Version Description
- (s2Member/s2Member Pro). WordPress 3.1. Updated for full compatibility with WordPress 3.1 ( s2Member also remains compatible with the WordPress 3.0.x series ).
- (s2Member/s2Member Pro). Speed Optimizations. s2Member's entire codebase has been re-organized into PHP classes containing s2Member's static functions ( dev note: all of s2Member's Hooks/Filters remain as they were ). This new infrastructure allows s2Member to take full advantage of PHP's built-in SPL Autoload extension. This means s2Member's source code is loaded ( only on-demand ) as function calls are made within core routines. So instead of loading s2Member's entire codebase into WordPress; only the objects/methods needed during the processing of particular page will be included. Long story short, this release of s2Member is much faster than previous versions. For advanced site owners, this will make it more feasible to run s2Member in concert many other plugins; even on shared hosting.
-
(s2Member). New feature. You can now force WordPress to use your Membership Labels instead of referencing them by s2Member Level #. For further details on this topic, check your Dashboard under
s2Member -> General Options -> Membership Levels/Labels
. -
(s2Member). Profile Shortcode. s2Member now provides a built-in Shortcode (
[s2Member-Profile /]
) that generates an inline Profile Modification Form; which can be inserted into any Post/Page ( such as your Login Welcome Page ) or even into a Text Widget if you like. This feature is ( in addition to ) the existing/?s2member_profile=1
stand-alone version that has always been available with s2Member. -
(s2Member). New feature. s2Member now supports Remote Header Authorization on File Downloads ( optional ). Remote Header Authorization allows access to file downloads through an entirely different approach ( again, using this is 100% optional ). Instead of asking the Member to log into your site through a browser, a Member can be prompted automatically, to log in through HTTP Header Authorization prompts; which is the same technique used in more traditional security systems via .htaccess files. In other words, Remote Header Authorization makes it possible for your Members to access files through remote applications that may NOT use a browser. This is often the case when a Member needs to access protected files through a software client like iTunes; typical with podcasts. For further details, please check your Dashboard under
s2Member -> Download Options -> Remote Auth / Podcasting
. -
(s2Member). New feature. s2Member now supports a new option in its Login/Registration Design panel. If you have WordPress 3.1+ installed, you can add your own raw HTML/PHP code to the very bottom of your default Login/Registration Forms with s2Member. Please check your Dashboard under:
s2Member -> General Options -> Login/Registration Design
. -
(s2Member). New feature. You can now tell s2Member to encrypt your PayPal Buttons automatically for added security. When this feature is enabled, all of your PayPal Button Shortcodes will produce encrypted PayPal Buttons. This improves security against fraudulent transactions. To turn this feature on, please log into your Dashboard and navigate to
s2Member -> PayPal Options -> Account Details
. You'll need to provide s2Member with your PayPal API Username/Password/Signature; and then enableButton Encryption
. Additional instructions are provided in your WordPress Dashboard. NOTE: This feature does NOT require you to have a PayPal Pro account. If you do, that's fine, but it's not a requirement. Also, this particular feature is ONLY applicable to PayPal Buttons ( it does NOT work with Pro Forms, nor does it need to ). - (s2Member Pro). CSV Exportation. s2Member now provides two different export formats. 1. Default CSV ( for easy re-importation ). 2. Easy-Read CSV ( improved readability; CANNOT be re-imported ). In addition to these new options, ALL CSV export formats now include column headers too. This makes CSV files easier to read inside applications like MS Excel or OpenOffice/Calc.
- (s2Member Pro). Authorize.Net. s2Member Pro now provides support for Authorize.Net integrations. Authorize.Net is a leading provider of payment gateway services, managing the submission of billions of transactions to processing networks on behalf of merchant customers. Authorize.Net is a solution offered by the CyberSource Corporation, a wholly owned subsidiary of Visa (NYSE: V).
- (s2Member Pro). ccBill. s2Member Pro now provides support for ccBill integration. ccBill is a great choice when you need to process transactions discreetly on an adult-oriented site. Drawing on its years of experience and proven payment processing platform, ccBill has a solution that will not only meet the requirements of your consumers, it will also help address the specific needs of your business.
-
(s2Member Pro). New feature. s2Member now allows for the inclusion of the Pro Login Widget directly into a theme/plugin file ( optional ). Example usage:
<?php echo s2member_pro_login_widget(); ?>
. It is also possible to configure widget options dynamically. For further details, please check the documentation inside this file:/s2member-pro/includes/functions/api-functions.inc.php
. -
(s2Member/s2Member Pro). Optimization. If/when s2Member's logging/debugging mechanisms are enabled through the Dashboard, s2Member is now capable of archiving its own log files. Oversize log files ( i.e. larger than 2MB ) are automatically renamed with
...-ARCHIVED-{time}.log
to prevent s2Member from creating ridiculously large log files that may have otherwise built up over a longer period of time. - (s2Member/s2Member Pro). New Profile field. A new drop-down menu has been added to the administration editing panel for User/Member Profiles. This new drop-down menu allows a site owner to specify which Payment Gateway a Member's payments are associated with. s2Member will automatically configure this field for you, but it is editable none the less. NOTE: If you are upgrading from a previous version of s2Member, you may notice that s2Member will NOT have this information on file for any existing Members that you obtained prior to installing s2Member v3.5+. You may want to go through and update the value of this field for each Member after upgrading. That being said, this new field is only provided for clarity; and for future compatibility. In other words, there is no functionality lost if the Payment Gateway field is left blank for previously existing Members.
-
(s2Member). New feature. s2Member now supports a new Replacement Code for Login Redirection URLs, and also for URI Restrictions (
%%current_user_ccaps%%
). This is the current User's set of Custom Capabilities. If the current User has multiple Custom Capabilities, they will be separated by hyphens; allowing this string to be used in the formulation of slugs for a Special Login Redirection URL; which could be configured differently for each Custom Capability Package that you offer. -
(s2Member). New feature. s2Member can now automate un-subscribe/opt-out removals for any List Servers that you've integrated ( i.e. MailChimp, AWeber ). s2Member is also capable of handling everything based on your own personal configuration preferences. You can choose which Events you consider grounds for List Removal. For further details, please check your Dashboard under:
s2Member -> API / List Servers -> Automate Un-Subscribes
. During a paid Subscription Modification, it also possible to have Members un-subscribed from Lists at their existing Membership Level#, while at the same time; subscribing them to Lists you've configured at the Membership Level they are upgrading/downgrading to. -
(s2Member). New feature. Brute Force IP/Login Restrictions. As with any Membership system, it is possible for someone to try and guess Username/Password combinations by attempting a Brute Force Attack; whereby multiple/repeated logins are strategically attempted with various Username/Password combinations until a correct guess is made. It is NOT likely that you'll be attacked in this way, but it's still a good idea to protect your system; just in case somebody tries this. s2Member thwarts this behavior by monitoring failed login attempts that occur within a short period of time. Whenever s2Member detects an IP address ( i.e. a remote user ) that is consistently failing to enter a valid Username/Password, a temporary ban is created; preventing additional attempts from taking place for 30 minutes. This temporary ban, will ONLY affect the offending IP address. For further details and configuration of this new feature, please check your Dashboard under:
s2Member -> General Options -> Brute Force IP/Login Restrictions
. -
(s2Member Pro). New feature. The s2Member (Pro) Login Widget now includes Login/Logout Redirection options. For further details, please check your Dashboard under:
Appearance -> Widgets -> s2Member (Pro) Login Widget
. -
(s2Member/s2Member Pro). Compatibility. s2Member now precedes all of its calls to these two functions with an @ sign (
@ini_get
and@ini_set
). This suppresses errors generated by PHP whenever these functions are disabled on the installation server. This is a very minor issue, as most hosting companies DO allow these functions to be called through PHP. At any rate, the preceding @ sign now puts s2Member inline with WordPress standards in this regard. -
(s2Member). WP 3.1 Compatibility. When "Redirect Members away from the Default Profile Panel?" is set to (
Yes
), s2Member will take an initiative to further safeguard ALL/wp-admin/
areas of your installation; not just the Default Profile Panel. Also, starting with WordPress 3.1+, setting this to (Yes
) tells s2Member to dynamically modify links/titles in the new Admin Bar that can be enabled on WordPress 3.1+. s2Member will force links to your Login Welcome Page instead of the Default Profile Panel; and Dashboard links are removed for non-Admin accounts ( as they should be ). -
(s2Member). New feature. It is now possible to delete/reset IP Restrictions ( i.e. temporary bans ) caused by a security breach in your configuration of s2Member's IP Restrictions. Some site owners have reported complaints from their Customers about the error
503 / Too Many IP Addresses
. This is not a bug; it is the result of a temporary ban that s2Member imposes automatically; based on your IP Restriction configuration in the General Options panel for s2Member. Improving upon this functionality in s2Member v3.5+, you can now pull up a Users account in your Dashboard and delete/reset temporary bans on a per-User basis; as needed for customer service. For further details, or to delete/reset ALL IP Restrictions at once, please check your Dashboard under:s2Member -> General Options -> IP Restrictions
. -
(s2Member). Multisite bug fix. When s2Member is installed on a Multisite Network, it is now capable of dealing with centralized Users accounts that are being shared across multiple sites in the Network. In other words, s2Member v3.5+ prevents WordPress from generating
username/email exists
errors through front-end forms whenever a User that exists on one site attempts to register on another. In order to accomplish this, s2Member v3.5 introduces one additional Multisite patch for your/wp-includes/ms-functions.php
file, making it possible for WordPress to add/remove existing User accounts from one site to another (gracefully); just like that which is supported natively in the WordPress Dashboard already. NOTE: after updating to s2Member v3.5+, please be sure to re-run your Multisite (Config) patches. You will find these patches in your Dashboard under:s2Member -> Multisite (Config)
. And yes, this is also compatible with WordPress v3.1. - (s2Member). Multisite auto-patcher. When running on a Multisite Network with `Automatically Patch WordPress
Download this release
Release Info
Developer | PriMoThemes |
Plugin | s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members) |
Version | 3.5 |
Comparing to | |
See all releases |
Code changes from version 3.3.2 to 3.5
- images/promos/150x150.jpg +0 -0
- images/promos/300x225.jpg +0 -0
- images/promos/590x300.jpg +0 -0
- images/promos/80x80.jpg +0 -0
- images/promos/900x285.jpg +0 -0
- images/promos/900x385.jpg +0 -0
- images/promos/shots/00_preview-590x300.jpg +0 -0
- images/promos/shots/00_preview-900x285.jpg +0 -0
- images/promos/shots/00_preview-900x385.jpg +0 -0
- images/promos/shots/01_screenshot-1200x.jpg +0 -0
- images/promos/shots/02_screenshot-1200x.jpg +0 -0
- images/promos/shots/03_screenshot-1200x.jpg +0 -0
- images/promos/shots/04_screenshot-1200x.jpg +0 -0
- images/promos/shots/05_screenshot-1200x.jpg +0 -0
- images/promos/shots/06_screenshot-1200x.jpg +0 -0
- images/promos/shots/07_screenshot-1200x.jpg +0 -0
- images/promos/shots/08_screenshot-1200x.jpg +0 -0
- images/promos/shots/09_screenshot-1200x.jpg +0 -0
- images/promos/shots/10_screenshot-1200x.jpg +0 -0
- images/promos/shots/11_screenshot-1200x.jpg +0 -0
- images/promos/shots/12_screenshot-1200x.jpg +0 -0
- images/promos/shots/13_screenshot-1200x.jpg +0 -0
- images/promos/shots/14_screenshot-1200x.jpg +0 -0
- images/promos/shots/15_screenshot-1200x.jpg +0 -0
- images/promos/shots/16_screenshot-1200x.jpg +0 -0
- images/promos/shots/17_screenshot-1200x.jpg +0 -0
- images/promos/shots/18_screenshot-1200x.jpg +0 -0
- images/promos/shots/19_screenshot-1200x.jpg +0 -0
- images/promos/shots/20_screenshot-1200x.jpg +0 -0
- images/promos/shots/21_screenshot-1200x.jpg +0 -0
- images/promos/shots/22_screenshot-1200x.jpg +0 -0
- images/promos/shots/23_screenshot-1200x.jpg +0 -0
- images/promos/shots/24_screenshot-1200x.jpg +0 -0
- images/promos/shots/25_screenshot-1200x.jpg +0 -0
- images/promos/shots/26_screenshot-1200x.jpg +0 -0
- images/promos/shots/27_screenshot-1200x.jpg +0 -0
- images/promos/shots/index.php +0 -0
- images/small-icon.png +0 -0
- includes/classes/admin-css-js.inc.php +89 -0
- includes/classes/admin-lockouts.inc.php +92 -0
- includes/classes/admin-notices.inc.php +138 -0
- includes/classes/auto-eots.inc.php +258 -0
- includes/classes/brute-force.inc.php +77 -0
- includes/classes/catgs-sp.inc.php +86 -0
- includes/classes/catgs.inc.php +100 -0
- includes/classes/check-activation.inc.php +48 -0
- includes/classes/constants.inc.php +197 -0
- includes/classes/cron-jobs.inc.php +62 -0
- includes/classes/css-js.inc.php +205 -0
- includes/classes/custom-reg-fields.inc.php +445 -0
- includes/classes/email-configs.inc.php +105 -0
- includes/classes/files-in.inc.php +211 -0
- includes/classes/files.inc.php +160 -0
- {images/promos → includes/classes}/index.php +0 -0
- includes/classes/installation.inc.php +328 -0
- includes/classes/ip-restrictions.inc.php +175 -0
- includes/classes/labels.inc.php +57 -0
- includes/classes/list-servers.inc.php +165 -0
- includes/classes/login-customizations.inc.php +137 -0
- includes/classes/login-redirects.inc.php +135 -0
- includes/classes/menu-pages.inc.php +554 -0
- includes/classes/meta-box-saves.inc.php +148 -0
- includes/classes/meta-box-security.inc.php +113 -0
- includes/classes/meta-boxes.inc.php +39 -0
- includes/classes/misc-redirects.inc.php +50 -0
- includes/classes/mms-patches.inc.php +128 -0
- includes/classes/nocache.inc.php +123 -0
- includes/classes/op-notices.inc.php +123 -0
- includes/classes/option-forces.inc.php +194 -0
- includes/classes/pages-sp.inc.php +107 -0
- includes/classes/pages.inc.php +133 -0
- includes/classes/paypal-notify-in.inc.php +1775 -0
- includes/classes/paypal-notify.inc.php +44 -0
- includes/classes/paypal-return-in.inc.php +518 -0
- includes/{functions → classes}/paypal-return.inc.php +12 -11
- includes/classes/paypal-utilities.inc.php +378 -0
- includes/classes/posts-sp.inc.php +110 -0
- includes/classes/posts.inc.php +138 -0
- includes/classes/profile-mods-in.inc.php +112 -0
- includes/classes/profile-mods.inc.php +34 -0
- includes/classes/profile.inc.php +42 -0
- includes/classes/ptags-sp.inc.php +104 -0
- includes/classes/ptags.inc.php +91 -0
- includes/classes/querys.inc.php +232 -0
- includes/classes/readmes.inc.php +190 -0
- includes/classes/register-access.inc.php +59 -0
- includes/classes/register-in.inc.php +69 -0
- includes/classes/register.inc.php +34 -0
- includes/classes/registration-times.inc.php +96 -0
- includes/classes/registrations.inc.php +839 -0
- includes/classes/ruris-sp.inc.php +74 -0
- includes/classes/ruris.inc.php +98 -0
- includes/classes/sc-gets-in.inc.php +62 -0
- includes/classes/sc-gets.inc.php +35 -0
- includes/classes/sc-if-conds-in.inc.php +241 -0
- includes/classes/sc-if-conds.inc.php +41 -0
- includes/classes/sc-paypal-button-e.inc.php +73 -0
- includes/classes/sc-paypal-button-in.inc.php +165 -0
- includes/classes/sc-paypal-button.inc.php +31 -0
- includes/classes/sc-profile-in.inc.php +270 -0
- includes/classes/sc-profile.inc.php +31 -0
- includes/classes/security.inc.php +84 -0
- includes/classes/sp-access.inc.php +134 -0
- includes/classes/ssl.inc.php +115 -0
- includes/classes/systematics-sp.inc.php +67 -0
- includes/classes/systematics.inc.php +75 -0
- includes/classes/tracking-codes.inc.php +104 -0
- includes/classes/tracking-cookies.inc.php +61 -0
- includes/classes/translations.inc.php +102 -0
- includes/classes/user-access.inc.php +111 -0
- includes/classes/user-deletions.inc.php +180 -0
- includes/classes/user-new-in.inc.php +249 -0
- includes/classes/user-new.inc.php +45 -0
- includes/classes/user-notes.inc.php +73 -0
- includes/classes/user-securities.inc.php +87 -0
- includes/classes/users-list-in.inc.php +469 -0
- includes/classes/users-list.inc.php +230 -0
- includes/classes/utilities.inc.php +62 -0
- includes/classes/utils-arrays.inc.php +78 -0
- includes/classes/utils-captchas.inc.php +44 -0
- includes/classes/utils-conds.inc.php +76 -0
- includes/classes/utils-css.inc.php +60 -0
- includes/classes/utils-dirs.inc.php +44 -0
- includes/classes/utils-encryption.inc.php +129 -0
- includes/classes/utils-forms.inc.php +78 -0
- includes/classes/utils-gets.inc.php +155 -0
- includes/classes/utils-logs.inc.php +77 -0
- includes/classes/utils-strings.inc.php +103 -0
- includes/classes/utils-time.inc.php +256 -0
- includes/classes/utils-urls.inc.php +86 -0
- includes/classes/utils-users.inc.php +187 -0
- includes/codes.inc.php +8 -6
- includes/funcs.inc.php +6 -5
- includes/functions/activate-deactivate.inc.php +0 -337
- includes/functions/admin-lockout.inc.php +0 -43
- includes/functions/admin-notices.inc.php +0 -117
- includes/functions/api-functions.inc.php +28 -28
- includes/functions/auto-eots.inc.php +0 -259
- includes/functions/catg-level-access.inc.php +0 -162
- includes/functions/class-autoloader.inc.php +58 -0
- includes/functions/config-user-registration.inc.php +0 -446
images/promos/150x150.jpg
DELETED
Binary file
|
images/promos/300x225.jpg
DELETED
Binary file
|
images/promos/590x300.jpg
DELETED
Binary file
|
images/promos/80x80.jpg
DELETED
Binary file
|
images/promos/900x285.jpg
DELETED
Binary file
|
images/promos/900x385.jpg
DELETED
Binary file
|
images/promos/shots/00_preview-590x300.jpg
DELETED
Binary file
|
images/promos/shots/00_preview-900x285.jpg
DELETED
Binary file
|
images/promos/shots/00_preview-900x385.jpg
DELETED
Binary file
|
images/promos/shots/01_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/02_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/03_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/04_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/05_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/06_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/07_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/08_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/09_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/10_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/11_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/12_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/13_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/14_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/15_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/16_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/17_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/18_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/19_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/20_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/21_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/22_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/23_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/24_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/25_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/26_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/27_screenshot-1200x.jpg
DELETED
Binary file
|
images/promos/shots/index.php
DELETED
File without changes
|
images/small-icon.png
ADDED
Binary file
|
includes/classes/admin-css-js.inc.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
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 |
+
/**/
|
44 |
+
echo "\n"; /* Add a line break before inclusion of this file. */
|
45 |
+
/**/
|
46 |
+
@include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s.css";
|
47 |
+
/**/
|
48 |
+
do_action ("ws_plugin__s2member_during_menu_pages_css", get_defined_vars ());
|
49 |
+
/**/
|
50 |
+
exit ();
|
51 |
+
}
|
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. */
|
77 |
+
/**/
|
78 |
+
@include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s-min.js";
|
79 |
+
/**/
|
80 |
+
do_action ("ws_plugin__s2member_during_menu_pages_js", get_defined_vars ());
|
81 |
+
/**/
|
82 |
+
exit ();
|
83 |
+
}
|
84 |
+
/**/
|
85 |
+
do_action ("ws_plugin__s2member_after_menu_pages_js", get_defined_vars ());
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
?>
|
includes/classes/admin-lockouts.inc.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 checks for special request methods 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"]));
|
39 |
+
/**/
|
40 |
+
exit (); /* Clean exit. */
|
41 |
+
}
|
42 |
+
/**/
|
43 |
+
do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
|
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. */
|
60 |
+
/**/
|
61 |
+
else /* Else we use the Login Welcome Page configured for s2Member. */
|
62 |
+
$lwp = get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]);
|
63 |
+
/**/
|
64 |
+
if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}) && is_array ($wp_admin_bar->menu->{"my-account-with-avatar"}))
|
65 |
+
if ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"] && is_object ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]))
|
66 |
+
{
|
67 |
+
$wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = $lwp;
|
68 |
+
$wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-my-profile"}["href"] = $lwp;
|
69 |
+
unset ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"dashboard"});
|
70 |
+
}
|
71 |
+
/**/
|
72 |
+
if (isset ($wp_admin_bar->menu->{"my-blogs"}) && is_array ($wp_admin_bar->menu->{"my-blogs"}))
|
73 |
+
if ($wp_admin_bar->menu->{"my-blogs"}["href"] && is_object ($wp_admin_bar->menu->{"my-blogs"}["children"]))
|
74 |
+
{
|
75 |
+
$wp_admin_bar->menu->{"my-blogs"}["href"] = "#"; /* Void this link by converting to #. */
|
76 |
+
/**/
|
77 |
+
foreach ($wp_admin_bar->menu->{"my-blogs"}["children"] as &$blog)
|
78 |
+
if (is_array ($blog) && $blog["href"] && is_object ($blog["children"]))
|
79 |
+
{
|
80 |
+
$blog["href"] = preg_replace ("/\/wp-admin/", "", $blog["href"]);
|
81 |
+
unset ($blog["children"]); /* Cause all we need is the link. */
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
/**/
|
86 |
+
do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
|
87 |
+
/**/
|
88 |
+
return; /* Return for uniformity. */
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
?>
|
includes/classes/admin-notices.inc.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**/
|
40 |
+
update_option ("ws_plugin__s2member_notices", c_ws_plugin__s2member_utils_arrays::array_unique ($notices));
|
41 |
+
}
|
42 |
+
/**/
|
43 |
+
do_action ("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
|
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 |
+
{
|
81 |
+
global $pagenow; /* This holds the current page filename. */
|
82 |
+
/**/
|
83 |
+
do_action ("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
|
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:` */
|
97 |
+
/**/
|
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 |
+
/**/
|
129 |
+
update_option ("ws_plugin__s2member_notices", $notices);
|
130 |
+
}
|
131 |
+
/**/
|
132 |
+
do_action ("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
|
133 |
+
/**/
|
134 |
+
return; /* Return for uniformity. */
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
?>
|
includes/classes/auto-eots.inc.php
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
26 |
+
do_action ("ws_plugin__s2member_before_add_auto_eot_system", get_defined_vars ());
|
27 |
+
/**/
|
28 |
+
if (!c_ws_plugin__s2member_auto_eots::delete_auto_eot_system ())
|
29 |
+
{
|
30 |
+
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
31 |
+
}
|
32 |
+
else if (function_exists ("wp_cron")) /* Otherwise, we can schedule? */
|
33 |
+
{
|
34 |
+
wp_schedule_event (time (), "every10m", "ws_plugin__s2member_auto_eot_system__schedule");
|
35 |
+
/**/
|
36 |
+
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", true, get_defined_vars ());
|
37 |
+
}
|
38 |
+
else /* Otherwise, it would appear that WP-Cron is not available. */
|
39 |
+
{
|
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 |
+
{
|
48 |
+
do_action ("ws_plugin__s2member_before_delete_auto_eot_system", get_defined_vars ());
|
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 |
+
}
|
56 |
+
else /* Otherwise, it would appear that WP-Cron is not available. */
|
57 |
+
{
|
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 |
+
{
|
78 |
+
global $wpdb; /* Need global DB obj. */
|
79 |
+
global $current_site, $current_blog; /* Multisite. */
|
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 |
+
/**/
|
90 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* Enabled? */
|
91 |
+
{
|
92 |
+
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
|
93 |
+
/**/
|
94 |
+
if (is_array ($eots = $wpdb->get_results ("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . $wpdb->escape (strtotime ("now")) . "' LIMIT " . $per_process)))
|
95 |
+
{
|
96 |
+
foreach ($eots as $eot) /* Go through the array of EOTS. We need to (demote|delete) each of them. */
|
97 |
+
{
|
98 |
+
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
99 |
+
{
|
100 |
+
delete_user_option ($user_id, "s2member_auto_eot_time"); /* ALWAYS delete this. */
|
101 |
+
/**/
|
102 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process Administrator accounts. */
|
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");
|
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 |
+
/**/
|
121 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
122 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
123 |
+
$user->remove_cap ($ccap = $cap);
|
124 |
+
/**/
|
125 |
+
delete_user_option ($user_id, "s2member_custom");
|
126 |
+
delete_user_option ($user_id, "s2member_subscr_id");
|
127 |
+
delete_user_option ($user_id, "s2member_subscr_gateway");
|
128 |
+
/**/
|
129 |
+
delete_user_option ($user_id, "s2member_ipn_signup_vars");
|
130 |
+
/**/
|
131 |
+
if (!apply_filters ("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars ()))
|
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 |
+
/**/
|
138 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
139 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
140 |
+
/**/
|
141 |
+
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
142 |
+
/**/
|
143 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
144 |
+
{
|
145 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
|
146 |
+
/**/
|
147 |
+
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 ($subscr_id)), $url)))
|
148 |
+
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)))
|
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)))
|
165 |
+
{
|
166 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release all Filters applied to wp_mail() From: headers. */
|
167 |
+
/**/
|
168 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
|
169 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
170 |
+
/**/
|
171 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
172 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
173 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
174 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
175 |
+
$msg .= "user_email: %%user_email%%\n";
|
176 |
+
$msg .= "user_login: %%user_login%%\n";
|
177 |
+
$msg .= "user_id: %%user_id%%\n";
|
178 |
+
/**/
|
179 |
+
if (is_array ($fields) && !empty ($fields))
|
180 |
+
foreach ($fields as $var => $val)
|
181 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
182 |
+
/**/
|
183 |
+
$msg .= "cv0: %%cv0%%\n";
|
184 |
+
$msg .= "cv1: %%cv1%%\n";
|
185 |
+
$msg .= "cv2: %%cv2%%\n";
|
186 |
+
$msg .= "cv3: %%cv3%%\n";
|
187 |
+
$msg .= "cv4: %%cv4%%\n";
|
188 |
+
$msg .= "cv5: %%cv5%%\n";
|
189 |
+
$msg .= "cv6: %%cv6%%\n";
|
190 |
+
$msg .= "cv7: %%cv7%%\n";
|
191 |
+
$msg .= "cv8: %%cv8%%\n";
|
192 |
+
$msg .= "cv9: %%cv9%%";
|
193 |
+
/**/
|
194 |
+
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 ($subscr_id), $msg)))
|
195 |
+
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)))
|
196 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
197 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
198 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
199 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
200 |
+
{
|
201 |
+
if (is_array ($fields) && !empty ($fields))
|
202 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
203 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
204 |
+
break;
|
205 |
+
/**/
|
206 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
207 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
|
208 |
+
($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;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
/**/
|
212 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
213 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
|
214 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
215 |
+
}
|
216 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
217 |
+
{
|
218 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
219 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars ());
|
220 |
+
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "auto-eot-cancellation-expiration-deletion");
|
221 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
222 |
+
/**/
|
223 |
+
if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
|
224 |
+
{
|
225 |
+
remove_user_from_blog ($user_id, $current_blog->blog_id);
|
226 |
+
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
227 |
+
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
|
228 |
+
}
|
229 |
+
/**/
|
230 |
+
else /* Otherwise, we can actually delete them. */
|
231 |
+
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
232 |
+
wp_delete_user ($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
|
233 |
+
/**/
|
234 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
235 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
236 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
237 |
+
}
|
238 |
+
/**/
|
239 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
240 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
|
241 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
/**/
|
248 |
+
c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients (); /* Cleanup. */
|
249 |
+
/**/
|
250 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
251 |
+
do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
|
252 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
253 |
+
/**/
|
254 |
+
return; /* Return for uniformity. */
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
?>
|
includes/classes/brute-force.inc.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**/
|
32 |
+
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
33 |
+
{
|
34 |
+
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
35 |
+
/* If you add Filters to this value, you should use a string that is compatible with PHP's strtotime() function. */
|
36 |
+
/**/
|
37 |
+
$transient = "s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"]);
|
38 |
+
set_transient ($transient, (int)get_transient ($transient) + 1, $exp_secs);
|
39 |
+
}
|
40 |
+
/**/
|
41 |
+
do_action ("ws_plugin__s2member_after_track_failed_logins", get_defined_vars ());
|
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 |
+
/**/
|
56 |
+
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
57 |
+
{
|
58 |
+
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
59 |
+
/* If you add Filters to this value, you should use a string that is compatible with PHP's strtotime() function. */
|
60 |
+
/**/
|
61 |
+
$about = c_ws_plugin__s2member_utils_time::approx_time_difference (time (), time () + $exp_secs);
|
62 |
+
/**/
|
63 |
+
if ((int)get_transient ("s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"])) > $max)
|
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 |
+
}
|
77 |
+
?>
|
includes/classes/catgs-sp.inc.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
38 |
+
do_action ("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars ());
|
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 |
+
/**/
|
79 |
+
do_action ("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars ());
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars ());
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
?>
|
includes/classes/catgs.inc.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
39 |
+
global $post; /* get_the_ID() is NOT available outside The Loop. */
|
40 |
+
/**/
|
41 |
+
do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
|
42 |
+
/**/
|
43 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
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 |
+
}
|
89 |
+
}
|
90 |
+
/**/
|
91 |
+
do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
|
92 |
+
}
|
93 |
+
/**/
|
94 |
+
do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
|
95 |
+
/**/
|
96 |
+
return; /* For uniformity. */
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
?>
|
includes/classes/check-activation.inc.php
ADDED
@@ -0,0 +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_check_activation"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_check_activation
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Check existing installations that have not been 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. */
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
?>
|
includes/classes/constants.inc.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Define 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 |
+
{
|
28 |
+
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
|
29 |
+
/**/
|
30 |
+
$links = c_ws_plugin__s2member_constants::constant_links ();
|
31 |
+
$level = c_ws_plugin__s2member_user_access::user_access_level ();
|
32 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
|
33 |
+
$file_downloads = c_ws_plugin__s2member_files::user_downloads ($current_user, false, null);
|
34 |
+
$subscr_id = ($current_user) ? get_user_option ("s2member_subscr_id", $current_user->ID) : "";
|
35 |
+
$subscr_gateway = ($current_user) ? get_user_option ("s2member_subscr_gateway", $current_user->ID) : "";
|
36 |
+
$custom = ($current_user) ? get_user_option ("s2member_custom", $current_user->ID) : "";
|
37 |
+
$custom_fields = ($current_user) ? get_user_option ("s2member_custom_fields", $current_user->ID) : array ();
|
38 |
+
$paid_registration_times = ($current_user) ? get_user_option ("s2member_paid_registration_times", $current_user->ID) : array ();
|
39 |
+
$login_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($current_user);
|
40 |
+
/**/
|
41 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
42 |
+
do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
|
43 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
44 |
+
/**/
|
45 |
+
define ("S2MEMBER_VERSION", ($c[] = WS_PLUGIN__S2MEMBER_VERSION)); /* Since 3.0. */
|
46 |
+
/**/
|
47 |
+
define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", ($c[] = (($current_user) ? true : false)));
|
48 |
+
define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", ($c[] = ( ($current_user && $level >= 1) ? true : false)));
|
49 |
+
define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", ($c[] = (int)$level));
|
50 |
+
define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]));
|
51 |
+
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", ($c[] = (($current_user) ? (($subscr_id) ? (string)$subscr_id : (string)$current_user->ID) : "")));
|
52 |
+
define ("S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY", ($c[] = (($current_user) ? (string)$subscr_gateway : "")));
|
53 |
+
define ("S2MEMBER_CURRENT_USER_CUSTOM", ($c[] = (string)$custom));
|
54 |
+
define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", ($c[] = ( ($current_user && $current_user->user_registered) ? (int)strtotime ($current_user->user_registered) : 0)));
|
55 |
+
define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME", ($c[] = ( ($current_user && (int)$paid_registration_times["level"]) ? (int)$paid_registration_times["level"] : 0)));
|
56 |
+
define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS", ($c[] = ( ($current_user && (int)$paid_registration_times["level"]) ? (int)floor ((strtotime ("now") - (int)$paid_registration_times["level"]) / 86400) : 0)));
|
57 |
+
define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", ($c[] = ( ($current_user && $current_user->user_registered) ? (int)floor ((strtotime ("now") - strtotime ($current_user->user_registered)) / 86400) : 0)));
|
58 |
+
define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", ($c[] = (($current_user) ? (string)$current_user->display_name : "")));
|
59 |
+
define ("S2MEMBER_CURRENT_USER_FIRST_NAME", ($c[] = (($current_user) ? (string)$current_user->first_name : "")));
|
60 |
+
define ("S2MEMBER_CURRENT_USER_LAST_NAME", ($c[] = (($current_user) ? (string)$current_user->last_name : "")));
|
61 |
+
define ("S2MEMBER_CURRENT_USER_LOGIN", ($c[] = (($current_user) ? (string)$current_user->user_login : "")));
|
62 |
+
define ("S2MEMBER_CURRENT_USER_EMAIL", ($c[] = (($current_user) ? (string)$current_user->user_email : "")));
|
63 |
+
define ("S2MEMBER_CURRENT_USER_IP", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
|
64 |
+
define ("S2MEMBER_CURRENT_USER_ID", ($c[] = (($current_user) ? (int)$current_user->ID : 0)));
|
65 |
+
define ("S2MEMBER_CURRENT_USER_FIELDS", ($c[] = (($current_user) ? json_encode (array_merge (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN, "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME, "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "subscr_gateway" => S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), (array)$custom_fields)) : json_encode (array ()))));
|
66 |
+
/**/
|
67 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", ($c[] = (int)$file_downloads["allowed"]));
|
68 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", ($c[] = ( ($file_downloads["allowed"] >= 999999999) ? true : false)));
|
69 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", ($c[] = (int)$file_downloads["currently"]));
|
70 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$file_downloads["allowed_days"]));
|
71 |
+
/**/
|
72 |
+
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]));
|
73 |
+
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]));
|
74 |
+
define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
75 |
+
/**/
|
76 |
+
define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = site_url ("/?s2member_profile=1")));
|
77 |
+
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
|
78 |
+
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"]));
|
79 |
+
define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
|
80 |
+
define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ()));
|
81 |
+
define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url ()));
|
82 |
+
/**/
|
83 |
+
define ("S2MEMBER_LEVEL0_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]));
|
84 |
+
define ("S2MEMBER_LEVEL1_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]));
|
85 |
+
define ("S2MEMBER_LEVEL2_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]));
|
86 |
+
define ("S2MEMBER_LEVEL3_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]));
|
87 |
+
define ("S2MEMBER_LEVEL4_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]));
|
88 |
+
/**/
|
89 |
+
define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"]));
|
90 |
+
define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]));
|
91 |
+
define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]));
|
92 |
+
define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]));
|
93 |
+
define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]));
|
94 |
+
/**/
|
95 |
+
define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"]));
|
96 |
+
define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]));
|
97 |
+
define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]));
|
98 |
+
define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]));
|
99 |
+
define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]));
|
100 |
+
/**/
|
101 |
+
define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]));
|
102 |
+
/**/
|
103 |
+
define ("S2MEMBER_REG_EMAIL_FROM_NAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]));
|
104 |
+
define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]));
|
105 |
+
/**/
|
106 |
+
define ("S2MEMBER_PAYPAL_NOTIFY_URL", ($c[] = site_url ("/?s2member_paypal_notify=1")));
|
107 |
+
define ("S2MEMBER_PAYPAL_RETURN_URL", ($c[] = site_url ("/?s2member_paypal_return=1")));
|
108 |
+
/**/
|
109 |
+
define ("S2MEMBER_PAYPAL_BUSINESS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]));
|
110 |
+
define ("S2MEMBER_PAYPAL_ENDPOINT", ($c[] = ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")));
|
111 |
+
define ("S2MEMBER_PAYPAL_API_ENDPOINT", ($c[] = ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com")));
|
112 |
+
define ("S2MEMBER_PAYPAL_API_USERNAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]));
|
113 |
+
define ("S2MEMBER_PAYPAL_API_PASSWORD", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]));
|
114 |
+
define ("S2MEMBER_PAYPAL_API_SIGNATURE", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]));
|
115 |
+
/**/
|
116 |
+
define ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]));
|
117 |
+
/**/
|
118 |
+
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_ID) ? "Updating Subscr. ID" : "")));
|
119 |
+
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ($c[] = ((S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) ? S2MEMBER_CURRENT_USER_SUBSCR_ID : "")));
|
120 |
+
/**/
|
121 |
+
$c = apply_filters ("ws_plugin__s2member_during_constants_c", $c, get_defined_vars ()); /* Allows other Constants to be calculated nicely. */
|
122 |
+
/**/
|
123 |
+
define ("WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5", md5 (serialize ($c))); /* Used as a Checksum against the state of these Constants. */
|
124 |
+
/**/
|
125 |
+
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ()); /* Calls the after Hook. Do NOT set Constants here. */
|
126 |
+
/**/
|
127 |
+
return; /* Return for uniformity. */
|
128 |
+
}
|
129 |
+
/*
|
130 |
+
This function pulls all of the Page links needed for Constants.
|
131 |
+
Page links are cached into the s2Member options on 15 min intervals.
|
132 |
+
This allows the API Constants to provide quick access to them without being
|
133 |
+
forced to execute get_page_link() all the time, which piles up DB queries.
|
134 |
+
*/
|
135 |
+
public static function constant_links ()
|
136 |
+
{
|
137 |
+
do_action ("ws_plugin__s2member_before_constant_links", get_defined_vars ());
|
138 |
+
/**/
|
139 |
+
$l = array ("login_welcome_page" => "", "membership_options_page" => "", "file_download_limit_exceeded_page" => "");
|
140 |
+
/**/
|
141 |
+
$login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
142 |
+
$membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
143 |
+
$file_download_limit_exceeded_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
144 |
+
/**/
|
145 |
+
$login_welcome_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
|
146 |
+
$membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
|
147 |
+
$file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
|
148 |
+
/**/
|
149 |
+
if ($login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["time"] >= strtotime ("-15 minutes"))
|
150 |
+
{
|
151 |
+
$l["login_welcome_page"] = $login_welcome_page_cache["link"];
|
152 |
+
}
|
153 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
154 |
+
{
|
155 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = strtotime ("now");
|
156 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $login_welcome_page;
|
157 |
+
$l["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($login_welcome_page);
|
158 |
+
/**/
|
159 |
+
$cache_needs_updating = true;
|
160 |
+
}
|
161 |
+
/**/
|
162 |
+
if ($membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["time"] >= strtotime ("-15 minutes"))
|
163 |
+
{
|
164 |
+
$l["membership_options_page"] = $membership_options_page_cache["link"];
|
165 |
+
}
|
166 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
167 |
+
{
|
168 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = strtotime ("now");
|
169 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $membership_options_page;
|
170 |
+
$l["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($membership_options_page);
|
171 |
+
/**/
|
172 |
+
$cache_needs_updating = true;
|
173 |
+
}
|
174 |
+
/**/
|
175 |
+
if ($file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-15 minutes"))
|
176 |
+
{
|
177 |
+
$l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
|
178 |
+
}
|
179 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
180 |
+
{
|
181 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = strtotime ("now");
|
182 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $file_download_limit_exceeded_page;
|
183 |
+
$l["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($file_download_limit_exceeded_page);
|
184 |
+
/**/
|
185 |
+
$cache_needs_updating = true;
|
186 |
+
}
|
187 |
+
/**/
|
188 |
+
if ($cache_needs_updating) /* The cache is also reset when options are updated from a menu page. */
|
189 |
+
{
|
190 |
+
update_option ("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]);
|
191 |
+
}
|
192 |
+
/**/
|
193 |
+
return apply_filters ("ws_plugin__s2member_constant_links", $l, get_defined_vars ());
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
?>
|
includes/classes/cron-jobs.inc.php
ADDED
@@ -0,0 +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_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 ())
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_extend_cron_schedules", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
$array = array ("every10m" => array ("interval" => 600, "display" => "Every 10 Minutes"));
|
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
|
37 |
+
processed through a server-side Cron Job.
|
38 |
+
Attach to: add_action("init");
|
39 |
+
*/
|
40 |
+
public static function auto_eot_system_via_cron ()
|
41 |
+
{
|
42 |
+
do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
|
43 |
+
/**/
|
44 |
+
if ($_GET["s2member_auto_eot_system_via_cron"]) /* Being called through HTTP? */
|
45 |
+
{
|
46 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
47 |
+
{
|
48 |
+
c_ws_plugin__s2member_auto_eots::auto_eot_system (); /* Process Auto EOTs now. */
|
49 |
+
/**/
|
50 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_via_cron", get_defined_vars ());
|
51 |
+
}
|
52 |
+
/**/
|
53 |
+
exit (); /* Clean exit. */
|
54 |
+
}
|
55 |
+
/**/
|
56 |
+
do_action ("ws_plugin__s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
57 |
+
/**/
|
58 |
+
return; /* Return for uniformity. */
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
includes/classes/css-js.inc.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Adds CSS files.
|
23 |
+
Attach to: add_action("wp_print_styles");
|
24 |
+
*/
|
25 |
+
public static function add_css ()
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
if (!is_admin ()) /* Not in the admin. */
|
30 |
+
{
|
31 |
+
wp_enqueue_style ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_css=1&qcABC=1"), array (), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
|
32 |
+
/**/
|
33 |
+
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
|
34 |
+
}
|
35 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_after_add_css", get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
return; /* Return for uniformity. */
|
39 |
+
}
|
40 |
+
/*
|
41 |
+
Builds CSS files.
|
42 |
+
Attach to: add_action("init");
|
43 |
+
*/
|
44 |
+
public static function css ()
|
45 |
+
{
|
46 |
+
do_action ("ws_plugin__s2member_before_css", get_defined_vars ());
|
47 |
+
/**/
|
48 |
+
if ($_GET["ws_plugin__s2member_css"])
|
49 |
+
{
|
50 |
+
header ("Content-Type: text/css; charset=utf-8");
|
51 |
+
header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
|
52 |
+
header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
|
53 |
+
header ("Cache-Control: max-age=604800");
|
54 |
+
header ("Pragma: public");
|
55 |
+
/**/
|
56 |
+
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
57 |
+
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
|
58 |
+
/**/
|
59 |
+
ob_start ("c_ws_plugin__s2member_utils_css::compress_css"); /* Compress. */
|
60 |
+
/**/
|
61 |
+
include_once dirname (dirname (__FILE__)) . "/s2member.css";
|
62 |
+
/**/
|
63 |
+
do_action ("ws_plugin__s2member_during_css", get_defined_vars ());
|
64 |
+
/**/
|
65 |
+
exit (); /* Clean exit. */
|
66 |
+
}
|
67 |
+
/**/
|
68 |
+
do_action ("ws_plugin__s2member_after_css", get_defined_vars ());
|
69 |
+
}
|
70 |
+
/*
|
71 |
+
Adds JavaScript files.
|
72 |
+
Attach to: add_action("wp_print_scripts");
|
73 |
+
*/
|
74 |
+
public static function add_js_w_globals ()
|
75 |
+
{
|
76 |
+
global $pagenow; /* Need this for comparisons. */
|
77 |
+
/**/
|
78 |
+
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
|
79 |
+
/**/
|
80 |
+
if (!is_admin () || (c_ws_plugin__s2member_utils_conds::is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
|
81 |
+
{
|
82 |
+
if (is_user_logged_in ()) /* Separate version for logged-in Users/Members. */
|
83 |
+
{
|
84 |
+
$md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */
|
85 |
+
/* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
|
86 |
+
/* For instance, the global variables may change when a User who is logged-in changes their Profile. */
|
87 |
+
wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=1&qcABC=1&" . $md5), array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
|
88 |
+
}
|
89 |
+
else /* Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5. */
|
90 |
+
{ /* This essentially creates 2 versions of the script. One while logged in & another when not. */
|
91 |
+
wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=1&qcABC=1"), array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
|
92 |
+
}
|
93 |
+
/**/
|
94 |
+
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
|
95 |
+
}
|
96 |
+
/**/
|
97 |
+
do_action ("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars ());
|
98 |
+
/**/
|
99 |
+
return; /* Return for uniformity. */
|
100 |
+
}
|
101 |
+
/*
|
102 |
+
Builds JavaScript files.
|
103 |
+
Attach to: add_action("init");
|
104 |
+
*/
|
105 |
+
public static function js_w_globals ()
|
106 |
+
{
|
107 |
+
do_action ("ws_plugin__s2member_before_js_w_globals", get_defined_vars ());
|
108 |
+
/**/
|
109 |
+
if ($_GET["ws_plugin__s2member_js_w_globals"])
|
110 |
+
{
|
111 |
+
header ("Content-Type: text/javascript; charset=utf-8");
|
112 |
+
header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
|
113 |
+
header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
|
114 |
+
header ("Cache-Control: max-age=604800");
|
115 |
+
header ("Pragma: public");
|
116 |
+
/**/
|
117 |
+
$g = "var S2MEMBER_VERSION = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_VERSION) . "',"; /* Since 3.0. */
|
118 |
+
/**/
|
119 |
+
$g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
|
120 |
+
$g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false") . ",";
|
121 |
+
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
|
122 |
+
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
|
123 |
+
$g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
|
124 |
+
$g .= "S2MEMBER_CURRENT_USER_CUSTOM = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_CUSTOM) . "',";
|
125 |
+
$g .= "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_REGISTRATION_TIME . ",";
|
126 |
+
$g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME . ",";
|
127 |
+
$g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS . ",";
|
128 |
+
$g .= "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_REGISTRATION_DAYS . ",";
|
129 |
+
$g .= "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_DISPLAY_NAME) . "',";
|
130 |
+
$g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_FIRST_NAME) . "',";
|
131 |
+
$g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LAST_NAME) . "',";
|
132 |
+
$g .= "S2MEMBER_CURRENT_USER_LOGIN = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LOGIN) . "',";
|
133 |
+
$g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_EMAIL) . "',";
|
134 |
+
$g .= "S2MEMBER_CURRENT_USER_IP = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_IP) . "',";
|
135 |
+
$g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
|
136 |
+
$g .= "S2MEMBER_CURRENT_USER_FIELDS = " . S2MEMBER_CURRENT_USER_FIELDS . ",";
|
137 |
+
/**/
|
138 |
+
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED . ",";
|
139 |
+
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = " . ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false") . ",";
|
140 |
+
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = " . S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY . ",";
|
141 |
+
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS . ",";
|
142 |
+
/**/
|
143 |
+
$g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = " . S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID . ",";
|
144 |
+
$g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID . ",";
|
145 |
+
$g .= "S2MEMBER_LOGIN_WELCOME_PAGE_ID = " . S2MEMBER_LOGIN_WELCOME_PAGE_ID . ",";
|
146 |
+
/**/
|
147 |
+
$g .= "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL) . "',";
|
148 |
+
$g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL) . "',";
|
149 |
+
$g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL) . "',";
|
150 |
+
$g .= "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGIN_WELCOME_PAGE_URL) . "',";
|
151 |
+
$g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGOUT_PAGE_URL) . "',";
|
152 |
+
$g .= "S2MEMBER_LOGIN_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGIN_PAGE_URL) . "',";
|
153 |
+
/**/
|
154 |
+
$g .= "S2MEMBER_LEVEL0_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL0_LABEL) . "',";
|
155 |
+
$g .= "S2MEMBER_LEVEL1_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL1_LABEL) . "',";
|
156 |
+
$g .= "S2MEMBER_LEVEL2_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL2_LABEL) . "',";
|
157 |
+
$g .= "S2MEMBER_LEVEL3_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL3_LABEL) . "',";
|
158 |
+
$g .= "S2MEMBER_LEVEL4_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL4_LABEL) . "',";
|
159 |
+
/**/
|
160 |
+
$g .= "S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED . ",";
|
161 |
+
$g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED . ",";
|
162 |
+
$g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED . ",";
|
163 |
+
$g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED . ",";
|
164 |
+
$g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED . ",";
|
165 |
+
/**/
|
166 |
+
$g .= "S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
|
167 |
+
$g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
|
168 |
+
$g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
|
169 |
+
$g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
|
170 |
+
$g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
|
171 |
+
/**/
|
172 |
+
$g .= "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS) . "',";
|
173 |
+
/**/
|
174 |
+
$g .= "S2MEMBER_REG_EMAIL_FROM_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_REG_EMAIL_FROM_NAME) . "',";
|
175 |
+
$g .= "S2MEMBER_REG_EMAIL_FROM_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_REG_EMAIL_FROM_EMAIL) . "',";
|
176 |
+
/**/
|
177 |
+
$g .= "S2MEMBER_PAYPAL_NOTIFY_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_PAYPAL_NOTIFY_URL) . "',";
|
178 |
+
$g .= "S2MEMBER_PAYPAL_RETURN_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_PAYPAL_RETURN_URL) . "',";
|
179 |
+
/**/
|
180 |
+
$g .= "S2MEMBER_PAYPAL_BUSINESS = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_PAYPAL_BUSINESS) . "',";
|
181 |
+
$g .= "S2MEMBER_PAYPAL_ENDPOINT = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_PAYPAL_ENDPOINT) . "',";
|
182 |
+
$g .= "S2MEMBER_PAYPAL_API_ENDPOINT = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_PAYPAL_API_ENDPOINT) . "',";
|
183 |
+
/**/
|
184 |
+
$g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) . "',";
|
185 |
+
$g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0) . "',";
|
186 |
+
/**/
|
187 |
+
$g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
|
188 |
+
/**/
|
189 |
+
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
190 |
+
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
|
191 |
+
/**/
|
192 |
+
echo $g . "\n"; /* Add a line break before inclusion. */
|
193 |
+
/**/
|
194 |
+
include_once dirname (dirname (__FILE__)) . "/s2member-min.js";
|
195 |
+
/**/
|
196 |
+
do_action ("ws_plugin__s2member_during_js_w_globals", get_defined_vars ());
|
197 |
+
/**/
|
198 |
+
exit (); /* Clean exit. */
|
199 |
+
}
|
200 |
+
/**/
|
201 |
+
do_action ("ws_plugin__s2member_after_js_w_globals", get_defined_vars ());
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
?>
|
includes/classes/custom-reg-fields.inc.php
ADDED
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
+
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
+
|
6 |
+
Released under the terms of the GNU General Public License.
|
7 |
+
You should have received a copy of the GNU General Public License,
|
8 |
+
along with this software. In the main directory, see: /licensing/
|
9 |
+
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Direct access denial.
|
13 |
+
*/
|
14 |
+
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
+
exit ("Do not access this file directly.");
|
16 |
+
/**/
|
17 |
+
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 |
+
/**/
|
36 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
37 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
38 |
+
/**/
|
39 |
+
$name_suffix = (preg_match ("/\[$/", $_name_prefix)) ? ']' : '';
|
40 |
+
$field_name = trim ($_name_prefix . $field_var . $name_suffix);
|
41 |
+
/**/
|
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", " ", 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", " ", 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 |
+
Function 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")
|
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 |
+
/**/
|
172 |
+
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level () : $_level;
|
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 |
+
$configured[] = $field["id"]; /* Add this to the array. */
|
183 |
+
}
|
184 |
+
/**/
|
185 |
+
return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", $configured, get_defined_vars ());
|
186 |
+
}
|
187 |
+
/*
|
188 |
+
This adds custom fields to `wp-signup.php`.
|
189 |
+
Attach to: add_action("signup_extra_fields");
|
190 |
+
~ For Multisite Blog Farms.
|
191 |
+
*/
|
192 |
+
public static function ms_custom_registration_fields ()
|
193 |
+
{
|
194 |
+
do_action ("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars ());
|
195 |
+
/**/
|
196 |
+
if (is_multisite () && is_main_site ()) /* Must be Multisite / Main Site. */
|
197 |
+
{
|
198 |
+
$_POST = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
|
199 |
+
/**/
|
200 |
+
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
|
201 |
+
/**/
|
202 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
203 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ());
|
204 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
205 |
+
/**/
|
206 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
207 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ());
|
208 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
209 |
+
/**/
|
210 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">First Name *</label>' . "\n";
|
211 |
+
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 ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n";
|
212 |
+
echo '<br />' . "\n";
|
213 |
+
/**/
|
214 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
215 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars ());
|
216 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
217 |
+
/**/
|
218 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
219 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars ());
|
220 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
221 |
+
/**/
|
222 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">Last Name *</label>' . "\n";
|
223 |
+
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 ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n";
|
224 |
+
echo '<br />' . "\n";
|
225 |
+
/**/
|
226 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
227 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ());
|
228 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
229 |
+
/**/
|
230 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
231 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection"))
|
232 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
233 |
+
{
|
234 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
235 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ());
|
236 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
237 |
+
/**/
|
238 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
239 |
+
{
|
240 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
241 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
242 |
+
/**/
|
243 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
244 |
+
if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
|
245 |
+
{
|
246 |
+
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";
|
247 |
+
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", "", "", "", $_POST, $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var]);
|
248 |
+
echo '<br />' . "\n";
|
249 |
+
}
|
250 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
251 |
+
}
|
252 |
+
/**/
|
253 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
254 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ());
|
255 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
256 |
+
}
|
257 |
+
/**/
|
258 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
|
259 |
+
{
|
260 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
261 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ());
|
262 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
263 |
+
/**/
|
264 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
|
265 |
+
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 ($_POST) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
|
266 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
267 |
+
echo '</label>' . "\n";
|
268 |
+
echo '<br />' . "\n";
|
269 |
+
/**/
|
270 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
271 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ());
|
272 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
273 |
+
}
|
274 |
+
/**/
|
275 |
+
echo '<br />' . "\n"; /* Toss in one extra line break ( extra margin ). */
|
276 |
+
/**/
|
277 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
278 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ());
|
279 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
280 |
+
}
|
281 |
+
/**/
|
282 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
283 |
+
do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ());
|
284 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
285 |
+
/**/
|
286 |
+
return; /* Return for uniformity. */
|
287 |
+
}
|
288 |
+
/*
|
289 |
+
This adds custom fields to `wp-login.php?action=register`.
|
290 |
+
Attach to: add_action("register_form");
|
291 |
+
*/
|
292 |
+
public static function custom_registration_fields ()
|
293 |
+
{
|
294 |
+
do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ());
|
295 |
+
/**/
|
296 |
+
$_POST = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
|
297 |
+
/**/
|
298 |
+
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
|
299 |
+
/**/
|
300 |
+
$tabindex = 20; /* Incremented tabindex starting with 20. */
|
301 |
+
/**/
|
302 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
303 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ());
|
304 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
305 |
+
/**/
|
306 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) /* Custom Passwords? */
|
307 |
+
{
|
308 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
309 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ());
|
310 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
311 |
+
/**/
|
312 |
+
echo '<p>' . "\n";
|
313 |
+
echo '<label>' . "\n";
|
314 |
+
echo '<span>Password *</span><br />' . "\n";
|
315 |
+
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 ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
316 |
+
echo '</label>' . "\n";
|
317 |
+
echo '</p>';
|
318 |
+
/**/
|
319 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
320 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ());
|
321 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
322 |
+
}
|
323 |
+
/**/
|
324 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
325 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ());
|
326 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
327 |
+
/**/
|
328 |
+
echo '<p>' . "\n";
|
329 |
+
echo '<label>' . "\n";
|
330 |
+
echo '<span>First Name *</span><br />' . "\n";
|
331 |
+
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 ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
332 |
+
echo '</label>' . "\n";
|
333 |
+
echo '</p>';
|
334 |
+
/**/
|
335 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
336 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ());
|
337 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
338 |
+
/**/
|
339 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
340 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ());
|
341 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
342 |
+
/**/
|
343 |
+
echo '<p>' . "\n";
|
344 |
+
echo '<label>' . "\n";
|
345 |
+
echo '<span>Last Name *</span><br />' . "\n";
|
346 |
+
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 ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
347 |
+
echo '</label>' . "\n";
|
348 |
+
echo '</p>';
|
349 |
+
/**/
|
350 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
351 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ());
|
352 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
353 |
+
/**/
|
354 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
355 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection"))
|
356 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
357 |
+
{
|
358 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
359 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ());
|
360 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
361 |
+
/**/
|
362 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
363 |
+
{
|
364 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
365 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
366 |
+
/**/
|
367 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
368 |
+
if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
|
369 |
+
{
|
370 |
+
echo '<p>' . "\n";
|
371 |
+
echo '<label>' . "\n";
|
372 |
+
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";
|
373 |
+
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), "", $_POST, $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var]);
|
374 |
+
echo '</label>' . "\n";
|
375 |
+
echo '</p>';
|
376 |
+
}
|
377 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
378 |
+
}
|
379 |
+
/**/
|
380 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
381 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ());
|
382 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
383 |
+
}
|
384 |
+
/**/
|
385 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
|
386 |
+
{
|
387 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
388 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ());
|
389 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
390 |
+
/**/
|
391 |
+
echo '<p>' . "\n";
|
392 |
+
echo '<label>' . "\n";
|
393 |
+
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 ($_POST) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
394 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
395 |
+
echo '</label>' . "\n";
|
396 |
+
echo '</p>';
|
397 |
+
/**/
|
398 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
399 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ());
|
400 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
401 |
+
}
|
402 |
+
/**/
|
403 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
404 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ());
|
405 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
406 |
+
/**/
|
407 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
408 |
+
do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ());
|
409 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
410 |
+
/**/
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
/*
|
414 |
+
This adds an opt-in checkbox to the BuddyPress signup form.
|
415 |
+
Attach to: add_action("bp_before_registration_submit_buttons");
|
416 |
+
*/
|
417 |
+
public static function opt_in_4bp ()
|
418 |
+
{
|
419 |
+
do_action ("ws_plugin__s2member_before_opt_in_4bp", get_defined_vars ());
|
420 |
+
/**/
|
421 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
|
422 |
+
{
|
423 |
+
do_action ("ws_plugin__s2member_during_opt_in_4bp_before", get_defined_vars ());
|
424 |
+
/**/
|
425 |
+
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";
|
426 |
+
/**/
|
427 |
+
echo '<p>' . "\n";
|
428 |
+
echo '<label>' . "\n";
|
429 |
+
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 ($_POST) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
|
430 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
431 |
+
echo '</label>' . "\n";
|
432 |
+
echo '</p>';
|
433 |
+
/**/
|
434 |
+
echo '</div>' . "\n";
|
435 |
+
/**/
|
436 |
+
do_action ("ws_plugin__s2member_during_opt_in_4bp_after", get_defined_vars ());
|
437 |
+
}
|
438 |
+
/**/
|
439 |
+
do_action ("ws_plugin__s2member_after_opt_in_4bp", get_defined_vars ());
|
440 |
+
/**/
|
441 |
+
return;
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
?>
|
includes/classes/email-configs.inc.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_email_config", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release all Filters. */
|
30 |
+
/**/
|
31 |
+
add_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
32 |
+
add_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
33 |
+
/**/
|
34 |
+
do_action ("ws_plugin__s2member_after_email_config", get_defined_vars ());
|
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 |
+
{
|
43 |
+
do_action ("_ws_plugin__s2member_before_email_config_email", get_defined_vars ());
|
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 |
+
{
|
52 |
+
do_action ("_ws_plugin__s2member_before_email_config_name", get_defined_vars ());
|
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 |
+
{
|
61 |
+
do_action ("ws_plugin__s2member_before_email_config_status", get_defined_vars ());
|
62 |
+
/**/
|
63 |
+
if (has_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email") || has_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name"))
|
64 |
+
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
65 |
+
/**/
|
66 |
+
else if ($any && (has_filter ("wp_mail_from") || has_filter ("wp_mail_from_name")))
|
67 |
+
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
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 |
+
{
|
76 |
+
do_action ("ws_plugin__s2member_before_email_config_release", get_defined_vars ());
|
77 |
+
/**/
|
78 |
+
remove_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
79 |
+
remove_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
80 |
+
/**/
|
81 |
+
if ($all) /* If $all is true, then we remove all attached WordPress® Filters. */
|
82 |
+
remove_all_filters ("wp_mail_from") . remove_all_filters ("wp_mail_from_name");
|
83 |
+
/**/
|
84 |
+
do_action ("ws_plugin__s2member_after_email_config_release", get_defined_vars ());
|
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 |
+
{
|
95 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
?>
|
includes/classes/files-in.inc.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$_GET["s2member_file_download_key"] = (!$_GET["s2member_file_download_key"] && $_GET["s2member_free_file_download_key"]) ? $_GET["s2member_free_file_download_key"] : $_GET["s2member_file_download_key"];
|
34 |
+
/**/
|
35 |
+
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))))))
|
36 |
+
{
|
37 |
+
$_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/"); /* Trim slashes after Key comparison. */
|
38 |
+
/**/
|
39 |
+
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
|
40 |
+
{
|
41 |
+
header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
|
42 |
+
exit ("404: Sorry, file not found. Please contact Support for assistance.");
|
43 |
+
}
|
44 |
+
else if ($_GET["s2member_file_download_key"] && !$file_download_key_is_valid) /* Was an invalid Key passed in? */
|
45 |
+
{
|
46 |
+
header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Invalid Download Keys are handled separately. */
|
47 |
+
exit ("503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.");
|
48 |
+
}
|
49 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Is a Membership Options Page configured? */
|
50 |
+
/* This file will be processed WITHOUT a Download Key, using Membership Level Access ( w/ possible Custom Capabilities ). */
|
51 |
+
{
|
52 |
+
if (!has_filter ("ws_plugin__s2member_check_file_download_access_current_user", "c_ws_plugin__s2member_files_in::_file_remote_authorization"))
|
53 |
+
add_filter ("ws_plugin__s2member_check_file_download_access_current_user", "c_ws_plugin__s2member_files_in::_file_remote_authorization", 10, 2);
|
54 |
+
/**/
|
55 |
+
if (($file_download_access_is_allowed = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads ()) === false)
|
56 |
+
{
|
57 |
+
header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* File downloads are NOT yet configured? */
|
58 |
+
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`.");
|
59 |
+
}
|
60 |
+
/**/
|
61 |
+
else if (! ($current_user = apply_filters ("ws_plugin__s2member_check_file_download_access_current_user", ( (is_user_logged_in ()) ? wp_get_current_user () : false), get_defined_vars ()))/**/
|
62 |
+
&& 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")
|
63 |
+
exit ();
|
64 |
+
/**/
|
65 |
+
else if ((!is_array ($file_downloads = c_ws_plugin__s2member_files::user_downloads ($current_user)) || !$file_downloads["allowed"] || !$file_downloads["allowed_days"])/**/
|
66 |
+
&& 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")
|
67 |
+
exit ();
|
68 |
+
/**/
|
69 |
+
else if (preg_match ("/^access[_\-]s2member[_\-]level([0-4])\//", $_GET["s2member_file_download"], $m))
|
70 |
+
{
|
71 |
+
$level_req = $m[1]; /* Which Level does this require? */
|
72 |
+
if (!$current_user->has_cap ("access_s2member_level" . $level_req) /* Does the User have access to this Level? */
|
73 |
+
&& 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")
|
74 |
+
exit ();
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $_GET["s2member_file_download"], $m))
|
78 |
+
{
|
79 |
+
$ccap_req = preg_replace ("/-/", "_", $m[1]); /* Which Capability does this require? */
|
80 |
+
if (!$current_user->has_cap ("access_s2member_ccap_" . $ccap_req) /* Does the User have access to this Custom Capability? */
|
81 |
+
&& 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")
|
82 |
+
exit ();
|
83 |
+
}
|
84 |
+
/**/
|
85 |
+
$previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
|
86 |
+
$max_days_logged = c_ws_plugin__s2member_files::max_download_period (); /* The longest period in days. */
|
87 |
+
$file_download_access_log = (array)get_user_option ("s2member_file_download_access_log", $current_user->ID);
|
88 |
+
$file_download_access_arc = (array)get_user_option ("s2member_file_download_access_arc", $current_user->ID);
|
89 |
+
/**/
|
90 |
+
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
|
91 |
+
{
|
92 |
+
if (strtotime ($file_download_access_log_entry["date"]) < strtotime ("-" . $max_days_logged . " days"))
|
93 |
+
{
|
94 |
+
unset ($file_download_access_log[$file_download_access_log_entry_key]);
|
95 |
+
$file_download_access_arc[] = $file_download_access_log_entry;
|
96 |
+
}
|
97 |
+
else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
|
98 |
+
{
|
99 |
+
$previous_file_downloads++;
|
100 |
+
/* Here we check if this file has already been downloaded. */
|
101 |
+
if ($file_download_access_log_entry["file"] === $_GET["s2member_file_download"])
|
102 |
+
$already_downloaded = true;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
/**/
|
106 |
+
if (!$already_downloaded && $previous_file_downloads >= $file_downloads["allowed"] /* They have NOT already downloaded this file, and they're over their limit. */
|
107 |
+
&& 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")
|
108 |
+
exit ();
|
109 |
+
/**/
|
110 |
+
if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
|
111 |
+
$file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
|
112 |
+
/**/
|
113 |
+
update_user_option ($current_user->ID, "s2member_file_download_access_arc", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_arc));
|
114 |
+
update_user_option ($current_user->ID, "s2member_file_download_access_log", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_log));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
else /* Otherwise... it's either $excluded; or permission was granted with a valid Download Key. */
|
118 |
+
{
|
119 |
+
$_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/");
|
120 |
+
/**/
|
121 |
+
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
|
122 |
+
{
|
123 |
+
header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
|
124 |
+
exit ("404: Sorry, file not found. Please contact Support for assistance.");
|
125 |
+
}
|
126 |
+
}
|
127 |
+
/*
|
128 |
+
Here we are going to put together all of the file download information.
|
129 |
+
*/
|
130 |
+
$mimetypes = parse_ini_file (dirname (dirname (dirname (__FILE__))) . "/includes/mime-types.ini");
|
131 |
+
$pathinfo = pathinfo ($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]);
|
132 |
+
$extension = strtolower ($pathinfo["extension"]); /* Convert file extension to lowercase format for MIME type lookup. */
|
133 |
+
$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;
|
134 |
+
$mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream"; /* Lookup MIME type. */
|
135 |
+
$basename = $pathinfo["basename"]; /* The actual file name, including its extension. */
|
136 |
+
$length = filesize ($file); /* The overall file size, in bytes. */
|
137 |
+
/**/
|
138 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
139 |
+
do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
|
140 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
141 |
+
/*
|
142 |
+
Send the file to the browser in chunks ( in support of larger files ).
|
143 |
+
Be sure to turn off output compression, as it DOES get in the way.
|
144 |
+
*/
|
145 |
+
set_time_limit (0); /* Unlimited. */
|
146 |
+
@ini_set ("zlib.output_compression", 0);
|
147 |
+
/**/
|
148 |
+
header ("Accept-Ranges: none");
|
149 |
+
header ("Content-Encoding: none");
|
150 |
+
header ("Content-Type: " . $mimetype);
|
151 |
+
header ("Transfer-Encoding: chunked");
|
152 |
+
header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
|
153 |
+
header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
|
154 |
+
header ("Cache-Control: no-cache, must-revalidate, max-age=0");
|
155 |
+
header ("Cache-Control: post-check=0, pre-check=0", false);
|
156 |
+
header ("Pragma: no-cache");
|
157 |
+
/**/
|
158 |
+
header ('Content-Disposition: ' . (($inline) ? "inline" : "attachment") . '; filename="' . $basename . '"');
|
159 |
+
/**/
|
160 |
+
if ($length && apply_filters ("ws_plugin__s2member_stream_file_downloads", true, get_defined_vars ()) && ($stream = fopen ($file, "rb")))
|
161 |
+
{
|
162 |
+
@ob_end_clean (); /* End/clean output buffer. */
|
163 |
+
/**/
|
164 |
+
while (!feof ($stream) && ($chunk_size = strlen ($data = fread ($stream, 2097152))))
|
165 |
+
eval ('echo dechex ($chunk_size) . "\r\n". $data . "\r\n"; @flush ();');
|
166 |
+
/**/
|
167 |
+
fclose($stream);
|
168 |
+
/**/
|
169 |
+
exit ("0\r\n\r\n");
|
170 |
+
}
|
171 |
+
else if ($length)
|
172 |
+
exit (file_get_contents ($file));
|
173 |
+
else
|
174 |
+
exit (); /* Empty file. */
|
175 |
+
}
|
176 |
+
/**/
|
177 |
+
do_action ("ws_plugin__s2member_after_file_download_access", get_defined_vars ());
|
178 |
+
}
|
179 |
+
/*
|
180 |
+
A sort of callback function that handles header authorization for File Downloads.
|
181 |
+
Attach to: add_filter("ws_plugin__s2member_check_file_download_access_current_user");
|
182 |
+
*/
|
183 |
+
public static function _file_remote_authorization ($current_user = FALSE)
|
184 |
+
{
|
185 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
186 |
+
do_action ("_ws_plugin__s2member_before_file_remote_authorization", get_defined_vars ());
|
187 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
188 |
+
/**/
|
189 |
+
if (!$current_user && $_GET["s2member_file_remote"]) /* Use remote header authorization? */
|
190 |
+
{
|
191 |
+
do_action ("_ws_plugin__s2member_during_file_remote_authorization_before", get_defined_vars ());
|
192 |
+
/**/
|
193 |
+
if (!$_SERVER["PHP_AUTH_USER"] || !user_pass_ok ($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
|
194 |
+
{
|
195 |
+
header ('WWW-Authenticate: Basic realm="Members Only"');
|
196 |
+
header ("HTTP/1.0 401 Unauthorized");
|
197 |
+
exit ("Access Denied");
|
198 |
+
}
|
199 |
+
else /* If authenticated, we can now assign $current_user. */
|
200 |
+
{
|
201 |
+
$current_user = new WP_User ($_SERVER["PHP_AUTH_USER"]);
|
202 |
+
}
|
203 |
+
/**/
|
204 |
+
do_action ("_ws_plugin__s2member_during_file_remote_authorization_after", get_defined_vars ());
|
205 |
+
}
|
206 |
+
/**/
|
207 |
+
return apply_filters ("_ws_plugin__s2member_file_remote_authorization", $current_user, get_defined_vars ());
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
?>
|
includes/classes/files.inc.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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 |
+
Function creates a special File Download Key.
|
34 |
+
Uses: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file.
|
35 |
+
|
36 |
+
The optional second argument can be passed in for compatiblity with Quick Cache / WP Super Cache.
|
37 |
+
When $cache_compatible is passed in, the salt is reduced to only the $file value.
|
38 |
+
- which is NOT as secure. So use that with caution.
|
39 |
+
*/
|
40 |
+
public static function file_download_key ($file = FALSE, $universal = FALSE)
|
41 |
+
{
|
42 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
43 |
+
do_action ("ws_plugin__s2member_before_file_download_key", get_defined_vars ());
|
44 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
45 |
+
/**/
|
46 |
+
$salt = ($universal) ? $file /* ( cache compatible / universally available ) */
|
47 |
+
: date ("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file;
|
48 |
+
/**/
|
49 |
+
$key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt ($salt));
|
50 |
+
/**/
|
51 |
+
if (!$universal) /* Disallow caching. */
|
52 |
+
c_ws_plugin__s2member_nocache::nocache_constants (true);
|
53 |
+
/**/
|
54 |
+
return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
|
55 |
+
}
|
56 |
+
/*
|
57 |
+
Function determines the max period in days for download access.
|
58 |
+
Returns number of days, where 0 means no access to files has been allowed.
|
59 |
+
*/
|
60 |
+
public static function max_download_period ()
|
61 |
+
{
|
62 |
+
do_action ("ws_plugin__s2member_before_max_download_period", get_defined_vars ());
|
63 |
+
/**/
|
64 |
+
if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
|
65 |
+
$max = ($max < $days) ? $days : $max;
|
66 |
+
/**/
|
67 |
+
if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
|
68 |
+
$max = ($max < $days) ? $days : $max;
|
69 |
+
/**/
|
70 |
+
if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
|
71 |
+
$max = ($max < $days) ? $days : $max;
|
72 |
+
/**/
|
73 |
+
if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
|
74 |
+
$max = ($max < $days) ? $days : $max;
|
75 |
+
/**/
|
76 |
+
return apply_filters ("ws_plugin__s2member_max_download_period", ( ($max > 365) ? 365 : (int)$max), get_defined_vars ());
|
77 |
+
}
|
78 |
+
/*
|
79 |
+
Function determines the minimum level required for file download access.
|
80 |
+
Test === false to see if no access is allowed.
|
81 |
+
This returns false, or (int)[0-1].
|
82 |
+
*/
|
83 |
+
public static function min_level_4_downloads ()
|
84 |
+
{
|
85 |
+
do_action ("ws_plugin__s2member_before_min_level_4_downloads", get_defined_vars ());
|
86 |
+
/**/
|
87 |
+
$file_download_access_is_allowed = $min_level_4_downloads = false; /* Test with === false, which means no access is allowed at all. */
|
88 |
+
/**/
|
89 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"])
|
90 |
+
$file_download_access_is_allowed = $min_level_4_downloads = 0;
|
91 |
+
/**/
|
92 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
|
93 |
+
$file_download_access_is_allowed = $min_level_4_downloads = 1;
|
94 |
+
/**/
|
95 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
|
96 |
+
$file_download_access_is_allowed = $min_level_4_downloads = 2;
|
97 |
+
/**/
|
98 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
|
99 |
+
$file_download_access_is_allowed = $min_level_4_downloads = 3;
|
100 |
+
/**/
|
101 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
|
102 |
+
$file_download_access_is_allowed = $min_level_4_downloads = 4;
|
103 |
+
/**/
|
104 |
+
return apply_filters ("ws_plugin__s2member_min_level_4_downloads", ($file_download_access_is_allowed = $min_level_4_downloads), get_defined_vars ());
|
105 |
+
}
|
106 |
+
/*
|
107 |
+
Function determines how many downloads allowed - etc, etc.
|
108 |
+
Returns an array with 3 elements: allowed, allowed_days, currently.
|
109 |
+
The 2nd parameter can be used to prevent another database connection.
|
110 |
+
*/
|
111 |
+
public static function user_downloads ($current_user = FALSE, $not_counting_this_particular_file = FALSE, $log = NULL)
|
112 |
+
{
|
113 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
114 |
+
do_action ("ws_plugin__s2member_before_user_downloads", get_defined_vars ());
|
115 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
116 |
+
/**/
|
117 |
+
if ($current_user || ($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
|
118 |
+
{
|
119 |
+
if ($current_user->has_cap ("access_s2member_level0") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"])
|
120 |
+
{
|
121 |
+
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"];
|
122 |
+
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"];
|
123 |
+
}
|
124 |
+
/**/
|
125 |
+
if ($current_user->has_cap ("access_s2member_level1") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"])
|
126 |
+
{
|
127 |
+
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"];
|
128 |
+
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"];
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
if ($current_user->has_cap ("access_s2member_level2") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"])
|
132 |
+
{
|
133 |
+
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"];
|
134 |
+
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"];
|
135 |
+
}
|
136 |
+
/**/
|
137 |
+
if ($current_user->has_cap ("access_s2member_level3") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"])
|
138 |
+
{
|
139 |
+
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"];
|
140 |
+
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"];
|
141 |
+
}
|
142 |
+
/**/
|
143 |
+
if ($current_user->has_cap ("access_s2member_level4") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"])
|
144 |
+
{
|
145 |
+
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"];
|
146 |
+
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"];
|
147 |
+
}
|
148 |
+
/**/
|
149 |
+
$file_download_access_log = (isset ($log)) ? (array)$log : (array)get_user_option ("s2member_file_download_access_log", $current_user->ID);
|
150 |
+
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
|
151 |
+
if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . (int)$allowed_days . " days"))
|
152 |
+
if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
|
153 |
+
$currently = ($currently) ? $currently + 1 : 1;
|
154 |
+
}
|
155 |
+
/**/
|
156 |
+
return apply_filters ("ws_plugin__s2member_user_downloads", array ("allowed" => (int)$allowed, "allowed_days" => (int)$allowed_days, "currently" => (int)$currently), get_defined_vars ());
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
?>
|
{images/promos → includes/classes}/index.php
RENAMED
File without changes
|
includes/classes/installation.inc.php
ADDED
@@ -0,0 +1,328 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function for handling activation routines.
|
23 |
+
This function should match the array key for this plugin:
|
24 |
+
ws_plugin__$plugin_key_activate() is called by our themes.
|
25 |
+
|
26 |
+
We also initialize some option values here.
|
27 |
+
Initializing these options will force them to be
|
28 |
+
autoloaded into WordPress® instead of generating
|
29 |
+
extra queries before they are set.
|
30 |
+
*/
|
31 |
+
public static function activate ()
|
32 |
+
{
|
33 |
+
global $wpdb; /* To update points of origin on a Multisite Network. */
|
34 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
35 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
add_role ("subscriber", "Subscriber");
|
39 |
+
add_role ("s2member_level1", "s2Member Level 1");
|
40 |
+
add_role ("s2member_level2", "s2Member Level 2");
|
41 |
+
add_role ("s2member_level3", "s2Member Level 3");
|
42 |
+
add_role ("s2member_level4", "s2Member Level 4");
|
43 |
+
/**/
|
44 |
+
if ($role = &get_role ("subscriber"))
|
45 |
+
{
|
46 |
+
$role->add_cap ("read");
|
47 |
+
$role->add_cap ("access_s2member_level0");
|
48 |
+
}
|
49 |
+
/**/
|
50 |
+
if ($role = &get_role ("s2member_level1"))
|
51 |
+
{
|
52 |
+
$role->add_cap ("read");
|
53 |
+
$role->add_cap ("level_0");
|
54 |
+
$role->add_cap ("access_s2member_level0");
|
55 |
+
$role->add_cap ("access_s2member_level1");
|
56 |
+
}
|
57 |
+
/**/
|
58 |
+
if ($role = &get_role ("s2member_level2"))
|
59 |
+
{
|
60 |
+
$role->add_cap ("read");
|
61 |
+
$role->add_cap ("level_0");
|
62 |
+
$role->add_cap ("access_s2member_level0");
|
63 |
+
$role->add_cap ("access_s2member_level1");
|
64 |
+
$role->add_cap ("access_s2member_level2");
|
65 |
+
}
|
66 |
+
/**/
|
67 |
+
if ($role = &get_role ("s2member_level3"))
|
68 |
+
{
|
69 |
+
$role->add_cap ("read");
|
70 |
+
$role->add_cap ("level_0");
|
71 |
+
$role->add_cap ("access_s2member_level0");
|
72 |
+
$role->add_cap ("access_s2member_level1");
|
73 |
+
$role->add_cap ("access_s2member_level2");
|
74 |
+
$role->add_cap ("access_s2member_level3");
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
if ($role = &get_role ("s2member_level4"))
|
78 |
+
{
|
79 |
+
$role->add_cap ("read");
|
80 |
+
$role->add_cap ("level_0");
|
81 |
+
$role->add_cap ("access_s2member_level0");
|
82 |
+
$role->add_cap ("access_s2member_level1");
|
83 |
+
$role->add_cap ("access_s2member_level2");
|
84 |
+
$role->add_cap ("access_s2member_level3");
|
85 |
+
$role->add_cap ("access_s2member_level4");
|
86 |
+
}
|
87 |
+
/**/
|
88 |
+
if ($role = &get_role ("administrator"))
|
89 |
+
{
|
90 |
+
$role->add_cap ("access_s2member_level0");
|
91 |
+
$role->add_cap ("access_s2member_level1");
|
92 |
+
$role->add_cap ("access_s2member_level2");
|
93 |
+
$role->add_cap ("access_s2member_level3");
|
94 |
+
$role->add_cap ("access_s2member_level4");
|
95 |
+
}
|
96 |
+
/**/
|
97 |
+
if ($role = &get_role ("editor"))
|
98 |
+
{
|
99 |
+
$role->add_cap ("access_s2member_level0");
|
100 |
+
$role->add_cap ("access_s2member_level1");
|
101 |
+
$role->add_cap ("access_s2member_level2");
|
102 |
+
$role->add_cap ("access_s2member_level3");
|
103 |
+
$role->add_cap ("access_s2member_level4");
|
104 |
+
}
|
105 |
+
/**/
|
106 |
+
if ($role = &get_role ("author"))
|
107 |
+
{
|
108 |
+
$role->add_cap ("access_s2member_level0");
|
109 |
+
$role->add_cap ("access_s2member_level1");
|
110 |
+
$role->add_cap ("access_s2member_level2");
|
111 |
+
$role->add_cap ("access_s2member_level3");
|
112 |
+
$role->add_cap ("access_s2member_level4");
|
113 |
+
}
|
114 |
+
/**/
|
115 |
+
if ($role = &get_role ("contributor"))
|
116 |
+
{
|
117 |
+
$role->add_cap ("access_s2member_level0");
|
118 |
+
$role->add_cap ("access_s2member_level1");
|
119 |
+
$role->add_cap ("access_s2member_level2");
|
120 |
+
$role->add_cap ("access_s2member_level3");
|
121 |
+
$role->add_cap ("access_s2member_level4");
|
122 |
+
}
|
123 |
+
/**/
|
124 |
+
if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
125 |
+
if (is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
|
126 |
+
mkdir ($files_dir, 0777, true);
|
127 |
+
/**/
|
128 |
+
if (is_dir ($files_dir) && is_writable ($files_dir))
|
129 |
+
if (!file_exists ($htaccess = $files_dir . "/.htaccess"))
|
130 |
+
file_put_contents ($htaccess, "deny from all");
|
131 |
+
/**/
|
132 |
+
if (!is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
133 |
+
if (is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir))))
|
134 |
+
mkdir ($logs_dir, 0777, true);
|
135 |
+
/**/
|
136 |
+
if (is_dir ($logs_dir) && is_writable ($logs_dir))
|
137 |
+
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
|
138 |
+
file_put_contents ($htaccess, "deny from all");
|
139 |
+
/**/
|
140 |
+
(!is_array (get_option ("ws_plugin__s2member_cache"))) ? update_option ("ws_plugin__s2member_cache", array ()) : null;
|
141 |
+
(!is_array (get_option ("ws_plugin__s2member_notices"))) ? update_option ("ws_plugin__s2member_notices", array ()) : null;
|
142 |
+
(!is_array (get_option ("ws_plugin__s2member_options"))) ? update_option ("ws_plugin__s2member_options", array ()) : null;
|
143 |
+
(!is_numeric (get_option ("ws_plugin__s2member_configured"))) ? update_option ("ws_plugin__s2member_configured", "0") : null;
|
144 |
+
/**/
|
145 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) /* If already configured, we are re-activating. */
|
146 |
+
{
|
147 |
+
$v = get_option ("ws_plugin__s2member_activated_version");
|
148 |
+
/**/
|
149 |
+
if (!$v || !version_compare ($v, "3.2", ">=")) /* Needs to be upgraded? */
|
150 |
+
/* Version 3.2 is where `meta_key` names were changed. They're prefixed now. */
|
151 |
+
{
|
152 |
+
$like = "`meta_key` LIKE 's2member\_%' AND `meta_key` NOT LIKE '%s2member\_originating\_blog%'";
|
153 |
+
$wpdb->query ("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
|
154 |
+
}
|
155 |
+
/**/
|
156 |
+
if (!$v || !version_compare ($v, "3.2.5", ">=")) /* Needs to be upgraded? */
|
157 |
+
/* Version 3.2.5 is where transient names were changed. They're prefixed now. */
|
158 |
+
{
|
159 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_%'");
|
160 |
+
}
|
161 |
+
/**/
|
162 |
+
if (!$v || !version_compare ($v, "3.2.6", ">=")) /* Needs to be upgraded? */
|
163 |
+
/* Version 3.2.6 fixed `s2member_ccaps_req` being stored empty and/or w/ one empty element in the array. */
|
164 |
+
{
|
165 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
|
166 |
+
}
|
167 |
+
/**/
|
168 |
+
if (!$v || !version_compare ($v, "3.5", ">=")) /* Needs to be notified about Screen Options? */
|
169 |
+
/* Version 3.5 introduced a dismissal message regarding Screen Options in the list of Users/Members. */
|
170 |
+
{
|
171 |
+
$notice = '<strong>Note:</strong> s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the <strong>Screen Options</strong> tab <em>( upper right-hand corner )</em>. With WordPress® Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
|
172 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:users.php", false, false, true); /* Visible until dismissed. */
|
173 |
+
}
|
174 |
+
/**/
|
175 |
+
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
|
176 |
+
$notice .= 'You now have version ' . esc_html (WS_PLUGIN__S2MEMBER_VERSION) . '. Your existing configuration remains.';
|
177 |
+
/**/
|
178 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) /* No Changelog on a Multisite Farm. */
|
179 |
+
$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! :-)';
|
180 |
+
/**/
|
181 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
|
182 |
+
/**/
|
183 |
+
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)
|
184 |
+
{
|
185 |
+
$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>.';
|
186 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"), true);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
else /* Otherwise, (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide. */
|
190 |
+
{
|
191 |
+
$notice = '<strong>Note:</strong> s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the <strong>Screen Options</strong> tab <em>( upper right-hand corner )</em>. With WordPress® Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
|
192 |
+
/**/
|
193 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:users.php", false, false, true); /* Remain visible until dismissed by the site owner. */
|
194 |
+
/**/
|
195 |
+
$notice = '<strong>s2Member</strong> v' . esc_html (WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
|
196 |
+
$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! :-)';
|
197 |
+
/**/
|
198 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
|
199 |
+
}
|
200 |
+
/**/
|
201 |
+
update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION); /* Mark version. */
|
202 |
+
/**/
|
203 |
+
if (is_multisite () && is_main_site ()) /* Network activation routines. A few quick adjustments. */
|
204 |
+
{
|
205 |
+
foreach ((array) ($users = $wpdb->get_results ("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user)
|
206 |
+
{
|
207 |
+
/* Here we convert everyone already in the system; without a point of origin.
|
208 |
+
This will set their point of origin to the Main Site ( Dashboard Blog ). */
|
209 |
+
if (! ($originating_blog = get_user_meta ($user->ID, "s2member_originating_blog", true)))
|
210 |
+
update_user_meta ($user->ID, "s2member_originating_blog", $current_site->blog_id);
|
211 |
+
}
|
212 |
+
/**/
|
213 |
+
$notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . esc_html (WS_PLUGIN__S2MEMBER_VERSION) . '.<br />';
|
214 |
+
$notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
|
215 |
+
$notice .= 'In the Dashboard for your Main Site, see:<br />';
|
216 |
+
$notice .= '<code>s2Member -> Multisite ( Config )</code>.';
|
217 |
+
/**/
|
218 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
|
219 |
+
/**/
|
220 |
+
update_option ("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
|
221 |
+
}
|
222 |
+
/**/
|
223 |
+
do_action ("ws_plugin__s2member_after_activation", get_defined_vars ());
|
224 |
+
/**/
|
225 |
+
return; /* Return for uniformity. */
|
226 |
+
}
|
227 |
+
/*
|
228 |
+
Function for handling de-activation cleanup routines.
|
229 |
+
This function should match the array key for this plugin:
|
230 |
+
ws_plugin__$plugin_key_deactivate() is called by our themes.
|
231 |
+
*/
|
232 |
+
public static function deactivate ()
|
233 |
+
{
|
234 |
+
global $wpdb; /* May need this for database cleaning. */
|
235 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
236 |
+
/**/
|
237 |
+
do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
|
238 |
+
/**/
|
239 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
|
240 |
+
{
|
241 |
+
remove_role ("s2member_level1");
|
242 |
+
remove_role ("s2member_level2");
|
243 |
+
remove_role ("s2member_level3");
|
244 |
+
remove_role ("s2member_level4");
|
245 |
+
/**/
|
246 |
+
if ($role = &get_role ("subscriber"))
|
247 |
+
{
|
248 |
+
$role->remove_cap ("access_s2member_level0");
|
249 |
+
}
|
250 |
+
/**/
|
251 |
+
if ($role = &get_role ("administrator"))
|
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 ("editor"))
|
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 ("author"))
|
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 ($role = &get_role ("contributor"))
|
279 |
+
{
|
280 |
+
$role->remove_cap ("access_s2member_level0");
|
281 |
+
$role->remove_cap ("access_s2member_level1");
|
282 |
+
$role->remove_cap ("access_s2member_level2");
|
283 |
+
$role->remove_cap ("access_s2member_level3");
|
284 |
+
$role->remove_cap ("access_s2member_level4");
|
285 |
+
}
|
286 |
+
/**/
|
287 |
+
if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
288 |
+
{
|
289 |
+
if (file_exists ($htaccess = $files_dir . "/.htaccess"))
|
290 |
+
if (is_writable ($htaccess))
|
291 |
+
unlink($htaccess);
|
292 |
+
/**/
|
293 |
+
@rmdir($files_dir) . @rmdir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir));
|
294 |
+
}
|
295 |
+
/**/
|
296 |
+
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
297 |
+
{
|
298 |
+
foreach (scandir ($logs_dir) as $log_file)
|
299 |
+
if (is_file ($log_file = $logs_dir . "/" . $log_file))
|
300 |
+
if (is_writable ($log_file))
|
301 |
+
unlink($log_file);
|
302 |
+
/**/
|
303 |
+
@rmdir($logs_dir) . @rmdir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir));
|
304 |
+
}
|
305 |
+
/**/
|
306 |
+
delete_option ("ws_plugin__s2member_cache");
|
307 |
+
delete_option ("ws_plugin__s2member_notices");
|
308 |
+
delete_option ("ws_plugin__s2member_options");
|
309 |
+
delete_option ("ws_plugin__s2member_configured");
|
310 |
+
delete_option ("ws_plugin__s2member_activated_version");
|
311 |
+
delete_option ("ws_plugin__s2member_activated_mms_version");
|
312 |
+
/**/
|
313 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%s2member\_%'");
|
314 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_s2m\_%'");
|
315 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_timeout\_s2m\_%'");
|
316 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` LIKE '%s2member\_%'");
|
317 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key` LIKE '%s2member\_%'");
|
318 |
+
/**/
|
319 |
+
do_action ("ws_plugin__s2member_during_deactivation", get_defined_vars ());
|
320 |
+
}
|
321 |
+
/**/
|
322 |
+
do_action ("ws_plugin__s2member_after_deactivation", get_defined_vars ());
|
323 |
+
/**/
|
324 |
+
return; /* Return for uniformity. */
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
?>
|
includes/classes/ip-restrictions.inc.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
99 |
+
do_action ("ws_plugin__s2member_before_specific_ip_restriction_breached_security", get_defined_vars ());
|
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 |
+
{
|
111 |
+
global $wpdb; /* Need global database object. */
|
112 |
+
/**/
|
113 |
+
do_action ("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions", get_defined_vars ());
|
114 |
+
/**/
|
115 |
+
$prefix = "s2m_ipr_"; /* s2Member Transient prefix for all IP Restrictions. */
|
116 |
+
$transient_entries = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_entries");
|
117 |
+
$transient_security_breach = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_security_breach");
|
118 |
+
/**/
|
119 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` = '" . esc_sql ($transient_entries) . "'");
|
120 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` = '" . esc_sql ($transient_security_breach) . "'");
|
121 |
+
/**/
|
122 |
+
do_action ("ws_plugin__s2member_after_delete_reset_specific_ip_restrictions", get_defined_vars ());
|
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 |
+
{
|
147 |
+
global $wpdb; /* Need global database object. */
|
148 |
+
/**/
|
149 |
+
do_action ("ws_plugin__s2member_before_delete_reset_all_ip_restrictions", get_defined_vars ());
|
150 |
+
/**/
|
151 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_s2m\_ipr\_%'");
|
152 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_timeout\_s2m\_ipr\_%'");
|
153 |
+
/**/
|
154 |
+
do_action ("ws_plugin__s2member_after_delete_reset_all_ip_restrictions", get_defined_vars ());
|
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 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
?>
|
includes/classes/labels.inc.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_config_label_translations", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["apply_label_translations"])
|
30 |
+
add_filter ("gettext_with_context", "c_ws_plugin__s2member_labels::_label_translations", 10, 3);
|
31 |
+
/**/
|
32 |
+
do_action ("ws_plugin__s2member_after_config_label_translations", get_defined_vars ());
|
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 |
+
{
|
42 |
+
if ($text && $context && preg_match ("/^User role$/i", $context) && ($role = $text))
|
43 |
+
{
|
44 |
+
if (preg_match ("/^(Free )?Subscriber$/i", $role) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"])
|
45 |
+
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"];
|
46 |
+
/**/
|
47 |
+
else if (preg_match ("/^s2Member Level ([0-9]+)$/i", $role, $m) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"])
|
48 |
+
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"];
|
49 |
+
/**/
|
50 |
+
$translation = apply_filters ("_ws_plugin__s2member_label_translations", $translation, get_defined_vars ());
|
51 |
+
}
|
52 |
+
/**/
|
53 |
+
return $translation; /* Return translation. */
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
?>
|
includes/classes/list-servers.inc.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function that determines whether or not any list
|
23 |
+
servers have been integrated into the s2Member options.
|
24 |
+
*/
|
25 |
+
public static function list_servers_integrated ()
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
for ($i = 0; $i <= 4; $i++)
|
30 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_mailchimp_list_ids"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_aweber_list_ids"])
|
31 |
+
return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
|
32 |
+
/**/
|
33 |
+
return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
|
34 |
+
}
|
35 |
+
/*
|
36 |
+
Function that processes List Server integrations for s2Member.
|
37 |
+
*/
|
38 |
+
public static function process_list_servers ($role = FALSE, $level = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE, $user_id = FALSE)
|
39 |
+
{
|
40 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
41 |
+
/**/
|
42 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
43 |
+
do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
|
44 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
45 |
+
/**/
|
46 |
+
if (strlen ($level) && is_email ($email) && $opt_in) /* Must have these. */
|
47 |
+
{
|
48 |
+
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (0);
|
49 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release Filters. */
|
50 |
+
/**/
|
51 |
+
if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
|
52 |
+
if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
53 |
+
{
|
54 |
+
if (!class_exists ("NC_MCAPI"))
|
55 |
+
include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
|
56 |
+
/**/
|
57 |
+
$MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
|
58 |
+
/**/
|
59 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
|
60 |
+
$MCAPI->listSubscribe ($mailchimp_list_id, $email, apply_filters ("ws_plugin__s2member_mailchimp_array", array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => $ip), get_defined_vars ()));
|
61 |
+
}
|
62 |
+
/**/
|
63 |
+
if (($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
64 |
+
{
|
65 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
|
66 |
+
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 . "\nRole: " . $role . "\nLevel: " . $level . "\n - end.", get_defined_vars ()), "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
|
67 |
+
}
|
68 |
+
/**/
|
69 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
70 |
+
do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
|
71 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
72 |
+
/**/
|
73 |
+
if ($email_configs_were_on) /* Back on? */
|
74 |
+
c_ws_plugin__s2member_email_configs::email_config ();
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
78 |
+
do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
|
79 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
80 |
+
/**/
|
81 |
+
return; /* Return for uniformity. */
|
82 |
+
}
|
83 |
+
/*
|
84 |
+
Function that processes list server removals for s2Member.
|
85 |
+
*/
|
86 |
+
public static function process_list_server_removals ($role = FALSE, $level = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE)
|
87 |
+
{
|
88 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
89 |
+
/**/
|
90 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
91 |
+
do_action ("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars ());
|
92 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
93 |
+
/**/
|
94 |
+
if (strlen ($level) && is_email ($email) && $opt_out) /* Must have these. */
|
95 |
+
{
|
96 |
+
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (0);
|
97 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release Filters. */
|
98 |
+
/**/
|
99 |
+
if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
|
100 |
+
if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
101 |
+
{
|
102 |
+
if (!class_exists ("NC_MCAPI"))
|
103 |
+
include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
|
104 |
+
/**/
|
105 |
+
$MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
|
106 |
+
/**/
|
107 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
|
108 |
+
$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 ()));
|
109 |
+
}
|
110 |
+
/**/
|
111 |
+
if (($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
112 |
+
{
|
113 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
|
114 |
+
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");
|
115 |
+
}
|
116 |
+
/**/
|
117 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
118 |
+
do_action ("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars ());
|
119 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
120 |
+
/**/
|
121 |
+
if ($email_configs_were_on) /* Back on? */
|
122 |
+
c_ws_plugin__s2member_email_configs::email_config ();
|
123 |
+
}
|
124 |
+
/**/
|
125 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
126 |
+
do_action ("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars ());
|
127 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
128 |
+
/**/
|
129 |
+
return; /* Return for uniformity. */
|
130 |
+
}
|
131 |
+
/*
|
132 |
+
This function listens to Collective EOT/MOD Events processed internally by s2Member.
|
133 |
+
This is only applicable when ["custom_reg_auto_opt_outs"] contains related Event(s).
|
134 |
+
Attach to: add_action("ws_plugin__s2member_during_collective_eots");
|
135 |
+
Attach to: add_action("ws_plugin__s2member_during_collective_mods");
|
136 |
+
*/
|
137 |
+
public static function auto_process_list_server_removals ($user_id = FALSE, $vars = FALSE, $event = FALSE, $new_level = FALSE)
|
138 |
+
{
|
139 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
140 |
+
static $auto_processed = array (); /* Only process ONE time for each User ID. */
|
141 |
+
/**/
|
142 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
143 |
+
do_action ("ws_plugin__s2member_before_auto_process_list_server_removals", get_defined_vars ());
|
144 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
145 |
+
/**/
|
146 |
+
if ($user_id && !in_array ($user_id, $auto_processed) && in_array ($event, $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)
|
147 |
+
{
|
148 |
+
if ((!strlen ($new_level) || (int)$new_level !== c_ws_plugin__s2member_user_access::user_access_level ($user)) && ($auto_processed[$user_id] = true))
|
149 |
+
{
|
150 |
+
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_email, $user->first_name, $user->last_name, false, true, $user_id);
|
151 |
+
/**/
|
152 |
+
if (strlen ($new_level) && apply_filters ("ws_plugin__s2member_auto_process_new_list_servers", true, get_defined_vars ())) /* Subscribe to new List(s)? */
|
153 |
+
c_ws_plugin__s2member_list_servers::process_list_servers ("s2member_level" . $new_level, $new_level, $user->user_email, $user->first_name, $user->last_name, false, true, $user_id);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
/**/
|
157 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
158 |
+
do_action ("ws_plugin__s2member_after_auto_process_list_server_removals", get_defined_vars ());
|
159 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
160 |
+
/**/
|
161 |
+
return; /* Return for uniformity. */
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
?>
|
includes/classes/login-customizations.inc.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function filters the Login/Registration Logo Url.
|
23 |
+
Attach to: add_filter("login_headerurl");
|
24 |
+
*/
|
25 |
+
public static function login_header_url ($url = FALSE)
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_login_header_url", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
$url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_url"];
|
30 |
+
/**/
|
31 |
+
return apply_filters ("ws_plugin__s2member_login_header_url", $url, get_defined_vars ());
|
32 |
+
}
|
33 |
+
/*
|
34 |
+
Function filters the Login/Registration Logo Title.
|
35 |
+
Attach to: add_filter("login_headertitle");
|
36 |
+
*/
|
37 |
+
public static function login_header_title ($title = FALSE)
|
38 |
+
{
|
39 |
+
do_action ("ws_plugin__s2member_before_login_header_title", get_defined_vars ());
|
40 |
+
/**/
|
41 |
+
$title = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_title"];
|
42 |
+
/**/
|
43 |
+
return apply_filters ("ws_plugin__s2member_login_header_title", $title, get_defined_vars ());
|
44 |
+
}
|
45 |
+
/*
|
46 |
+
Function 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 |
+
$s .= "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>' . "\n";
|
61 |
+
$s .= '<script type="text/javascript" src="' . esc_attr (site_url ("/?ws_plugin__s2member_js_w_globals=1&no-cache=" . urlencode (md5 (mt_rand ())))) . '"></script>' . "\n";
|
62 |
+
/**/
|
63 |
+
$s .= "\n" . '<style type="text/css">' . "\n";
|
64 |
+
/**/
|
65 |
+
$s .= 'html, body { border: 0' . $i . '; background: none' . $i . '; }' . "\n"; /* Clear existing. */
|
66 |
+
$s .= 'html { background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . $i . '; }' . "\n";
|
67 |
+
$s .= 'html { background-image: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ')' . $i . '; }' . "\n";
|
68 |
+
$s .= 'html { background-repeat: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] . $i . '; }' . "\n";
|
69 |
+
/**/
|
70 |
+
$s .= 'body, body * { font-size: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_size"] . $i . '; }' . "\n";
|
71 |
+
$s .= 'body, body * { font-family: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_family"] . $i . '; }' . "\n";
|
72 |
+
/**/
|
73 |
+
$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";
|
74 |
+
/**/
|
75 |
+
$s .= 'div#login { width: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"] . 'px' . $i . '; }' . "\n";
|
76 |
+
$s .= 'div#login h1 a { background: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"] . ') no-repeat top center' . $i . '; }' . "\n";
|
77 |
+
$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";
|
78 |
+
/**/
|
79 |
+
$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";
|
80 |
+
/**/
|
81 |
+
$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";
|
82 |
+
/**/
|
83 |
+
$s .= 'div#login form p { margin: 2px 0 16px 0' . $i . '; }' . "\n"; /* Handle margins. */
|
84 |
+
$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";
|
85 |
+
$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";
|
86 |
+
$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";
|
87 |
+
$s .= 'div#login form label.ws-plugin--s2member-custom-reg-field-op-l { vertical-align:middle' . $i . '; font-size:90%' . $i . '; }' . "\n";
|
88 |
+
$s .= 'div#login form select.ws-plugin--s2member-custom-reg-field { width:100%' . $i . '; }' . "\n";
|
89 |
+
/**/
|
90 |
+
$s .= 'div#login form p.submit { margin-bottom: 0' . $i . '; }' . "\n";
|
91 |
+
$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";
|
92 |
+
$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";
|
93 |
+
$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";
|
94 |
+
$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";
|
95 |
+
/**/
|
96 |
+
$s .= 'div#login form#registerform p#reg_passmail { font-style: italic' . $i . '; }' . "\n";
|
97 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
98 |
+
$s .= 'p#reg_passmail { display: none' . $i . '; }' . "\n";
|
99 |
+
/**/
|
100 |
+
$s .= '</style>' . "\n\n";
|
101 |
+
/**/
|
102 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
103 |
+
do_action ("ws_plugin__s2member_during_login_header_styles", get_defined_vars ());
|
104 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
105 |
+
/**/
|
106 |
+
echo apply_filters ("ws_plugin__s2member_login_header_styles", $s, get_defined_vars ());
|
107 |
+
/**/
|
108 |
+
do_action ("ws_plugin__s2member_after_login_header_styles", get_defined_vars ());
|
109 |
+
/**/
|
110 |
+
return; /* Return for uniformity. */
|
111 |
+
}
|
112 |
+
/*
|
113 |
+
Function displays Login Footer Design.
|
114 |
+
Attach to: add_action("login_footer");
|
115 |
+
*/
|
116 |
+
public static function login_footer_design ()
|
117 |
+
{
|
118 |
+
do_action ("ws_plugin__s2member_before_login_footer_design", get_defined_vars ());
|
119 |
+
/**/
|
120 |
+
if (($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_footer_design"]))
|
121 |
+
/**/
|
122 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
|
123 |
+
{
|
124 |
+
echo $code . "\n"; /* No PHP here. */
|
125 |
+
}
|
126 |
+
else /* Otherwise, safe to allow PHP code. */
|
127 |
+
{
|
128 |
+
eval ("?>" . $code);
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
do_action ("ws_plugin__s2member_after_login_footer_design", get_defined_vars ());
|
132 |
+
/**/
|
133 |
+
return; /* Return for uniformity. */
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
?>
|
includes/classes/login-redirects.inc.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
This function 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 |
+
remove_all_filters ("login_redirect"); /* Removes ALL `login_redirect` Filters. */
|
30 |
+
/**/
|
31 |
+
do_action ("ws_plugin__s2member_after_remove_login_redirect_filters", get_defined_vars ());
|
32 |
+
}
|
33 |
+
/*
|
34 |
+
Function for handling login redirections.
|
35 |
+
Attach to: add_action("wp_login");
|
36 |
+
*/
|
37 |
+
public static function login_redirect ($username = FALSE)
|
38 |
+
{
|
39 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
40 |
+
do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
|
41 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
42 |
+
/**/
|
43 |
+
$username = (!$username && is_object ($current_user = wp_get_current_user ())) ? $current_user->user_login : $username;
|
44 |
+
/**/
|
45 |
+
if ($username && 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 ())))
|
46 |
+
{
|
47 |
+
if ($user->has_cap ("edit_posts") || strtolower ($username) === "demo" || c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
|
48 |
+
{
|
49 |
+
if (!$_REQUEST["redirect_to"] || $_REQUEST["redirect_to"] === "wp-admin/" || $_REQUEST["redirect_to"] === admin_url ()) /* ?redirect_to=[value]. */
|
50 |
+
{
|
51 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) /* Using custom Passwords? */
|
52 |
+
{
|
53 |
+
delete_user_setting ("default_password_nag"); /* setcookie(). */
|
54 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
55 |
+
}
|
56 |
+
/**/
|
57 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
58 |
+
do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
|
59 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
60 |
+
/**/
|
61 |
+
if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
|
62 |
+
wp_redirect($special_redirection_url); /* Special Redirection. */
|
63 |
+
/**/
|
64 |
+
else /* Else we use the Login Welcome Page configured for s2Member. */
|
65 |
+
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
66 |
+
/**/
|
67 |
+
exit (); /* Clean exit. */
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
/**/
|
72 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
73 |
+
do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
|
74 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
75 |
+
/**/
|
76 |
+
return; /* Return for uniformity. */
|
77 |
+
}
|
78 |
+
/*
|
79 |
+
This function formulates a possible ( Special ) Login Redirection URL.
|
80 |
+
*/
|
81 |
+
public static function login_redirection_url ($user = FALSE)
|
82 |
+
{
|
83 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
84 |
+
do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
|
85 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
86 |
+
/**/
|
87 |
+
$url = c_ws_plugin__s2member_login_redirects::fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $user);
|
88 |
+
/**/
|
89 |
+
return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
|
90 |
+
}
|
91 |
+
/*
|
92 |
+
Parses the URI out of a possible ( Special ) Login Redirection URL.
|
93 |
+
*/
|
94 |
+
public static function login_redirection_uri ($user = FALSE)
|
95 |
+
{
|
96 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
97 |
+
do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
|
98 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
99 |
+
/**/
|
100 |
+
if ($url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
|
101 |
+
{
|
102 |
+
$path = parse_url ($url, PHP_URL_PATH);
|
103 |
+
$query = parse_url ($url, PHP_URL_QUERY);
|
104 |
+
$uri = ($query) ? $path . "?" . $query : $path;
|
105 |
+
}
|
106 |
+
/**/
|
107 |
+
return apply_filters ("ws_plugin__s2member_login_redirection_uri", $uri, get_defined_vars ());
|
108 |
+
}
|
109 |
+
/*
|
110 |
+
Function that fills replacement code variables in special redirection URLs.
|
111 |
+
*/
|
112 |
+
public static function fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE)
|
113 |
+
{
|
114 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
115 |
+
do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
|
116 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
117 |
+
/**/
|
118 |
+
$user = (is_object ($user)) ? $user : wp_get_current_user ();
|
119 |
+
$user_login = (is_object ($user)) ? strtolower ($user->user_login) : "";
|
120 |
+
$user_id = (is_object ($user)) ? (string)$user->ID : "";
|
121 |
+
$user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
|
122 |
+
$user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
|
123 |
+
$user_ccaps = implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
124 |
+
/**/
|
125 |
+
$url = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $url);
|
126 |
+
$url = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $url);
|
127 |
+
$url = preg_replace ("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_level), $url);
|
128 |
+
$url = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $url);
|
129 |
+
$url = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $url);
|
130 |
+
/**/
|
131 |
+
return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
?>
|
includes/classes/menu-pages.inc.php
ADDED
@@ -0,0 +1,554 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function that 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. */
|
37 |
+
if (preg_match ("/^" . preg_quote ("ws_plugin__s2member_", "/") . "/", $key))
|
38 |
+
/**/
|
39 |
+
if ($key === "ws_plugin__s2member_configured") /* Configured. */
|
40 |
+
{
|
41 |
+
update_option ("ws_plugin__s2member_configured", $value);
|
42 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = $value;
|
43 |
+
}
|
44 |
+
else /* Place this option into the array. Remove ws_plugin__s2member_. */
|
45 |
+
{
|
46 |
+
(is_array ($value)) ? array_shift ($value) : null; /* Arrays should be padded. */
|
47 |
+
$key = preg_replace ("/^" . preg_quote ("ws_plugin__s2member_", "/") . "/", "", $key);
|
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;');
|
55 |
+
do_action ("ws_plugin__s2member_during_update_all_options", get_defined_vars ());
|
56 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
57 |
+
/**/
|
58 |
+
update_option ("ws_plugin__s2member_options", $options) . update_option ("ws_plugin__s2member_cache", array ());
|
59 |
+
/**/
|
60 |
+
if ($update_other === true || in_array ("auto_eot_system", (array)$update_other)) /* Handle the Auto-EOT System now ( enable/disable ). */
|
61 |
+
($options["auto_eot_system_enabled"] == 1) ? c_ws_plugin__s2member_auto_eots::add_auto_eot_system () : c_ws_plugin__s2member_auto_eots::delete_auto_eot_system ();
|
62 |
+
/**/
|
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);
|
70 |
+
/**/
|
71 |
+
if ($options["login_welcome_page"] && $options["login_welcome_page"] === $options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is the same as your Membership Options Page. Please correct this. See: <code>s2Member -> General Options -> Login Welcome Page</code>.'))
|
72 |
+
($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);
|
73 |
+
/**/
|
74 |
+
if ($options["membership_options_page"] && (string)get_option ("page_on_front") === $options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Membership Options Page</code>.'))
|
75 |
+
($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);
|
76 |
+
/**/
|
77 |
+
if ($options["login_welcome_page"] && (string)get_option ("page_on_front") === $options["login_welcome_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Login Welcome Page</code>.'))
|
78 |
+
($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);
|
79 |
+
/**/
|
80 |
+
if ($options["membership_options_page"] && (string)get_option ("page_for_posts") === $options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Membership Options Page</code>.'))
|
81 |
+
($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);
|
82 |
+
/**/
|
83 |
+
if ($options["login_welcome_page"] && (string)get_option ("page_for_posts") === $options["login_welcome_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Login Welcome Page</code>.'))
|
84 |
+
($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);
|
85 |
+
/**/
|
86 |
+
if ($options["file_download_limit_exceeded_page"] && $options["file_download_limit_exceeded_page"] === $options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>s2Member:</strong> Your Download Limit Exceeded Page is the same as your Membership Options Page. Please correct this. See: <code>s2Member -> Download Options</code>.'))
|
87 |
+
($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);
|
88 |
+
}
|
89 |
+
/**/
|
90 |
+
$updated_all_options = true; /* Flag indicating this routine was indeed processed. */
|
91 |
+
}
|
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 |
+
Add the options menus & sub-menus.
|
99 |
+
Attach to: add_action("admin_menu");
|
100 |
+
*/
|
101 |
+
public static function add_admin_options ()
|
102 |
+
{
|
103 |
+
do_action ("ws_plugin__s2member_before_add_admin_options", get_defined_vars ());
|
104 |
+
/**/
|
105 |
+
add_filter ("plugin_action_links", "c_ws_plugin__s2member_menu_pages::_add_settings_link", 10, 2);
|
106 |
+
/**/
|
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 ())
|
110 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
|
111 |
+
/**/
|
112 |
+
if (is_multisite () && is_main_site ()) /* Re-organize menu whenever Multisite Networking is enabled; and we're on the Main Site. */
|
113 |
+
{
|
114 |
+
$menu = "ws-plugin--s2member-mms-options"; /* Used below for nesting additional sub-menu pages. */
|
115 |
+
/**/
|
116 |
+
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");
|
117 |
+
/**/
|
118 |
+
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");
|
119 |
+
add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "c_ws_plugin__s2member_menu_pages::options_page");
|
120 |
+
}
|
121 |
+
else /* Otherwise, we use the standard menu configuration here. The parent menu is the General Options for s2Member in this case. */
|
122 |
+
{
|
123 |
+
$menu = "ws-plugin--s2member-options"; /* Used below for nesting additional sub-menu pages. */
|
124 |
+
/**/
|
125 |
+
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");
|
126 |
+
/**/
|
127 |
+
add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "c_ws_plugin__s2member_menu_pages::options_page");
|
128 |
+
(!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;
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars ())) /* Shortcut. */
|
132 |
+
add_submenu_page ($menu, "s2Member / Add A Member", "Add A Member", "create_users", "user-new.php"); /* Shortcut to user-new.php. */
|
133 |
+
/**/
|
134 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars ()))
|
135 |
+
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");
|
136 |
+
/**/
|
137 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars ()))
|
138 |
+
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");
|
139 |
+
/**/
|
140 |
+
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 ()))
|
141 |
+
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");
|
142 |
+
/**/
|
143 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars ()))
|
144 |
+
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");
|
145 |
+
/**/
|
146 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_els_ops_page", true, get_defined_vars ()))
|
147 |
+
add_submenu_page ($menu, "s2Member API / List Servers", "API / List Servers", "create_users", "ws-plugin--s2member-els-ops", "c_ws_plugin__s2member_menu_pages::els_ops_page");
|
148 |
+
/**/
|
149 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_api_ops_page", true, get_defined_vars ()))
|
150 |
+
add_submenu_page ($menu, "s2Member API / Notifications", "API / Notifications", "create_users", "ws-plugin--s2member-api-ops", "c_ws_plugin__s2member_menu_pages::api_ops_page");
|
151 |
+
/**/
|
152 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars ()))
|
153 |
+
add_submenu_page ($menu, "s2Member API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "c_ws_plugin__s2member_menu_pages::scripting_page");
|
154 |
+
/**/
|
155 |
+
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 ()))
|
156 |
+
add_submenu_page ($menu, "s2Member Bridge Integrations", "API / Bridges", "create_users", "ws-plugin--s2member-bridges", "c_ws_plugin__s2member_menu_pages::bridges_page");
|
157 |
+
/**/
|
158 |
+
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 ()))
|
159 |
+
add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
160 |
+
/**/
|
161 |
+
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars ()))
|
162 |
+
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");
|
163 |
+
}
|
164 |
+
/**/
|
165 |
+
do_action ("ws_plugin__s2member_after_add_admin_options", get_defined_vars ());
|
166 |
+
/**/
|
167 |
+
return; /* Return for uniformity. */
|
168 |
+
}
|
169 |
+
/*
|
170 |
+
Add the options menus & sub-menus.
|
171 |
+
Attach to: add_action("network_admin_menu");
|
172 |
+
*/
|
173 |
+
public static function add_network_admin_options ()
|
174 |
+
{
|
175 |
+
do_action ("ws_plugin__s2member_before_add_network_admin_options", get_defined_vars ());
|
176 |
+
/**/
|
177 |
+
if (apply_filters ("ws_plugin__s2member_during_add_network_admin_options_create_menu_items", true, get_defined_vars ()))
|
178 |
+
{
|
179 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
|
180 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
|
181 |
+
/**/
|
182 |
+
$menu = "ws-plugin--s2member-mms-options"; /* Used below for nesting additional sub-menu pages. */
|
183 |
+
/**/
|
184 |
+
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");
|
185 |
+
/**/
|
186 |
+
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");
|
187 |
+
/**/
|
188 |
+
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 ()))
|
189 |
+
add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
190 |
+
}
|
191 |
+
/**/
|
192 |
+
do_action ("ws_plugin__s2member_after_add_network_admin_options", get_defined_vars ());
|
193 |
+
/**/
|
194 |
+
return; /* Return for uniformity. */
|
195 |
+
}
|
196 |
+
/*
|
197 |
+
A sort of callback function to add the settings link.
|
198 |
+
*/
|
199 |
+
public static function _add_settings_link ($links = array (), $file = "")
|
200 |
+
{
|
201 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
202 |
+
do_action ("_ws_plugin__s2member_before_add_settings_link", get_defined_vars ());
|
203 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
204 |
+
/**/
|
205 |
+
if (preg_match ("/" . preg_quote ($file, "/") . "$/", $GLOBALS["WS_PLUGIN__"]["s2member"]["l"]) && is_array ($links))
|
206 |
+
{
|
207 |
+
$settings = '<a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-options")) . '">Settings</a>';
|
208 |
+
array_unshift ($links, apply_filters ("ws_plugin__s2member_add_settings_link", $settings, get_defined_vars ()));
|
209 |
+
/**/
|
210 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
211 |
+
do_action ("_ws_plugin__s2member_during_add_settings_link", get_defined_vars ());
|
212 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
213 |
+
}
|
214 |
+
/**/
|
215 |
+
return apply_filters ("_ws_plugin__s2member_add_settings_link", $links, get_defined_vars ());
|
216 |
+
}
|
217 |
+
/*
|
218 |
+
Add scripts to admin panels.
|
219 |
+
Attach to: add_action("admin_print_scripts");
|
220 |
+
*/
|
221 |
+
public static function add_admin_scripts ()
|
222 |
+
{
|
223 |
+
do_action ("ws_plugin__s2member_before_add_admin_scripts", get_defined_vars ());
|
224 |
+
/**/
|
225 |
+
if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
|
226 |
+
{
|
227 |
+
wp_enqueue_script ("jquery");
|
228 |
+
wp_enqueue_script ("thickbox");
|
229 |
+
wp_enqueue_script ("media-upload");
|
230 |
+
wp_enqueue_script ("jquery-ui-core");
|
231 |
+
wp_enqueue_script ("jquery-json-ps", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/includes/menu-pages/jquery-json-ps-min.js", array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
|
232 |
+
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"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
|
233 |
+
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"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
|
234 |
+
/**/
|
235 |
+
do_action ("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars ());
|
236 |
+
}
|
237 |
+
/**/
|
238 |
+
do_action ("ws_plugin__s2member_after_add_admin_scripts", get_defined_vars ());
|
239 |
+
/**/
|
240 |
+
return; /* Return for uniformity. */
|
241 |
+
}
|
242 |
+
/*
|
243 |
+
Add styles to admin panels.
|
244 |
+
Attach to: add_action("admin_print_styles");
|
245 |
+
*/
|
246 |
+
public static function add_admin_styles ()
|
247 |
+
{
|
248 |
+
do_action ("ws_plugin__s2member_before_add_admin_styles", get_defined_vars ());
|
249 |
+
/**/
|
250 |
+
if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
|
251 |
+
{
|
252 |
+
wp_enqueue_style ("thickbox");
|
253 |
+
wp_enqueue_style ("ws-plugin--s2member-menu-pages", site_url ("/?ws_plugin__s2member_menu_pages_css=" . urlencode (mt_rand ())), array ("thickbox"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
|
254 |
+
/**/
|
255 |
+
do_action ("ws_plugin__s2member_during_add_admin_styles", get_defined_vars ());
|
256 |
+
}
|
257 |
+
/**/
|
258 |
+
do_action ("ws_plugin__s2member_after_add_admin_styles", get_defined_vars ());
|
259 |
+
/**/
|
260 |
+
return; /* Return for uniformity. */
|
261 |
+
}
|
262 |
+
/*
|
263 |
+
Function for building and handling the Main Multisite Options page.
|
264 |
+
*/
|
265 |
+
public static function mms_options_page ()
|
266 |
+
{
|
267 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
268 |
+
/**/
|
269 |
+
do_action ("ws_plugin__s2member_before_mms_options_page", get_defined_vars ());
|
270 |
+
/**/
|
271 |
+
if (c_ws_plugin__s2member_menu_pages::update_all_options ())
|
272 |
+
c_ws_plugin__s2member_mms_patches::mms_patches (true);
|
273 |
+
/**/
|
274 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/mms-options.inc.php";
|
275 |
+
/**/
|
276 |
+
do_action ("ws_plugin__s2member_after_mms_options_page", get_defined_vars ());
|
277 |
+
/**/
|
278 |
+
return; /* Return for uniformity. */
|
279 |
+
}
|
280 |
+
/*
|
281 |
+
Function for building and handling the General Options page.
|
282 |
+
*/
|
283 |
+
public static function options_page ()
|
284 |
+
{
|
285 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
286 |
+
/**/
|
287 |
+
do_action ("ws_plugin__s2member_before_options_page", get_defined_vars ());
|
288 |
+
/**/
|
289 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
290 |
+
/**/
|
291 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/options.inc.php";
|
292 |
+
/**/
|
293 |
+
do_action ("ws_plugin__s2member_after_options_page", get_defined_vars ());
|
294 |
+
/**/
|
295 |
+
return; /* Return for uniformity. */
|
296 |
+
}
|
297 |
+
/*
|
298 |
+
Function for building and handling the Paypal Options page.
|
299 |
+
*/
|
300 |
+
public static function paypal_ops_page ()
|
301 |
+
{
|
302 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
303 |
+
/**/
|
304 |
+
do_action ("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars ());
|
305 |
+
/**/
|
306 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
307 |
+
/**/
|
308 |
+
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
309 |
+
/**/
|
310 |
+
if (!is_dir ($logs_dir) && is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir))))
|
311 |
+
mkdir ($logs_dir, 0777, true) . clearstatcache ();
|
312 |
+
/**/
|
313 |
+
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] . "/.htaccess";
|
314 |
+
/**/
|
315 |
+
if (is_dir ($logs_dir) && is_writable ($logs_dir) && !file_exists ($htaccess))
|
316 |
+
file_put_contents ($htaccess, "deny from all") . clearstatcache ();
|
317 |
+
/**/
|
318 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) /* Logging enabled? */
|
319 |
+
{
|
320 |
+
if (!is_dir ($logs_dir)) /* If the security-enabled logs directory does not exist yet. */
|
321 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The security-enabled logs directory ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $logs_dir)) . "</code> ) does not exist. Please create this directory manually & make it writable ( chmod 777 ).", true);
|
322 |
+
/**/
|
323 |
+
else if (!is_writable ($logs_dir)) /* If the logs directory is not writable yet. */
|
324 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("Permissions error. The security-enabled logs directory ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $logs_dir)) . "</code> ) is not writable. Please make this directory writable ( chmod 777 ).", true);
|
325 |
+
/**/
|
326 |
+
if (!file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
|
327 |
+
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);
|
328 |
+
/**/
|
329 |
+
else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
|
330 |
+
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);
|
331 |
+
}
|
332 |
+
/**/
|
333 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/paypal-ops.inc.php";
|
334 |
+
/**/
|
335 |
+
do_action ("ws_plugin__s2member_after_paypal_ops_page", get_defined_vars ());
|
336 |
+
/**/
|
337 |
+
return; /* Return for uniformity. */
|
338 |
+
}
|
339 |
+
/*
|
340 |
+
Function for building and handling the Download Options page.
|
341 |
+
*/
|
342 |
+
public static function down_ops_page ()
|
343 |
+
{
|
344 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
345 |
+
/**/
|
346 |
+
do_action ("ws_plugin__s2member_before_down_ops_page", get_defined_vars ());
|
347 |
+
/**/
|
348 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
349 |
+
/**/
|
350 |
+
$files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
|
351 |
+
/**/
|
352 |
+
if (!is_dir ($files_dir) && is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
|
353 |
+
mkdir ($files_dir, 0777, true) . clearstatcache ();
|
354 |
+
/**/
|
355 |
+
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/.htaccess";
|
356 |
+
/**/
|
357 |
+
if (is_dir ($files_dir) && is_writable ($files_dir) && !file_exists ($htaccess))
|
358 |
+
file_put_contents ($htaccess, "deny from all") . clearstatcache ();
|
359 |
+
/**/
|
360 |
+
if (!is_dir ($files_dir)) /* If the security-enabled files directory does not exist yet. */
|
361 |
+
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);
|
362 |
+
/**/
|
363 |
+
if (!file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
|
364 |
+
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);
|
365 |
+
/**/
|
366 |
+
else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
|
367 |
+
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);
|
368 |
+
/**/
|
369 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/down-ops.inc.php";
|
370 |
+
/**/
|
371 |
+
do_action ("ws_plugin__s2member_after_down_ops_page", get_defined_vars ());
|
372 |
+
/**/
|
373 |
+
return; /* Return for uniformity. */
|
374 |
+
}
|
375 |
+
/*
|
376 |
+
Function for building and handling the API Tracking options page.
|
377 |
+
*/
|
378 |
+
public static function trk_ops_page ()
|
379 |
+
{
|
380 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
381 |
+
/**/
|
382 |
+
do_action ("ws_plugin__s2member_before_trk_ops_page", get_defined_vars ());
|
383 |
+
/**/
|
384 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
385 |
+
/**/
|
386 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/trk-ops.inc.php";
|
387 |
+
/**/
|
388 |
+
do_action ("ws_plugin__s2member_after_trk_ops_page", get_defined_vars ());
|
389 |
+
/**/
|
390 |
+
return; /* Return for uniformity. */
|
391 |
+
}
|
392 |
+
/*
|
393 |
+
Function for building and handling the API List Server options page.
|
394 |
+
*/
|
395 |
+
public static function els_ops_page ()
|
396 |
+
{
|
397 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
398 |
+
/**/
|
399 |
+
do_action ("ws_plugin__s2member_before_els_ops_page", get_defined_vars ());
|
400 |
+
/**/
|
401 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
402 |
+
/**/
|
403 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/els-ops.inc.php";
|
404 |
+
/**/
|
405 |
+
do_action ("ws_plugin__s2member_after_els_ops_page", get_defined_vars ());
|
406 |
+
/**/
|
407 |
+
return; /* Return for uniformity. */
|
408 |
+
}
|
409 |
+
/*
|
410 |
+
Function for building and handling the API Notifications page.
|
411 |
+
*/
|
412 |
+
public static function api_ops_page ()
|
413 |
+
{
|
414 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
415 |
+
/**/
|
416 |
+
do_action ("ws_plugin__s2member_before_api_ops_page", get_defined_vars ());
|
417 |
+
/**/
|
418 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ();
|
419 |
+
/**/
|
420 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/api-ops.inc.php";
|
421 |
+
/**/
|
422 |
+
do_action ("ws_plugin__s2member_after_api_ops_page", get_defined_vars ());
|
423 |
+
/**/
|
424 |
+
return; /* Return for uniformity. */
|
425 |
+
}
|
426 |
+
/*
|
427 |
+
Function for building the PayPal Button Generator page.
|
428 |
+
*/
|
429 |
+
public static function paypal_buttons_page ()
|
430 |
+
{
|
431 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
432 |
+
/**/
|
433 |
+
do_action ("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars ());
|
434 |
+
/**/
|
435 |
+
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"])
|
436 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ('Please configure <code>s2Member -> PayPal® Options</code> first. Once all of your PayPal® Options are configured; including your Email Address, API Username, Password, and Signature; return to this page & generate your PayPal® Button(s).', true);
|
437 |
+
/**/
|
438 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/paypal-buttons.inc.php";
|
439 |
+
/**/
|
440 |
+
do_action ("ws_plugin__s2member_after_paypal_buttons_page", get_defined_vars ());
|
441 |
+
/**/
|
442 |
+
return; /* Return for uniformity. */
|
443 |
+
}
|
444 |
+
/*
|
445 |
+
Function for building the API Scripting page.
|
446 |
+
*/
|
447 |
+
public static function scripting_page ()
|
448 |
+
{
|
449 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
450 |
+
/**/
|
451 |
+
do_action ("ws_plugin__s2member_before_scripting_page", get_defined_vars ());
|
452 |
+
/**/
|
453 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
|
454 |
+
/**/
|
455 |
+
do_action ("ws_plugin__s2member_after_scripting_page", get_defined_vars ());
|
456 |
+
/**/
|
457 |
+
return; /* Return for uniformity. */
|
458 |
+
}
|
459 |
+
/*
|
460 |
+
Function for building the Bridge Integrations page.
|
461 |
+
*/
|
462 |
+
public static function bridges_page ()
|
463 |
+
{
|
464 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
465 |
+
/**/
|
466 |
+
do_action ("ws_plugin__s2member_before_bridges_page", get_defined_vars ());
|
467 |
+
/**/
|
468 |
+
if (($nonce = $_POST["ws_plugin__s2member_bridge_bbpress"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-bridge-bbpress"))
|
469 |
+
{
|
470 |
+
$post = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Trim/strip all _POST vars. */
|
471 |
+
/**/
|
472 |
+
if (($plugins_dir = rtrim ($post["ws_plugin__s2member_bridge_bbpress_plugins_dir"], "/")) && is_dir ($plugins_dir))
|
473 |
+
{
|
474 |
+
if (is_writable ($plugins_dir)) /* This directory MUST be writable. Otherwise, we cannot continue. */
|
475 |
+
{
|
476 |
+
if (preg_match ("/^Install/i", $post["ws_plugin__s2member_bridge_bbpress_action"]))
|
477 |
+
{
|
478 |
+
$min = (string)$post["ws_plugin__s2member_bridge_bbpress_min_level"];
|
479 |
+
/**/
|
480 |
+
if (($file = file_get_contents (dirname (dirname (__FILE__)) . "/dropins/bridges/_s2member-bbpress-bridge.php")) && ($file = preg_replace ("/%%min%%/i", c_ws_plugin__s2member_utils_strings::esc_dq ($min), $file)) && file_put_contents ($plugins_dir . "/_s2member-bbpress-bridge.php", $file))
|
481 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The bbPress® Bridge/plugin has been <strong>installed successfully</strong>.");
|
482 |
+
/**/
|
483 |
+
else /* Otherwise, something unexpected. The site owner will need to install the bbPress® plugin manually. */
|
484 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("Unknown error. Please try again, or install manually.", true);
|
485 |
+
}
|
486 |
+
/**/
|
487 |
+
else if (preg_match ("/^Un-Install/i", $post["ws_plugin__s2member_bridge_bbpress_action"]))
|
488 |
+
{
|
489 |
+
if (file_exists ($plugins_dir . "/_s2member-bbpress-bridge.php"))
|
490 |
+
{
|
491 |
+
if (!unlink ($plugins_dir . "/_s2member-bbpress-bridge.php")) /* Test return value of unlink. */
|
492 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("Unknown error. Please try again, or un-install manually.", true);
|
493 |
+
/**/
|
494 |
+
else /* Otherwise, everything looks good. The plugin file has been removed successfully. */
|
495 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The bbPress® Bridge/plugin has been successfully <strong>un-installed</strong>.");
|
496 |
+
}
|
497 |
+
else
|
498 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The bbPress® Bridge/plugin is already un-installed.", true);
|
499 |
+
}
|
500 |
+
}
|
501 |
+
else
|
502 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The directory you specified is NOT writable. Please try again, or install manually.", true);
|
503 |
+
}
|
504 |
+
else
|
505 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice ("The directory you specified does NOT exist. Please try again, or install manually.", true);
|
506 |
+
}
|
507 |
+
/**/
|
508 |
+
if (!is_dir ($plugins_dir_guess = $_SERVER["DOCUMENT_ROOT"] . "/bbpress/my-plugins"))
|
509 |
+
if (!is_dir ($plugins_dir_guess = $_SERVER["DOCUMENT_ROOT"] . "/forums/my-plugins"))
|
510 |
+
if (!is_dir ($plugins_dir_guess = $_SERVER["DOCUMENT_ROOT"] . "/bbpress/bb-plugins"))
|
511 |
+
if (!is_dir ($plugins_dir_guess = $_SERVER["DOCUMENT_ROOT"] . "/forums/bb-plugins"))
|
512 |
+
$plugins_dir_guess = ($plugins_dir) ? $plugins_dir : $plugins_dir_guess;
|
513 |
+
/**/
|
514 |
+
$_bridge_bbpress_plugins_dir_guess = ($plugins_dir) ? $plugins_dir : $plugins_dir_guess;
|
515 |
+
/**/
|
516 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/bridges.inc.php";
|
517 |
+
/**/
|
518 |
+
do_action ("ws_plugin__s2member_after_bridges_page", get_defined_vars ());
|
519 |
+
/**/
|
520 |
+
return; /* Return for uniformity. */
|
521 |
+
}
|
522 |
+
/*
|
523 |
+
Function for building the s2Member Info page.
|
524 |
+
*/
|
525 |
+
public static function info_page ()
|
526 |
+
{
|
527 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
528 |
+
/**/
|
529 |
+
do_action ("ws_plugin__s2member_before_info_page", get_defined_vars ());
|
530 |
+
/**/
|
531 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
|
532 |
+
/**/
|
533 |
+
do_action ("ws_plugin__s2member_after_info_page", get_defined_vars ());
|
534 |
+
/**/
|
535 |
+
return; /* Return for uniformity. */
|
536 |
+
}
|
537 |
+
/*
|
538 |
+
Function for building and handling the Quick Start page.
|
539 |
+
*/
|
540 |
+
public static function start_page ()
|
541 |
+
{
|
542 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
543 |
+
/**/
|
544 |
+
do_action ("ws_plugin__s2member_before_start_page", get_defined_vars ());
|
545 |
+
/**/
|
546 |
+
include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
|
547 |
+
/**/
|
548 |
+
do_action ("ws_plugin__s2member_after_start_page", get_defined_vars ());
|
549 |
+
/**/
|
550 |
+
return; /* Return for uniformity. */
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
?>
|
includes/classes/meta-box-saves.inc.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
28 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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. */
|
37 |
+
/**/
|
38 |
+
if (($_p["post_type"] === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id))
|
39 |
+
{
|
40 |
+
if ($_p["post_type"] === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
|
41 |
+
{
|
42 |
+
if (isset ($_p["ws_plugin__s2member_security_meta_box_level"])) /* Just needs to be set. It CAN be empty. */
|
43 |
+
{
|
44 |
+
$pages["0"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"]));
|
45 |
+
$pages["1"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]));
|
46 |
+
$pages["2"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"]));
|
47 |
+
$pages["3"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"]));
|
48 |
+
$pages["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]));
|
49 |
+
/**/
|
50 |
+
if (($i = array_search ($page_id, $pages["0"])) !== false) /* Remove $page_id from existing options. */
|
51 |
+
unset ($pages["0"][$i]);
|
52 |
+
else if (($i = array_search ($page_id, $pages["1"])) !== false)
|
53 |
+
unset ($pages["1"][$i]);
|
54 |
+
else if (($i = array_search ($page_id, $pages["2"])) !== false)
|
55 |
+
unset ($pages["2"][$i]);
|
56 |
+
else if (($i = array_search ($page_id, $pages["3"])) !== false)
|
57 |
+
unset ($pages["3"][$i]);
|
58 |
+
else if (($i = array_search ($page_id, $pages["4"])) !== false)
|
59 |
+
unset ($pages["4"][$i]);
|
60 |
+
/**/
|
61 |
+
if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
62 |
+
if (!$pages[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
|
63 |
+
array_push ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]], $page_id);
|
64 |
+
/**/
|
65 |
+
$new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_pages" => implode (",", $pages[0]), "ws_plugin__s2member_level1_pages" => implode (",", $pages[1]), "ws_plugin__s2member_level2_pages" => implode (",", $pages[2]), "ws_plugin__s2member_level3_pages" => implode (",", $pages[3]), "ws_plugin__s2member_level4_pages" => implode (",", $pages[4])));
|
66 |
+
/**/
|
67 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
68 |
+
do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
|
69 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
70 |
+
/**/
|
71 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
/**/
|
75 |
+
else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
|
76 |
+
{
|
77 |
+
if (isset ($_p["ws_plugin__s2member_security_meta_box_level"])) /* Just needs to be set. It CAN be empty. */
|
78 |
+
{
|
79 |
+
$posts["0"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"]));
|
80 |
+
$posts["1"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]));
|
81 |
+
$posts["2"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"]));
|
82 |
+
$posts["3"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"]));
|
83 |
+
$posts["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"]));
|
84 |
+
/**/
|
85 |
+
if (($i = array_search ($post_id, $posts["0"])) !== false) /* Remove $post_id from existing options. */
|
86 |
+
unset ($posts["0"][$i]);
|
87 |
+
else if (($i = array_search ($post_id, $posts["1"])) !== false)
|
88 |
+
unset ($posts["1"][$i]);
|
89 |
+
else if (($i = array_search ($post_id, $posts["2"])) !== false)
|
90 |
+
unset ($posts["2"][$i]);
|
91 |
+
else if (($i = array_search ($post_id, $posts["3"])) !== false)
|
92 |
+
unset ($posts["3"][$i]);
|
93 |
+
else if (($i = array_search ($post_id, $posts["4"])) !== false)
|
94 |
+
unset ($posts["4"][$i]);
|
95 |
+
/**/
|
96 |
+
if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
97 |
+
if (!$posts[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
|
98 |
+
array_push ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]], $post_id);
|
99 |
+
/**/
|
100 |
+
$new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_posts" => implode (",", $posts[0]), "ws_plugin__s2member_level1_posts" => implode (",", $posts[1]), "ws_plugin__s2member_level2_posts" => implode (",", $posts[2]), "ws_plugin__s2member_level3_posts" => implode (",", $posts[3]), "ws_plugin__s2member_level4_posts" => implode (",", $posts[4])));
|
101 |
+
/**/
|
102 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
103 |
+
do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
|
104 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
105 |
+
/**/
|
106 |
+
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
/**/
|
110 |
+
if ($_p["post_type"] === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
|
111 |
+
{
|
112 |
+
if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"])) /* Just needs to be set. It CAN be empty. */
|
113 |
+
{
|
114 |
+
$ccaps_req = trim (strtolower ($_p["ws_plugin__s2member_security_meta_box_ccaps"]), ",");
|
115 |
+
$ccaps_req = trim (preg_replace ("/[^a-z_0-9,]/", "", $ccaps_req), ","); /* Now clean up. */
|
116 |
+
/**/
|
117 |
+
if (strlen ($ccaps_req) && ($s2member_ccaps_req = preg_split ("/[\r\n\t\s;,]+/", $ccaps_req)))
|
118 |
+
update_post_meta ($page_id, "s2member_ccaps_req", $s2member_ccaps_req);
|
119 |
+
/**/
|
120 |
+
else /* Otherwise, the array is empty. Safe to delete. */
|
121 |
+
delete_post_meta ($page_id, "s2member_ccaps_req");
|
122 |
+
}
|
123 |
+
}
|
124 |
+
/**/
|
125 |
+
else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
|
126 |
+
{
|
127 |
+
if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"])) /* Just needs to be set. It CAN be empty. */
|
128 |
+
{
|
129 |
+
$ccaps_req = trim (strtolower ($_p["ws_plugin__s2member_security_meta_box_ccaps"]), ",");
|
130 |
+
$ccaps_req = trim (preg_replace ("/[^a-z_0-9,]/", "", $ccaps_req), ","); /* Now clean up. */
|
131 |
+
/**/
|
132 |
+
if (strlen ($ccaps_req) && ($s2member_ccaps_req = preg_split ("/[\r\n\t\s;,]+/", $ccaps_req)))
|
133 |
+
update_post_meta ($post_id, "s2member_ccaps_req", $s2member_ccaps_req);
|
134 |
+
/**/
|
135 |
+
else /* Otherwise, the array is empty. Safe to delete. */
|
136 |
+
delete_post_meta ($post_id, "s2member_ccaps_req");
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
/**/
|
142 |
+
do_action ("ws_plugin__s2member_after_save_meta_boxes", get_defined_vars ());
|
143 |
+
/**/
|
144 |
+
return; /* Return for uniformity. */
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
?>
|
includes/classes/meta-box-security.inc.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
34 |
+
if (!in_array ($page_id, array ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"], $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"], $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])))
|
35 |
+
{
|
36 |
+
echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save" id="ws-plugin--s2member-security-meta-box-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-security-meta-box-save")) . '" />' . "\n";
|
37 |
+
echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save_id" id="ws-plugin--s2member-security-meta-box-save-id" value="' . esc_attr ($page_id) . '" />' . "\n";
|
38 |
+
/**/
|
39 |
+
$pages["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"]);
|
40 |
+
$pages["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]);
|
41 |
+
$pages["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"]);
|
42 |
+
$pages["3"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"]);
|
43 |
+
$pages["4"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]);
|
44 |
+
/**/
|
45 |
+
echo '<p style="margin-left:2px;"><strong>Page Level Restriction?</strong></p>' . "\n";
|
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 ())
|
57 |
+
/* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
|
58 |
+
{
|
59 |
+
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>' . "\n";
|
60 |
+
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>' . "\n";
|
61 |
+
echo '<input type="text" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="' . format_to_edit (implode (",", (array)get_post_meta ($page_id, "s2member_ccaps_req", true))) . '" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" style="width:99%;" />' . "\n";
|
62 |
+
echo '<br /><small>* see: <code>API Scripting -> Custom Capabilities</code></small>' . "\n";
|
63 |
+
}
|
64 |
+
}
|
65 |
+
else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
66 |
+
echo 'This Page is your:<br /><strong>Membership Options Page</strong><br />( always publicly available )';
|
67 |
+
/**/
|
68 |
+
else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
|
69 |
+
echo 'This Page is your:<br /><strong>Login Welcome Page</strong><br />( automatically guarded by s2Member )';
|
70 |
+
/**/
|
71 |
+
else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
|
72 |
+
echo 'This Page is your:<br /><strong>Download Limit Exceeded Page</strong><br />( automatically guarded by s2Member )';
|
73 |
+
}
|
74 |
+
else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
|
75 |
+
{
|
76 |
+
echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save" id="ws-plugin--s2member-security-meta-box-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-security-meta-box-save")) . '" />' . "\n";
|
77 |
+
echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save_id" id="ws-plugin--s2member-security-meta-box-save-id" value="' . esc_attr ($post_id) . '" />' . "\n";
|
78 |
+
/**/
|
79 |
+
$posts["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"]);
|
80 |
+
$posts["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]);
|
81 |
+
$posts["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"]);
|
82 |
+
$posts["3"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"]);
|
83 |
+
$posts["4"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"]);
|
84 |
+
/**/
|
85 |
+
echo '<p style="margin-left:2px;"><strong>Post Level Restriction?</strong></p>' . "\n"; /* This allows a site owner to automatically add a Page/Post into their s2Member options. */
|
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 ())
|
97 |
+
/* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
|
98 |
+
{
|
99 |
+
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>' . "\n";
|
100 |
+
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>' . "\n";
|
101 |
+
echo '<input type="text" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="' . format_to_edit (implode (",", (array)get_post_meta ($post_id, "s2member_ccaps_req", true))) . '" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" style="width:99%;" />' . "\n";
|
102 |
+
echo '<br /><small>* see: <code>API Scripting -> Custom Capabilities</code></small>' . "\n";
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
/**/
|
107 |
+
do_action ("ws_plugin__s2member_after_security_meta_box", get_defined_vars ());
|
108 |
+
/**/
|
109 |
+
return; /* Return for uniformity. */
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
?>
|
includes/classes/meta-boxes.inc.php
ADDED
@@ -0,0 +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_meta_boxes"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_meta_boxes
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function adds meta boxes to Post/Page editing stations.
|
23 |
+
Attach to: add_action("admin_menu");
|
24 |
+
*/
|
25 |
+
public static function add_meta_boxes ()
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
foreach (get_post_types () as $type) /* Handles Custom Post Types as well. */
|
30 |
+
if (!in_array ($type, array ("revision", "attachment", "nav_menu_item"))) /* But NOT on these Post Types. */
|
31 |
+
add_meta_box ("ws-plugin--s2member-security", "s2Member", "c_ws_plugin__s2member_meta_box_security::security_meta_box", $type, "side", "high");
|
32 |
+
/**/
|
33 |
+
do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
|
34 |
+
/**/
|
35 |
+
return; /* Return for uniformity. */
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
?>
|
includes/classes/misc-redirects.inc.php
ADDED
@@ -0,0 +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_misc_redirects"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_misc_redirects
|
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
|
24 |
+
Page is currently set as the Membership Options Page.
|
25 |
+
|
26 |
+
This is used by s2Member's bbPress Bridge integration.
|
27 |
+
|
28 |
+
Attach to: add_action("template_redirect");
|
29 |
+
Example usage: http://example.com/?s2member_membership_options_page=1
|
30 |
+
*/
|
31 |
+
public static function membership_options_page () /* Force a redirection. */
|
32 |
+
{
|
33 |
+
do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ());
|
34 |
+
/**/
|
35 |
+
if ($_GET["s2member_membership_options_page"] && !is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
|
36 |
+
{
|
37 |
+
$query_args = array (); /* Initialize array. */
|
38 |
+
foreach ($_GET as $var => $val) /* Include any s2member_ vars. */
|
39 |
+
if (preg_match ("/^s2member_/", $var) && $var !== "s2member_membership_options_page")
|
40 |
+
$query_args[$var] = $val;
|
41 |
+
/**/
|
42 |
+
wp_redirect (add_query_arg (urlencode_deep ($query_args), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), 301);
|
43 |
+
exit ();
|
44 |
+
}
|
45 |
+
/**/
|
46 |
+
do_action ("ws_plugin__s2member_after_membership_options_page", get_defined_vars ());
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
?>
|
includes/classes/mms-patches.inc.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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…" && c_ws_plugin__s2member_mms_patches::mms_patches ())
|
35 |
+
apply_filters ("update_feedback", "s2 Multisite patches applied…");
|
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 |
+
/**/
|
48 |
+
if (is_multisite () && is_admin () && is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"])
|
49 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] && (!defined ("DISALLOW_FILE_MODS") || !DISALLOW_FILE_MODS))
|
50 |
+
{
|
51 |
+
do_action ("ws_plugin__s2member_during_mms_patches_before", get_defined_vars ());
|
52 |
+
/**/
|
53 |
+
$wp_login_file = ABSPATH . "wp-login.php"; /* This works for both WordPress® 3.1 and 3.0. WordPress® 3.1+ uses: `site_url('wp-signup.php')`. */
|
54 |
+
$wp_login_section = "/([\r\n\t\s ]+)(wp_redirect( *?)\(( *?)apply_filters( *?)\(( *?)['\"]wp_signup_location['\"],( *?)(site_url( *?)\(( *?)['\"]wp-signup\.php['\"]( *?)\)|get_bloginfo( *?)\(['\"]wpurl['\"]\)( *?)\.( *?)['\"]\/wp-signup\.php['\"])( *?)\)( *?)\);)([\r\n\t\s ]+)(exit;)/";
|
55 |
+
$wp_login_replace = "\n\t\t// Modified for full plugin compatiblity.\n\t\t//wp_redirect( apply_filters( 'wp_signup_location', site_url('wp-signup.php') ) );\n\t\t//exit;";
|
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;
|
63 |
+
else if (!$wp_login_patched) /* Otherwise, we need to report that /wp-login.php could NOT be updated. Wrong WordPress® version? */
|
64 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. Unverifiable.', true) : null;
|
65 |
+
}
|
66 |
+
else /* Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error. */
|
67 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. File NOT writable.', true) : null;
|
68 |
+
/**/
|
69 |
+
$load_file = ABSPATH . WPINC . "/load.php";
|
70 |
+
$load_section = "/([\r\n\t\s ]+)(if( *?)\(( *?)empty( *?)\(( *?)\\\$active_plugins( *?)\)( *?)\|\|( *?)defined( *?)\(( *?)['\"]WP_INSTALLING['\"]( *?)\)( *?)\))/";
|
71 |
+
$load_replace = "\n\n\t// Modified for full plugin compatiblity.\n\t//if ( empty( \$active_plugins ) || defined( 'WP_INSTALLING' ) )\n\tif ( empty( \$active_plugins ) || ( defined( 'WP_INSTALLING' ) && !preg_match(\"/\/wp-activate\.php/\", \$_SERVER[\"REQUEST_URI\"]) ) )";
|
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;
|
79 |
+
else if (!$load_patched) /* Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Wrong WordPress® version? */
|
80 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. Unverifiable.', true) : null;
|
81 |
+
}
|
82 |
+
else /* Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error. */
|
83 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. File NOT writable.', true) : null;
|
84 |
+
/**/
|
85 |
+
$user_new_file = ABSPATH . "wp-admin/user-new.php";
|
86 |
+
$user_new_section = "/([\r\n\t\s ]+)(wpmu_signup_user( *?)\(( *?)\\\$new_user_login,( *?)\\\$_REQUEST\[( *?)'email'( *?)\],( *?)array( *?)\(( *?)'add_to_blog'( *?)\=\>( *?)\\\$wpdb->blogid,( *?)'new_role'( *?)\=\>( *?)\\\$_REQUEST\[( *?)'role'( *?)\]( *?)\)( *?)\);)/";
|
87 |
+
$user_new_replace = "\n\t\t\t// Modified for full plugin compatiblity.\n\t\t\t//wpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) );\n\t\t\twpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], apply_filters( 'add_signup_meta', array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) ) );";
|
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;
|
95 |
+
else if (!$user_new_patched) /* Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Wrong WordPress® version? */
|
96 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Unverifiable.', true) : null;
|
97 |
+
}
|
98 |
+
else /* Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error. */
|
99 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. File NOT writable.', true) : null;
|
100 |
+
/**/
|
101 |
+
$ms_functions_file = ABSPATH . "wp-includes/ms-functions.php";
|
102 |
+
$ms_functions_section = "/([\r\n\t\s ]+)(return new WP_Error( *?)\(( *?)'user_already_exists'( *?),( *?)__( *?)\(( *?)'That username is already activated.'( *?)\),( *?)\\\$signup( *?)\);)/";
|
103 |
+
$ms_functions_replace = "\n\t\t\t// Modified for full plugin compatiblity.\n\t\t\t//return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), \$signup);\n\t\t\treturn apply_filters('_wpmu_activate_existing_error_', new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), \$signup), get_defined_vars());";
|
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;
|
111 |
+
else if (!$ms_functions_patched) /* Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Wrong WordPress® version? */
|
112 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Unverifiable.', true) : null;
|
113 |
+
}
|
114 |
+
else /* Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error. */
|
115 |
+
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. File NOT writable.', true) : null;
|
116 |
+
/**/
|
117 |
+
$ran_mms_patches = true; /* Flag indicating this routine was indeed processed. */
|
118 |
+
/**/
|
119 |
+
do_action ("ws_plugin__s2member_during_mms_patches_after", get_defined_vars ());
|
120 |
+
}
|
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 |
+
}
|
128 |
+
?>
|
includes/classes/nocache.inc.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 () . c_ws_plugin__s2member_nocache::nocache_headers ();
|
31 |
+
/**/
|
32 |
+
do_action ("ws_plugin__s2member_after_nocache", get_defined_vars ());
|
33 |
+
/**/
|
34 |
+
return; /* Return for uniformity. */
|
35 |
+
}
|
36 |
+
/*
|
37 |
+
Define compatible nocache constants for s2Member.
|
38 |
+
This is compatible with Quick Cache and also with WP Super Cache.
|
39 |
+
Quick Cache uses: QUICK_CACHE_ALLOWED, and Super Cache uses: DONOTCACHEPAGE.
|
40 |
+
Actually, Quick Cache is compatible with either of these defined constants.
|
41 |
+
|
42 |
+
Always disallow caching for logged in users and GET requests with /?s2member systematic use.
|
43 |
+
For clarity on the systematic use with s2member in the request, see: is-systematic.inc.php.
|
44 |
+
- Also disallow caching if the $nocache param is passed in as true by other routines.
|
45 |
+
* BUT, always obey the qcAC param that specifically allows caching.
|
46 |
+
|
47 |
+
This function is also called upon by other routines that protect members-only content areas.
|
48 |
+
Members-only content areas should never be cached. In other words, there are some important supplemental
|
49 |
+
routines that occur outside the scope of this single function. This function is called upon by those other
|
50 |
+
targeted routines, to handle the nocache constants when they are required.
|
51 |
+
|
52 |
+
These additional supplemental routines, include:
|
53 |
+
- c_ws_plugin__s2member_ruris::check_ruri_level_access()
|
54 |
+
- c_ws_plugin__s2member_catgs::check_catg_level_access()
|
55 |
+
- c_ws_plugin__s2member_ptags::check_ptag_level_access()
|
56 |
+
- c_ws_plugin__s2member_posts::check_post_level_access()
|
57 |
+
- c_ws_plugin__s2member_pages::check_page_level_access()
|
58 |
+
- c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok()
|
59 |
+
- c_ws_plugin__s2member_files::file_download_key()
|
60 |
+
- Button/Form/Shortcode Generators also call this.
|
61 |
+
*/
|
62 |
+
public static function nocache_constants ($nocache = FALSE)
|
63 |
+
{
|
64 |
+
static $once; /* We only need to set these Constants once. */
|
65 |
+
/**/
|
66 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
67 |
+
do_action ("ws_plugin__s2member_before_nocache_constants", get_defined_vars ());
|
68 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
69 |
+
/**/
|
70 |
+
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)))))
|
71 |
+
{
|
72 |
+
define ("QUICK_CACHE_ALLOWED", false) . define ("DONOTCACHEPAGE", true);
|
73 |
+
/**/
|
74 |
+
$GLOBALS["ws_plugin__s2member_nocache_headers_selective"] = true;
|
75 |
+
/**/
|
76 |
+
$once = true; /* Only need to set these Constants one time. */
|
77 |
+
/**/
|
78 |
+
do_action ("ws_plugin__s2member_during_nocache_constants", get_defined_vars ());
|
79 |
+
}
|
80 |
+
/**/
|
81 |
+
do_action ("ws_plugin__s2member_after_nocache_constants", get_defined_vars ());
|
82 |
+
/**/
|
83 |
+
return; /* Return for uniformity. */
|
84 |
+
}
|
85 |
+
/*
|
86 |
+
Sends Cache-Control ( no-cache ) headers.
|
87 |
+
This uses the nocache_headers() function provided by WordPress®.
|
88 |
+
This is compatible with the Quick Cache parameter ?qcABC=1 as well.
|
89 |
+
* Always obey the qcABC param that specifically allows browser caching.
|
90 |
+
*/
|
91 |
+
public static function nocache_headers () /* Cache-Control header. */
|
92 |
+
{
|
93 |
+
static $once; /* We only need to set these headers one time. */
|
94 |
+
/**/
|
95 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
96 |
+
do_action ("ws_plugin__s2member_before_nocache_headers", get_defined_vars ());
|
97 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
98 |
+
/**/
|
99 |
+
$using_selective_behavior = apply_filters ("ws_plugin__s2member_nocache_headers_selective", false, get_defined_vars ());
|
100 |
+
$selective = $GLOBALS["ws_plugin__s2member_nocache_headers_selective"]; /* Selective ( i.e. required ) ? */
|
101 |
+
/**/
|
102 |
+
if (!$once && !$_GET["qcABC"] && (!$using_selective_behavior || $selective) && !apply_filters ("ws_plugin__s2member_disable_nocache_headers", false, get_defined_vars ()))
|
103 |
+
{
|
104 |
+
if (is_array ($headers = headers_list ()))
|
105 |
+
foreach ($headers as $k => $header)
|
106 |
+
if (preg_match ("/no-cache/i", $header))
|
107 |
+
$no_cache_already_sent = true;
|
108 |
+
/**/
|
109 |
+
if (!$no_cache_already_sent)
|
110 |
+
nocache_headers ();
|
111 |
+
/**/
|
112 |
+
$once = true; /* Only need to set these headers once. */
|
113 |
+
/**/
|
114 |
+
do_action ("ws_plugin__s2member_during_nocache_headers", get_defined_vars ());
|
115 |
+
}
|
116 |
+
/**/
|
117 |
+
do_action ("ws_plugin__s2member_after_nocache_headers", get_defined_vars ());
|
118 |
+
/**/
|
119 |
+
return; /* Return for uniformity. */
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
?>
|
includes/classes/op-notices.inc.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("admin_init");
|
24 |
+
*/
|
25 |
+
public static function general_ops_notice ()
|
26 |
+
{
|
27 |
+
global $pagenow; /* Need this global variable. */
|
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 |
+
/**/
|
35 |
+
$js = '<script type="text/javascript">';
|
36 |
+
$js .= "jQuery('input#users_can_register, select#default_role').attr('disabled', 'disabled');";
|
37 |
+
$js .= '</script>';
|
38 |
+
/**/
|
39 |
+
do_action ("ws_plugin__s2member_during_general_ops_notice", get_defined_vars ());
|
40 |
+
/**/
|
41 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "blog:" . $pagenow);
|
42 |
+
}
|
43 |
+
/**/
|
44 |
+
do_action ("ws_plugin__s2member_after_general_ops_notice", get_defined_vars ());
|
45 |
+
/**/
|
46 |
+
return; /* Return for uniformity. */
|
47 |
+
}
|
48 |
+
/*
|
49 |
+
Function that describes the Multisite Option overrides for clarity.
|
50 |
+
Attach to: add_action("admin_init");
|
51 |
+
*/
|
52 |
+
public static function multisite_ops_notice ()
|
53 |
+
{
|
54 |
+
global $pagenow; /* Need this global variable. */
|
55 |
+
/**/
|
56 |
+
do_action ("ws_plugin__s2member_before_multisite_ops_notice", get_defined_vars ());
|
57 |
+
/**/
|
58 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_network_admin () && in_array ($pagenow, array ("settings.php", "ms-options.php")) && !isset ($_GET["page"]))
|
59 |
+
{
|
60 |
+
if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
|
61 |
+
{
|
62 |
+
$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>.";
|
63 |
+
/**/
|
64 |
+
$js = '<script type="text/javascript">';
|
65 |
+
$js .= "jQuery('input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
|
66 |
+
$js .= '</script>';
|
67 |
+
}
|
68 |
+
else /* Else we use the old WordPress® v3.0.x method of disabling these important options. */
|
69 |
+
{
|
70 |
+
$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>.";
|
71 |
+
/**/
|
72 |
+
$js = '<script type="text/javascript">';
|
73 |
+
$js .= "jQuery('input#dashboard_blog, select#default_user_role, input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
|
74 |
+
$js .= '</script>';
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
do_action ("ws_plugin__s2member_during_multisite_ops_notice", get_defined_vars ());
|
78 |
+
/**/
|
79 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "network:" . $pagenow);
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
do_action ("ws_plugin__s2member_after_multisite_ops_notice", get_defined_vars ());
|
83 |
+
/**/
|
84 |
+
return; /* Return for uniformity. */
|
85 |
+
}
|
86 |
+
/*
|
87 |
+
Function that deals with Reading Option conflicts.
|
88 |
+
Attach to: add_action("admin_init");
|
89 |
+
*/
|
90 |
+
public static function reading_ops_notice ()
|
91 |
+
{
|
92 |
+
global $pagenow; /* Need this global variable. */
|
93 |
+
/**/
|
94 |
+
do_action ("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars ());
|
95 |
+
/**/
|
96 |
+
if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "options-reading.php" && !isset ($_GET["page"]))
|
97 |
+
{
|
98 |
+
do_action ("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars ()); /* Now check for conflicts. */
|
99 |
+
/**/
|
100 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]/**/
|
101 |
+
&& ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this.'))
|
102 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
103 |
+
/**/
|
104 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]/**/
|
105 |
+
&& ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this.'))
|
106 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
107 |
+
/**/
|
108 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]/**/
|
109 |
+
&& ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this.'))
|
110 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
111 |
+
/**/
|
112 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]/**/
|
113 |
+
&& ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this.'))
|
114 |
+
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
115 |
+
}
|
116 |
+
/**/
|
117 |
+
do_action ("ws_plugin__s2member_after_reading_ops_notice", get_defined_vars ());
|
118 |
+
/**/
|
119 |
+
return; /* Return for uniformity. */
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
?>
|
includes/classes/option-forces.inc.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_force_default_role", get_defined_vars ());
|
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 |
+
{
|
37 |
+
do_action ("ws_plugin__s2member_before_force_mms_default_role", get_defined_vars ());
|
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 |
+
{
|
47 |
+
do_action ("ws_plugin__s2member_before_force_demotion_role", get_defined_vars ());
|
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 |
+
{
|
57 |
+
do_action ("ws_plugin__s2member_before_mms_allow_new_users", get_defined_vars ());
|
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 |
+
{
|
67 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
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 |
+
{
|
82 |
+
global $wpdb; /* Global database object reference */
|
83 |
+
/**/
|
84 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
85 |
+
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
86 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
87 |
+
/**/
|
88 |
+
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"];
|
89 |
+
/**/
|
90 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ())
|
91 |
+
return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "0"), get_defined_vars ());
|
92 |
+
/**/
|
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 |
+
}
|
100 |
+
}
|
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 |
+
{
|
111 |
+
global $wpdb; /* Global database object reference */
|
112 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
113 |
+
/**/
|
114 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
115 |
+
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
116 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
117 |
+
/**/
|
118 |
+
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"];
|
119 |
+
/**/
|
120 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site ()) /* NOT a Blog Farm. */
|
121 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
122 |
+
/**/
|
123 |
+
else if (!is_admin () && $users_can_register !== "all") /* Do NOT run these security checks on option pages; it's confusing to a site owner. */
|
124 |
+
{
|
125 |
+
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"))))
|
126 |
+
{
|
127 |
+
if (is_super_admin () || current_user_can ("create_users"))
|
128 |
+
{
|
129 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
130 |
+
}
|
131 |
+
else if ($subscr_gateway && $subscr_id && $custom && $level) /* A paying Customer? Cookies already authenticated above. */
|
132 |
+
{
|
133 |
+
list ($level) = preg_split ("/\:/", $level, 1); /* Parse out the level now. */
|
134 |
+
/**/
|
135 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . $level])
|
136 |
+
{
|
137 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
138 |
+
}
|
139 |
+
else /* Otherwise, we MUST allow them to create an account; they paid for it! */
|
140 |
+
{
|
141 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "user"), get_defined_vars ());
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
/* --------------------> $users_can_register !== "all", so exclude Level #0. */
|
146 |
+
else if (is_user_logged_in () && current_user_can ("access_s2member_level1") && is_object ($current_user = wp_get_current_user ()))
|
147 |
+
{
|
148 |
+
$blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
|
149 |
+
$current_user_blogs = (is_array ($blogs = get_blogs_of_user ($current_user->ID))) ? count ($blogs) - 1 : 0;
|
150 |
+
$current_user_blogs = ($current_user_blogs >= 0) ? $current_user_blogs : 0;
|
151 |
+
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
152 |
+
/**/
|
153 |
+
if ($current_user_blogs < $blogs_allowed) /* Are they within their limit? */
|
154 |
+
{
|
155 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
/**/
|
160 |
+
else if (!is_admin () && $users_can_register === "all") /* Do NOT run these security checks on option pages; it's confusing to a site owner. */
|
161 |
+
{
|
162 |
+
if (is_user_logged_in () && is_object ($current_user = wp_get_current_user ()))
|
163 |
+
{
|
164 |
+
$blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
|
165 |
+
$current_user_blogs = (is_array ($blogs = get_blogs_of_user ($current_user->ID))) ? count ($blogs) - 1 : 0;
|
166 |
+
$current_user_blogs = ($current_user_blogs >= 0) ? $current_user_blogs : 0;
|
167 |
+
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
168 |
+
/**/
|
169 |
+
if ($current_user_blogs >= $blogs_allowed) /* Are they at their limit? */
|
170 |
+
{
|
171 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
/**/
|
176 |
+
return apply_filters ("ws_plugin__s2member_check_mms_register_access", $users_can_register, get_defined_vars ());
|
177 |
+
}
|
178 |
+
/*
|
179 |
+
This handles register access in BuddyPress - for Multisite compatibility.
|
180 |
+
Attach to: add_filter("bp_core_get_site_options");
|
181 |
+
|
182 |
+
BuddyPress bypasses the default Filter ( `pre_site_option_registration` )
|
183 |
+
and instead, it uses: bp_core_get_site_options()
|
184 |
+
*/
|
185 |
+
public static function check_bp_mms_register_access ($site_options = FALSE)
|
186 |
+
{
|
187 |
+
if (is_multisite ()) /* Only if Multisite Networking is enabled. Pointless otherwise. */
|
188 |
+
$site_options["registration"] = c_ws_plugin__s2member_option_forces::check_mms_register_access ($site_options["registration"]);
|
189 |
+
/**/
|
190 |
+
return apply_filters ("ws_plugin__s2member_check_bp_mms_register_access", $site_options, get_defined_vars ());
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
?>
|
includes/classes/pages-sp.inc.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function 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 |
+
{
|
38 |
+
do_action ("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars ());
|
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")))
|
97 |
+
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_sp_req" => $page_id), get_defined_vars ());
|
98 |
+
}
|
99 |
+
/**/
|
100 |
+
do_action ("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars ());
|
101 |
+
}
|
102 |
+
/**/
|
103 |
+
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars ());
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
?>
|
includes/classes/pages.inc.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function for handling 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 |
+
{
|
38 |
+
global $post; /* get_the_ID() unavailable outside The Loop. */
|
39 |
+
/**/
|
40 |
+
do_action ("ws_plugin__s2member_before_check_page_level_access", get_defined_vars ());
|
41 |
+
/**/
|
42 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars ());
|
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 ();
|
121 |
+
}
|
122 |
+
}
|
123 |
+
/**/
|
124 |
+
do_action ("ws_plugin__s2member_during_check_page_level_access", get_defined_vars ());
|
125 |
+
}
|
126 |
+
/**/
|
127 |
+
do_action ("ws_plugin__s2member_after_check_page_level_access", get_defined_vars ());
|
128 |
+
/**/
|
129 |
+
return; /* For uniformity. */
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
?>
|
includes/classes/paypal-notify-in.inc.php
ADDED
@@ -0,0 +1,1775 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
37 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
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 |
+
/**/
|
47 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release Filters on wp_mail() / From: headers. */
|
48 |
+
/**/
|
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 " . /* Indicate Proxy Key. */
|
53 |
+
( ($postvars["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
54 |
+
/**/
|
55 |
+
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
56 |
+
/**/
|
57 |
+
$paypal["subscr_gateway"] = ($_GET["s2member_paypal_proxy"]) ? $_GET["s2member_paypal_proxy"] : "paypal"; /* Defaults to: `paypal`. */
|
58 |
+
/**/
|
59 |
+
$paypal["custom"] = (!$paypal["custom"]) ? c_ws_plugin__s2member_utils_users::get_user_custom_with ($paypal["recurring_payment_id"]) : $paypal["custom"];
|
60 |
+
/* Notifications following the PayPal® Pro format for Recurring Payments, do NOT carry the "custom" value, so we have to do a lookup.
|
61 |
+
This is only crucial for one IPN call in Standard Integration: `txn_type=recurring_payment_suspended_due_to_max_failed_payment`.
|
62 |
+
In Pro Integrations, we just need to make sure the "custom" field is assigned for each account during on-site checkout.
|
63 |
+
This way the "custom" value will always be available when it needs to be; for both Standard and Pro services. */
|
64 |
+
if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
65 |
+
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
|
66 |
+
email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
|
67 |
+
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
|
68 |
+
/*
|
69 |
+
Custom conditionals can be applied by Filters.
|
70 |
+
*/
|
71 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
72 |
+
if (!apply_filters ("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars ()))
|
73 |
+
{
|
74 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
75 |
+
/*
|
76 |
+
Virtual Terminal transactions.
|
77 |
+
This is not really necessary. It is only here because this txn_type could
|
78 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
79 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
80 |
+
*/
|
81 |
+
if (/**/(preg_match ("/^virtual_terminal$/i", $paypal["txn_type"]))/**/
|
82 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
83 |
+
&& ($paypal["txn_id"])/**/)
|
84 |
+
{
|
85 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
86 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars ());
|
87 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
88 |
+
/**/
|
89 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as virtual_terminal.";
|
90 |
+
/**/
|
91 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
92 |
+
/**/
|
93 |
+
$paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
|
94 |
+
/**/
|
95 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
96 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars ());
|
97 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
98 |
+
/**/
|
99 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
100 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars ());
|
101 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
102 |
+
}
|
103 |
+
/*
|
104 |
+
Express Checkout transactions.
|
105 |
+
This is not really necessary. It is only here because this txn_type could
|
106 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
107 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
108 |
+
*/
|
109 |
+
else if (/**/(preg_match ("/^express_checkout$/i", $paypal["txn_type"]))/**/
|
110 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
111 |
+
&& ($paypal["txn_id"])/**/)
|
112 |
+
{
|
113 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
114 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_express_checkout", get_defined_vars ());
|
115 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
116 |
+
/**/
|
117 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as express_checkout.";
|
118 |
+
/**/
|
119 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
120 |
+
/**/
|
121 |
+
$paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
|
122 |
+
$paypal["s2member_log"][] = "s2Member Pro handles Express Checkout events on-site, with an IPN proxy.";
|
123 |
+
/**/
|
124 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
125 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_express_checkout", get_defined_vars ());
|
126 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
127 |
+
/**/
|
128 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
129 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_express_checkout", get_defined_vars ());
|
130 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
131 |
+
}
|
132 |
+
/*
|
133 |
+
Cart ( Line Item ) transactions.
|
134 |
+
This is not really necessary. It is only here because this txn_type could
|
135 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
136 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
137 |
+
*/
|
138 |
+
else if (/**/(preg_match ("/^cart$/i", $paypal["txn_type"]))/**/
|
139 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
140 |
+
&& ($paypal["txn_id"])/**/)
|
141 |
+
{
|
142 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
143 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_cart", get_defined_vars ());
|
144 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
145 |
+
/**/
|
146 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as cart.";
|
147 |
+
/**/
|
148 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
149 |
+
/**/
|
150 |
+
$paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
|
151 |
+
$paypal["s2member_log"][] = "s2Member Pro handles Cart events on-site, with an IPN proxy.";
|
152 |
+
/**/
|
153 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
154 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_cart", get_defined_vars ());
|
155 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
156 |
+
/**/
|
157 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
158 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_cart", get_defined_vars ());
|
159 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
160 |
+
}
|
161 |
+
/*
|
162 |
+
Send Money / Mobile transactions.
|
163 |
+
This is not really necessary. It is only here because this txn_type could
|
164 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
165 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
166 |
+
*/
|
167 |
+
else if (/**/(preg_match ("/^send_money$/i", $paypal["txn_type"]))/**/
|
168 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
169 |
+
&& ($paypal["txn_id"])/**/)
|
170 |
+
{
|
171 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
172 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_send_money", get_defined_vars ());
|
173 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
174 |
+
/**/
|
175 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as send_money.";
|
176 |
+
/**/
|
177 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
178 |
+
/**/
|
179 |
+
$paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
|
180 |
+
/**/
|
181 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
182 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_send_money", get_defined_vars ());
|
183 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
184 |
+
/**/
|
185 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
186 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_send_money", get_defined_vars ());
|
187 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
188 |
+
}
|
189 |
+
/*
|
190 |
+
Specific Post/Page Access ~ Sales.
|
191 |
+
*/
|
192 |
+
else if (/**/(preg_match ("/^web_accept$/i", $paypal["txn_type"]))/**/
|
193 |
+
&& (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"]))/**/
|
194 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
195 |
+
&& ($paypal["payer_email"] && $paypal["txn_id"])/**/)
|
196 |
+
{
|
197 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
198 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars ());
|
199 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
200 |
+
/**/
|
201 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page Access.";
|
202 |
+
/**/
|
203 |
+
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
204 |
+
/**/
|
205 |
+
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"])))
|
206 |
+
{
|
207 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
208 |
+
/**/
|
209 |
+
$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"]);
|
210 |
+
$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);
|
211 |
+
/**/
|
212 |
+
$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"]);
|
213 |
+
$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);
|
214 |
+
/**/
|
215 |
+
$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"]);
|
216 |
+
$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);
|
217 |
+
/**/
|
218 |
+
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)))
|
219 |
+
if (($rec = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $rec))) /* Full amount of the payment, before fee is subtracted. */
|
220 |
+
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)))
|
221 |
+
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)))
|
222 |
+
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> ). */
|
223 |
+
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
224 |
+
/**/
|
225 |
+
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)))
|
226 |
+
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. */
|
227 |
+
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)))
|
228 |
+
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)))
|
229 |
+
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
230 |
+
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
231 |
+
/**/
|
232 |
+
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)))
|
233 |
+
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. */
|
234 |
+
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)))
|
235 |
+
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)))
|
236 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
237 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
238 |
+
/**/
|
239 |
+
if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
240 |
+
{
|
241 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
|
242 |
+
($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;
|
243 |
+
/**/
|
244 |
+
$paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
|
245 |
+
}
|
246 |
+
/**/
|
247 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"])
|
248 |
+
{
|
249 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url)
|
250 |
+
/**/
|
251 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (rawurlencode ($sp_access_url)), $url)))
|
252 |
+
if (($url = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
|
253 |
+
if (($url = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["txn_id"])), $url)))
|
254 |
+
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)))
|
255 |
+
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)))
|
256 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
257 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
258 |
+
/**/
|
259 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
260 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
261 |
+
/**/
|
262 |
+
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
|
263 |
+
}
|
264 |
+
/**/
|
265 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])
|
266 |
+
{
|
267 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Specific Post/Page ~ Sale";
|
268 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
269 |
+
/**/
|
270 |
+
$msg .= "sp_access_url: %%sp_access_url%%\n";
|
271 |
+
$msg .= "sp_access_exp: %%sp_access_exp%%\n";
|
272 |
+
$msg .= "amount: %%amount%%\n";
|
273 |
+
$msg .= "txn_id: %%txn_id%%\n";
|
274 |
+
$msg .= "item_number: %%item_number%%\n";
|
275 |
+
$msg .= "item_name: %%item_name%%\n";
|
276 |
+
$msg .= "first_name: %%first_name%%\n";
|
277 |
+
$msg .= "last_name: %%last_name%%\n";
|
278 |
+
$msg .= "full_name: %%full_name%%\n";
|
279 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
280 |
+
$msg .= "cv0: %%cv0%%\n";
|
281 |
+
$msg .= "cv1: %%cv1%%\n";
|
282 |
+
$msg .= "cv2: %%cv2%%\n";
|
283 |
+
$msg .= "cv3: %%cv3%%\n";
|
284 |
+
$msg .= "cv4: %%cv4%%\n";
|
285 |
+
$msg .= "cv5: %%cv5%%\n";
|
286 |
+
$msg .= "cv6: %%cv6%%\n";
|
287 |
+
$msg .= "cv7: %%cv7%%\n";
|
288 |
+
$msg .= "cv8: %%cv8%%\n";
|
289 |
+
$msg .= "cv9: %%cv9%%";
|
290 |
+
/**/
|
291 |
+
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $msg)))
|
292 |
+
if (($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)))
|
293 |
+
if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $msg)))
|
294 |
+
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)))
|
295 |
+
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)))
|
296 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
297 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
298 |
+
/**/
|
299 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
300 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])) as $recipient)
|
301 |
+
($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;
|
302 |
+
/**/
|
303 |
+
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
|
304 |
+
}
|
305 |
+
/**/
|
306 |
+
if ($processing && $_GET["s2member_paypal_proxy"] && ($url = $_GET["s2member_paypal_proxy_return_url"])) /* A Proxy is requesting a Return URL for this transaction? */
|
307 |
+
{
|
308 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (rawurlencode ($sp_access_url)), $url)))
|
309 |
+
if (($url = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
|
310 |
+
if (($url = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["txn_id"])), $url)))
|
311 |
+
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)))
|
312 |
+
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)))
|
313 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
314 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
315 |
+
/**/
|
316 |
+
if (($url = trim ($url))) /* Preserve Remaining replacements. */
|
317 |
+
/* Because the parent routine may perform replacements too. */
|
318 |
+
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
319 |
+
/**/
|
320 |
+
$paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
|
321 |
+
}
|
322 |
+
/**/
|
323 |
+
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]))
|
324 |
+
{
|
325 |
+
if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $code)))
|
326 |
+
if (($code = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $code)))
|
327 |
+
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)))
|
328 |
+
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
329 |
+
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
330 |
+
/**/
|
331 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
|
332 |
+
{
|
333 |
+
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
334 |
+
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
335 |
+
}
|
336 |
+
}
|
337 |
+
/**/
|
338 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
339 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars ());
|
340 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
341 |
+
}
|
342 |
+
else
|
343 |
+
$paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?";
|
344 |
+
/**/
|
345 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
346 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars ());
|
347 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
348 |
+
}
|
349 |
+
/*
|
350 |
+
New Subscriptions.
|
351 |
+
Possibly containing advanced update vars
|
352 |
+
( option_name1, option_selection1 ); which allow account modifications.
|
353 |
+
*/
|
354 |
+
else if (/**/(preg_match ("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))/**/
|
355 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
|
356 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
|
357 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
358 |
+
&& ($paypal["payer_email"])/**/)
|
359 |
+
{
|
360 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
361 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", get_defined_vars ());
|
362 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
363 |
+
/**/
|
364 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup).";
|
365 |
+
/**/
|
366 |
+
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
367 |
+
/**/
|
368 |
+
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
369 |
+
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
|
370 |
+
/**/
|
371 |
+
if (preg_match ("/^web_accept$/i", $paypal["txn_type"])) /* Conversions for Lifetime & Fixed-Term sales. */
|
372 |
+
{
|
373 |
+
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : "1 L"; /* 1 Lifetime. */
|
374 |
+
$paypal["mc_amount3"] = $paypal["mc_gross"]; /* The "Buy Now" amount is the full gross. */
|
375 |
+
}
|
376 |
+
/**/
|
377 |
+
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
378 |
+
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
379 |
+
$paypal["regular"] = $paypal["mc_amount3"]; /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */
|
380 |
+
$paypal["regular_term"] = $paypal["period3"]; /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
|
381 |
+
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise Regular. */
|
382 |
+
/**/
|
383 |
+
eval ('$ipn_signup_vars = $paypal; unset($ipn_signup_vars["s2member_log"]);'); /* Create array of IPN signup vars w/o s2member_log. */
|
384 |
+
/*
|
385 |
+
New Subscription with advanced update vars ( option_name1, option_selection1 )? These variables are used in Subscr. Modifications.
|
386 |
+
*/
|
387 |
+
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle Subscription update modifications. */
|
388 |
+
/* 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
|
389 |
+
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. */
|
390 |
+
{
|
391 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
392 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
|
393 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
394 |
+
/**/
|
395 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/ update vars.";
|
396 |
+
/**/
|
397 |
+
/* Check for both the old & new subscr_id's, just in case the Return routine already changed it. */
|
398 |
+
if (($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)
|
399 |
+
{
|
400 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
401 |
+
{
|
402 |
+
$processing = $modifying = $during = true; /* Yes, we ARE processing this. */
|
403 |
+
/**/
|
404 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
405 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", get_defined_vars ());
|
406 |
+
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", $paypal["level"]);
|
407 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
408 |
+
/**/
|
409 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
410 |
+
/**/
|
411 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
412 |
+
{
|
413 |
+
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
414 |
+
$user = new WP_User ($user_id);
|
415 |
+
}
|
416 |
+
/**/
|
417 |
+
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
418 |
+
/**/
|
419 |
+
if ($current_role !== "s2member_level" . $paypal["level"]) /* Only if we need to. */
|
420 |
+
$user->set_role ("s2member_level" . $paypal["level"]); /* (upgrade/downgrade) */
|
421 |
+
/**/
|
422 |
+
if (!preg_match ("/^\+/", $paypal["ccaps"]))
|
423 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
424 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
425 |
+
$user->remove_cap ($ccap = $cap);
|
426 |
+
/**/
|
427 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($paypal["ccaps"], "+")) as $ccap)
|
428 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
429 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
430 |
+
/**/
|
431 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
432 |
+
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
433 |
+
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
434 |
+
/**/
|
435 |
+
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
436 |
+
/**/
|
437 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
438 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
439 |
+
/**/
|
440 |
+
if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
441 |
+
update_user_option ($user_id, "s2member_auto_eot_time", c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"]));
|
442 |
+
else /* Otherwise, we need to clear the Auto-EOT Time. */
|
443 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
444 |
+
/**/
|
445 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
446 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
447 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
448 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
449 |
+
/**/
|
450 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
451 |
+
/**/
|
452 |
+
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
453 |
+
/**/
|
454 |
+
wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", "Thank you! Your account has been updated.", get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", "Thank you! You've been updated to:\n" . $paypal["item_name"] . "\n\nPlease log back in now.\n" . wp_login_url (), 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");
|
455 |
+
/**/
|
456 |
+
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
457 |
+
/**/
|
458 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
459 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
|
460 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
461 |
+
}
|
462 |
+
else
|
463 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
464 |
+
}
|
465 |
+
else
|
466 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
|
467 |
+
/**/
|
468 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
469 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars ());
|
470 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
471 |
+
}
|
472 |
+
/*
|
473 |
+
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
474 |
+
*/
|
475 |
+
else /* Else this is a normal Subscription signup, we are not updating anything. */
|
476 |
+
{
|
477 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
478 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars ());
|
479 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
480 |
+
/**/
|
481 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/o update vars.";
|
482 |
+
/**/
|
483 |
+
if (($registration_url = c_ws_plugin__s2member_register_access::register_link_gen ($paypal["subscr_gateway"], $paypal["subscr_id"], $paypal["custom"], $paypal["item_number"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
484 |
+
{
|
485 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
486 |
+
/**/
|
487 |
+
$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"]);
|
488 |
+
$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"]);
|
489 |
+
$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"]);
|
490 |
+
/**/
|
491 |
+
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)))
|
492 |
+
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)))
|
493 |
+
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)))
|
494 |
+
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)))
|
495 |
+
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)))
|
496 |
+
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)))
|
497 |
+
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)))
|
498 |
+
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> ). */
|
499 |
+
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
500 |
+
/**/
|
501 |
+
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)))
|
502 |
+
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)))
|
503 |
+
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)))
|
504 |
+
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)))
|
505 |
+
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)))
|
506 |
+
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)))
|
507 |
+
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)))
|
508 |
+
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
509 |
+
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
510 |
+
/**/
|
511 |
+
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)))
|
512 |
+
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)))
|
513 |
+
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)))
|
514 |
+
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)))
|
515 |
+
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)))
|
516 |
+
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)))
|
517 |
+
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)))
|
518 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
519 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
520 |
+
/**/
|
521 |
+
if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
522 |
+
{
|
523 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
|
524 |
+
($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;
|
525 |
+
/**/
|
526 |
+
$paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
|
527 |
+
}
|
528 |
+
/**/
|
529 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
530 |
+
{
|
531 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
|
532 |
+
/**/
|
533 |
+
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)))
|
534 |
+
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)))
|
535 |
+
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)))
|
536 |
+
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)))
|
537 |
+
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)))
|
538 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
539 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
540 |
+
/**/
|
541 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
542 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
543 |
+
/**/
|
544 |
+
$paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
|
545 |
+
}
|
546 |
+
/**/
|
547 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
548 |
+
{
|
549 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Signup";
|
550 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
551 |
+
/**/
|
552 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
553 |
+
$msg .= "initial: %%initial%%\n";
|
554 |
+
$msg .= "regular: %%regular%%\n";
|
555 |
+
$msg .= "recurring: %%recurring%%\n";
|
556 |
+
$msg .= "initial_term: %%initial_term%%\n";
|
557 |
+
$msg .= "regular_term: %%regular_term%%\n";
|
558 |
+
$msg .= "item_number: %%item_number%%\n";
|
559 |
+
$msg .= "item_name: %%item_name%%\n";
|
560 |
+
$msg .= "first_name: %%first_name%%\n";
|
561 |
+
$msg .= "last_name: %%last_name%%\n";
|
562 |
+
$msg .= "full_name: %%full_name%%\n";
|
563 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
564 |
+
$msg .= "cv0: %%cv0%%\n";
|
565 |
+
$msg .= "cv1: %%cv1%%\n";
|
566 |
+
$msg .= "cv2: %%cv2%%\n";
|
567 |
+
$msg .= "cv3: %%cv3%%\n";
|
568 |
+
$msg .= "cv4: %%cv4%%\n";
|
569 |
+
$msg .= "cv5: %%cv5%%\n";
|
570 |
+
$msg .= "cv6: %%cv6%%\n";
|
571 |
+
$msg .= "cv7: %%cv7%%\n";
|
572 |
+
$msg .= "cv8: %%cv8%%\n";
|
573 |
+
$msg .= "cv9: %%cv9%%";
|
574 |
+
/**/
|
575 |
+
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)))
|
576 |
+
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)))
|
577 |
+
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)))
|
578 |
+
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)))
|
579 |
+
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)))
|
580 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
581 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
582 |
+
/**/
|
583 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
584 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"])) as $recipient)
|
585 |
+
($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;
|
586 |
+
/**/
|
587 |
+
$paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
|
588 |
+
}
|
589 |
+
/**/
|
590 |
+
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
591 |
+
{
|
592 |
+
if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $code)))
|
593 |
+
if (($code = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $code)) && ($code = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $code)) && ($code = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $code)))
|
594 |
+
if (($code = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $code)) && ($code = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $code)))
|
595 |
+
if (($code = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $code)))
|
596 |
+
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)))
|
597 |
+
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
598 |
+
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
599 |
+
/**/
|
600 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
|
601 |
+
{
|
602 |
+
$paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
|
603 |
+
set_transient ("s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
604 |
+
}
|
605 |
+
}
|
606 |
+
/**/
|
607 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
608 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());
|
609 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
610 |
+
}
|
611 |
+
else
|
612 |
+
$paypal["s2member_log"][] = "Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response.";
|
613 |
+
/**/
|
614 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
615 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars ());
|
616 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
617 |
+
}
|
618 |
+
/**/
|
619 |
+
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? */
|
620 |
+
{
|
621 |
+
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))
|
622 |
+
{
|
623 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed below. */
|
624 |
+
/**/
|
625 |
+
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)))
|
626 |
+
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)))
|
627 |
+
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)))
|
628 |
+
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)))
|
629 |
+
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)))
|
630 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
631 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
632 |
+
if (($url = preg_replace ("/%%modification%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ((int)$modifying)), $url)))
|
633 |
+
{
|
634 |
+
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)))
|
635 |
+
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)))
|
636 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
637 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
638 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
639 |
+
{
|
640 |
+
if (is_array ($fields) && !empty ($fields))
|
641 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
642 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
643 |
+
break;
|
644 |
+
/**/
|
645 |
+
if (($url = trim ($url))) /* Preserve remaining replacements. */
|
646 |
+
/* Because the parent routine may perform replacements too. */
|
647 |
+
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
648 |
+
}
|
649 |
+
}
|
650 |
+
}
|
651 |
+
/**/
|
652 |
+
$paypal["s2member_log"][] = "Subscr. Return ( modification=" . (int)$modifying . " ), a Proxy Return URL is ready.";
|
653 |
+
}
|
654 |
+
/**/
|
655 |
+
if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
|
656 |
+
&& (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))/**/
|
657 |
+
&& ( ($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)))
|
658 |
+
{
|
659 |
+
$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") . ").";
|
660 |
+
/**/
|
661 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
662 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
663 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
664 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
665 |
+
/**/
|
666 |
+
update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Also update the last payment time. */
|
667 |
+
/**/
|
668 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
|
669 |
+
/**/
|
670 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
671 |
+
{
|
672 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
673 |
+
/**/
|
674 |
+
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)))
|
675 |
+
if (($url = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["txn_id"])), $url)))
|
676 |
+
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)))
|
677 |
+
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)))
|
678 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
679 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
680 |
+
{
|
681 |
+
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)))
|
682 |
+
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)))
|
683 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
684 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
685 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
686 |
+
{
|
687 |
+
if (is_array ($fields) && !empty ($fields))
|
688 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
689 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
690 |
+
break;
|
691 |
+
/**/
|
692 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
693 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
694 |
+
}
|
695 |
+
}
|
696 |
+
/**/
|
697 |
+
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
698 |
+
}
|
699 |
+
/**/
|
700 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
701 |
+
{
|
702 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Payment";
|
703 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
704 |
+
/**/
|
705 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
706 |
+
$msg .= "amount: %%amount%%\n";
|
707 |
+
$msg .= "txn_id: %%txn_id%%\n";
|
708 |
+
$msg .= "item_number: %%item_number%%\n";
|
709 |
+
$msg .= "item_name: %%item_name%%\n";
|
710 |
+
$msg .= "first_name: %%first_name%%\n";
|
711 |
+
$msg .= "last_name: %%last_name%%\n";
|
712 |
+
$msg .= "full_name: %%full_name%%\n";
|
713 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
714 |
+
/**/
|
715 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
716 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
717 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
718 |
+
$msg .= "user_email: %%user_email%%\n";
|
719 |
+
$msg .= "user_login: %%user_login%%\n";
|
720 |
+
$msg .= "user_id: %%user_id%%\n";
|
721 |
+
/**/
|
722 |
+
if (is_array ($fields) && !empty ($fields))
|
723 |
+
foreach ($fields as $var => $val)
|
724 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
725 |
+
/**/
|
726 |
+
$msg .= "cv0: %%cv0%%\n";
|
727 |
+
$msg .= "cv1: %%cv1%%\n";
|
728 |
+
$msg .= "cv2: %%cv2%%\n";
|
729 |
+
$msg .= "cv3: %%cv3%%\n";
|
730 |
+
$msg .= "cv4: %%cv4%%\n";
|
731 |
+
$msg .= "cv5: %%cv5%%\n";
|
732 |
+
$msg .= "cv6: %%cv6%%\n";
|
733 |
+
$msg .= "cv7: %%cv7%%\n";
|
734 |
+
$msg .= "cv8: %%cv8%%\n";
|
735 |
+
$msg .= "cv9: %%cv9%%";
|
736 |
+
/**/
|
737 |
+
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)))
|
738 |
+
if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $msg)))
|
739 |
+
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)))
|
740 |
+
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)))
|
741 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
742 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
743 |
+
{
|
744 |
+
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)))
|
745 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
746 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
747 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
748 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
749 |
+
{
|
750 |
+
if (is_array ($fields) && !empty ($fields))
|
751 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
752 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
753 |
+
break;
|
754 |
+
/**/
|
755 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
756 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
|
757 |
+
($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;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
/**/
|
761 |
+
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
762 |
+
}
|
763 |
+
}
|
764 |
+
else if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
|
765 |
+
&& (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)))
|
766 |
+
{
|
767 |
+
$paypal["s2member_log"][] = "Storing `payment` for Subscription via (" . ( (preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . ").";
|
768 |
+
/**/
|
769 |
+
$ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
|
770 |
+
/**/
|
771 |
+
foreach ($paypal as $var => $val)
|
772 |
+
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")))
|
773 |
+
$ipn[$var] = $val;
|
774 |
+
/**/
|
775 |
+
$paypal["s2member_log"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.";
|
776 |
+
/**/
|
777 |
+
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
778 |
+
}
|
779 |
+
/**/
|
780 |
+
if ($processing /* Store signup vars now? If the User already exists in the database, we can go ahead and store these right now. */
|
781 |
+
&& ( ($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 |
+
$paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference.";
|
784 |
+
/**/
|
785 |
+
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
786 |
+
}
|
787 |
+
else if ($processing) /* Otherwise, we can store these into a Transient Queue for registration processing. */
|
788 |
+
{
|
789 |
+
$paypal["s2member_log"][] = "Storing IPN signup vars into a Transient Queue. These will be processed on registration.";
|
790 |
+
/**/
|
791 |
+
set_transient ("s2m_" . md5 ("s2member_transient_ipn_signup_vars_" . $paypal["subscr_id"]), $ipn_signup_vars, 43200);
|
792 |
+
}
|
793 |
+
/**/
|
794 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
795 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup", get_defined_vars ());
|
796 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
797 |
+
}
|
798 |
+
/*
|
799 |
+
Recurring Payment Profile creation.
|
800 |
+
This is not really necessary. It is only here because this txn_type could
|
801 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
802 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
803 |
+
*/
|
804 |
+
else if (/**/(preg_match ("/^recurring_payment_profile_created$/i", $paypal["txn_type"]))/**/
|
805 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
|
806 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
|
807 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
|
808 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))/**/
|
809 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/)
|
810 |
+
{
|
811 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
812 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars ());
|
813 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
814 |
+
/**/
|
815 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as recurring_payment_profile_created.";
|
816 |
+
/**/
|
817 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
818 |
+
/**/
|
819 |
+
$paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
|
820 |
+
$paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
|
821 |
+
/**/
|
822 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
823 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars ());
|
824 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
825 |
+
/**/
|
826 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
827 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars ());
|
828 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
829 |
+
}
|
830 |
+
/*
|
831 |
+
Subscription modifications.
|
832 |
+
*/
|
833 |
+
else if (/**/(preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))/**/
|
834 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
|
835 |
+
&& ($paypal["subscr_id"] && $paypal["payer_email"])/**/)
|
836 |
+
{
|
837 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
838 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars ());
|
839 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
840 |
+
/**/
|
841 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
|
842 |
+
/**/
|
843 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
|
844 |
+
/**/
|
845 |
+
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
846 |
+
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
|
847 |
+
/**/
|
848 |
+
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
849 |
+
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
850 |
+
$paypal["regular"] = $paypal["mc_amount3"]; /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */
|
851 |
+
$paypal["regular_term"] = $paypal["period3"]; /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
|
852 |
+
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise Regular. */
|
853 |
+
/**/
|
854 |
+
eval ('$ipn_signup_vars = $paypal; unset($ipn_signup_vars["s2member_log"]);'); /* Create array of IPN signup vars w/o s2member_log. */
|
855 |
+
/**/
|
856 |
+
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)
|
857 |
+
{
|
858 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
859 |
+
{
|
860 |
+
$processing = $modifying = $during = true; /* Yes, we ARE processing this. */
|
861 |
+
/**/
|
862 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
863 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars ());
|
864 |
+
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", $paypal["level"]);
|
865 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
866 |
+
/**/
|
867 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
868 |
+
/**/
|
869 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
870 |
+
{
|
871 |
+
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
872 |
+
$user = new WP_User ($user_id);
|
873 |
+
}
|
874 |
+
/**/
|
875 |
+
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
876 |
+
/**/
|
877 |
+
if ($current_role !== "s2member_level" . $paypal["level"]) /* Only if we need to. */
|
878 |
+
$user->set_role ("s2member_level" . $paypal["level"]); /* (upgrade/downgrade) */
|
879 |
+
/**/
|
880 |
+
if (!preg_match ("/^\+/", $paypal["ccaps"]))
|
881 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
882 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
883 |
+
$user->remove_cap ($ccap = $cap);
|
884 |
+
/**/
|
885 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($paypal["ccaps"], "+")) as $ccap)
|
886 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
887 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
888 |
+
/**/
|
889 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
890 |
+
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
891 |
+
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
892 |
+
/**/
|
893 |
+
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
894 |
+
/**/
|
895 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
896 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
897 |
+
/**/
|
898 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
899 |
+
/**/
|
900 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
901 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
902 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
903 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
904 |
+
/**/
|
905 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
906 |
+
/**/
|
907 |
+
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
|
908 |
+
/**/
|
909 |
+
wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", "Thank you! Your account has been updated.", get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", "Thank you! You've been updated to:\n" . $paypal["item_name"] . "\n\nPlease log back in now.\n" . wp_login_url (), 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");
|
910 |
+
/**/
|
911 |
+
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
912 |
+
/**/
|
913 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
914 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
|
915 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
916 |
+
}
|
917 |
+
else
|
918 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
919 |
+
}
|
920 |
+
else
|
921 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
922 |
+
/**/
|
923 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
924 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_modify", get_defined_vars ());
|
925 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
926 |
+
}
|
927 |
+
/*
|
928 |
+
Subscription payment notifications.
|
929 |
+
We need these to update: `s2member_last_payment_time`.
|
930 |
+
*/
|
931 |
+
else if (/**/(preg_match ("/^(subscr_payment|recurring_payment)$/i", $paypal["txn_type"]))/**/
|
932 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
|
933 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
|
934 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
|
935 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"])) /* Status OK? This goes thru a list of known status issues. */
|
936 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))/**/
|
937 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/
|
938 |
+
&& ($paypal["txn_id"] && $paypal["mc_gross"])/**/)
|
939 |
+
{
|
940 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
941 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
|
942 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
943 |
+
/**/
|
944 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment|recurring_payment.";
|
945 |
+
$paypal["s2member_log"][] = "Sleeping for 2 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
|
946 |
+
sleep (2); /* Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
|
947 |
+
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. */
|
948 |
+
$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.";
|
949 |
+
/**/
|
950 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
|
951 |
+
/**/
|
952 |
+
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)
|
953 |
+
{
|
954 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
955 |
+
/**/
|
956 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
957 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
958 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
959 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
960 |
+
/**/
|
961 |
+
update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Also update last payment time. */
|
962 |
+
/**/
|
963 |
+
$paypal["s2member_log"][] = "Updated Payment Times for this Member."; /* Flag this action in the log. */
|
964 |
+
/**/
|
965 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
|
966 |
+
/**/
|
967 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
968 |
+
{
|
969 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
970 |
+
/**/
|
971 |
+
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)))
|
972 |
+
if (($url = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["txn_id"])), $url)))
|
973 |
+
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)))
|
974 |
+
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)))
|
975 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
976 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
977 |
+
{
|
978 |
+
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)))
|
979 |
+
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)))
|
980 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
981 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
982 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
983 |
+
{
|
984 |
+
if (is_array ($fields) && !empty ($fields))
|
985 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
986 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
987 |
+
break;
|
988 |
+
/**/
|
989 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
990 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
991 |
+
}
|
992 |
+
}
|
993 |
+
/**/
|
994 |
+
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
995 |
+
}
|
996 |
+
/**/
|
997 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
998 |
+
{
|
999 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Payment";
|
1000 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
1001 |
+
/**/
|
1002 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
1003 |
+
$msg .= "amount: %%amount%%\n";
|
1004 |
+
$msg .= "txn_id: %%txn_id%%\n";
|
1005 |
+
$msg .= "item_number: %%item_number%%\n";
|
1006 |
+
$msg .= "item_name: %%item_name%%\n";
|
1007 |
+
$msg .= "first_name: %%first_name%%\n";
|
1008 |
+
$msg .= "last_name: %%last_name%%\n";
|
1009 |
+
$msg .= "full_name: %%full_name%%\n";
|
1010 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
1011 |
+
/**/
|
1012 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
1013 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
1014 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
1015 |
+
$msg .= "user_email: %%user_email%%\n";
|
1016 |
+
$msg .= "user_login: %%user_login%%\n";
|
1017 |
+
$msg .= "user_id: %%user_id%%\n";
|
1018 |
+
/**/
|
1019 |
+
if (is_array ($fields) && !empty ($fields))
|
1020 |
+
foreach ($fields as $var => $val)
|
1021 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
1022 |
+
/**/
|
1023 |
+
$msg .= "cv0: %%cv0%%\n";
|
1024 |
+
$msg .= "cv1: %%cv1%%\n";
|
1025 |
+
$msg .= "cv2: %%cv2%%\n";
|
1026 |
+
$msg .= "cv3: %%cv3%%\n";
|
1027 |
+
$msg .= "cv4: %%cv4%%\n";
|
1028 |
+
$msg .= "cv5: %%cv5%%\n";
|
1029 |
+
$msg .= "cv6: %%cv6%%\n";
|
1030 |
+
$msg .= "cv7: %%cv7%%\n";
|
1031 |
+
$msg .= "cv8: %%cv8%%\n";
|
1032 |
+
$msg .= "cv9: %%cv9%%";
|
1033 |
+
/**/
|
1034 |
+
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)))
|
1035 |
+
if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $msg)))
|
1036 |
+
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)))
|
1037 |
+
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)))
|
1038 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
1039 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
1040 |
+
{
|
1041 |
+
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)))
|
1042 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
1043 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
1044 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
1045 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
1046 |
+
{
|
1047 |
+
if (is_array ($fields) && !empty ($fields))
|
1048 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1049 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
1050 |
+
break;
|
1051 |
+
/**/
|
1052 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
1053 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
|
1054 |
+
($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;
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
/**/
|
1058 |
+
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
1059 |
+
}
|
1060 |
+
/**/
|
1061 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1062 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars ());
|
1063 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1064 |
+
}
|
1065 |
+
else /* Otherwise, we need to re-generate/store this IPN into a Transient Queue. Then re-process it on registration. */
|
1066 |
+
{
|
1067 |
+
$paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
|
1068 |
+
/**/
|
1069 |
+
$ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
|
1070 |
+
/**/
|
1071 |
+
foreach ($paypal as $var => $val)
|
1072 |
+
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")))
|
1073 |
+
$ipn[$var] = $val;
|
1074 |
+
/**/
|
1075 |
+
$paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and re-processed during registration.";
|
1076 |
+
/**/
|
1077 |
+
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
1078 |
+
}
|
1079 |
+
/**/
|
1080 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1081 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars ());
|
1082 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1083 |
+
}
|
1084 |
+
/*
|
1085 |
+
Subscription failed payment notifications.
|
1086 |
+
This is not really necessary. It is only here because this txn_type could
|
1087 |
+
be necessary in a future release of s2Member. For now, it's just a fill-in.
|
1088 |
+
These Hooks/Filters will remain, so you can use them now; if you need to.
|
1089 |
+
*/
|
1090 |
+
else if (/**/(preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i", $paypal["txn_type"]))/**/
|
1091 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
|
1092 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* Must match a Subscription. */
|
1093 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
|
1094 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))/**/
|
1095 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/)
|
1096 |
+
{
|
1097 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1098 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars ());
|
1099 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1100 |
+
/**/
|
1101 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_failed|recurring_payment_failed|recurring_payment_skipped.";
|
1102 |
+
/**/
|
1103 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1104 |
+
/**/
|
1105 |
+
$paypal["s2member_log"][] = "This txn_type does not require any action on the part of s2Member.";
|
1106 |
+
$paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
|
1107 |
+
$paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
|
1108 |
+
/**/
|
1109 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1110 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars ());
|
1111 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1112 |
+
/**/
|
1113 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1114 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars ());
|
1115 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1116 |
+
}
|
1117 |
+
/*
|
1118 |
+
Subscription cancellations. s2Member can use this, to determine when/if it should Auto-EOT (demote|delete) a Member's account.
|
1119 |
+
This processing routine for `subscr_cancel` is compatible with newer PayPal® accounts that do NOT send a subscr_eot after cancellation.
|
1120 |
+
This works in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
|
1121 |
+
For further details, see: https://www.x.com/thread/41155?start=15&tstart=0
|
1122 |
+
*/
|
1123 |
+
else if (/**/(preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i", $paypal["txn_type"]))/**/
|
1124 |
+
&& ! (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))
|
1125 |
+
/* ^^ Bypass this case ( for now ) "recurring_payment_profile_cancel" with an initial failed payment warrants an Immediate EOT instead. */
|
1126 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Got the item_number? */
|
1127 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This item_number must validate. */
|
1128 |
+
&& ($paypal["period1"] || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || ($paypal["period1"] = "0 D"))/**/
|
1129 |
+
&& ($paypal["period3"] || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal))) /* Must have a period3 value. */
|
1130 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal))) /* Must have this. */
|
1131 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal))) /* Must have this. */
|
1132 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/)
|
1133 |
+
{
|
1134 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1135 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", get_defined_vars ());
|
1136 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1137 |
+
/**/
|
1138 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_cancel|recurring_payment_profile_cancel.";
|
1139 |
+
/**/
|
1140 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
|
1141 |
+
/**/
|
1142 |
+
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)
|
1143 |
+
{
|
1144 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
1145 |
+
{
|
1146 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
1147 |
+
/**/
|
1148 |
+
if (!get_user_option ("s2member_auto_eot_time", $user_id)) /* Respect existing. */
|
1149 |
+
{
|
1150 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1151 |
+
/**/
|
1152 |
+
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
|
1153 |
+
/**/
|
1154 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); /* s2Member follows-up later. */
|
1155 |
+
/**/
|
1156 |
+
$paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date ("D M j, Y g:i a T", $auto_eot_time);
|
1157 |
+
/**/
|
1158 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1159 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars ());
|
1160 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1161 |
+
}
|
1162 |
+
else
|
1163 |
+
$paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
|
1164 |
+
/**/
|
1165 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1166 |
+
{
|
1167 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) /* Handle Cancellation Notifications. */
|
1168 |
+
/**/
|
1169 |
+
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)))
|
1170 |
+
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)))
|
1171 |
+
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)))
|
1172 |
+
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)))
|
1173 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
1174 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
1175 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
1176 |
+
{
|
1177 |
+
if (is_array ($fields) && !empty ($fields))
|
1178 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1179 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
1180 |
+
break;
|
1181 |
+
/**/
|
1182 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
1183 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
1184 |
+
}
|
1185 |
+
/**/
|
1186 |
+
$paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
|
1187 |
+
}
|
1188 |
+
/**/
|
1189 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1190 |
+
{
|
1191 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Cancellation";
|
1192 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
1193 |
+
/**/
|
1194 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
1195 |
+
$msg .= "item_number: %%item_number%%\n";
|
1196 |
+
$msg .= "item_name: %%item_name%%\n";
|
1197 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
1198 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
1199 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
1200 |
+
$msg .= "user_email: %%user_email%%\n";
|
1201 |
+
$msg .= "user_login: %%user_login%%\n";
|
1202 |
+
$msg .= "user_id: %%user_id%%\n";
|
1203 |
+
/**/
|
1204 |
+
if (is_array ($fields) && !empty ($fields))
|
1205 |
+
foreach ($fields as $var => $val)
|
1206 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
1207 |
+
/**/
|
1208 |
+
$msg .= "cv0: %%cv0%%\n";
|
1209 |
+
$msg .= "cv1: %%cv1%%\n";
|
1210 |
+
$msg .= "cv2: %%cv2%%\n";
|
1211 |
+
$msg .= "cv3: %%cv3%%\n";
|
1212 |
+
$msg .= "cv4: %%cv4%%\n";
|
1213 |
+
$msg .= "cv5: %%cv5%%\n";
|
1214 |
+
$msg .= "cv6: %%cv6%%\n";
|
1215 |
+
$msg .= "cv7: %%cv7%%\n";
|
1216 |
+
$msg .= "cv8: %%cv8%%\n";
|
1217 |
+
$msg .= "cv9: %%cv9%%";
|
1218 |
+
/**/
|
1219 |
+
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)))
|
1220 |
+
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)))
|
1221 |
+
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)))
|
1222 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
1223 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
1224 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
1225 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
1226 |
+
{
|
1227 |
+
if (is_array ($fields) && !empty ($fields))
|
1228 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1229 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
1230 |
+
break;
|
1231 |
+
/**/
|
1232 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
1233 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"])) as $recipient)
|
1234 |
+
($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;
|
1235 |
+
}
|
1236 |
+
/**/
|
1237 |
+
$paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
+
else
|
1241 |
+
$paypal["s2member_log"][] = "Ignoring Cancellation. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
1242 |
+
}
|
1243 |
+
else
|
1244 |
+
$paypal["s2member_log"][] = "Unable to handle Cancellation. Could not get the existing User ID from the DB.";
|
1245 |
+
/**/
|
1246 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1247 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_cancel", get_defined_vars ());
|
1248 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1249 |
+
}
|
1250 |
+
/*
|
1251 |
+
Subscription terminations, max failed payments, initial payment failed, chargebacks, refunds, and reversals.
|
1252 |
+
An immediate EOT is necessary under MANY different conditions. However, in some cases, a delayed EOT is required.
|
1253 |
+
Delayed EOTs work in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
|
1254 |
+
|
1255 |
+
~ NOTE: newer PayPal® accounts ( i.e. Billing Profiles that start with "I-" ), will trigger a "subscr_eot" upon last payment.
|
1256 |
+
So those are treated as delayed EOTs - ( s2Member was updated at v3.2.3 to deal with this scenario gracefully ).
|
1257 |
+
In the case of "subscr_eot" with "I-", s2Member calculates the EOT Time, and records it for future processing.
|
1258 |
+
|
1259 |
+
~ NOTE: "new_case" with "case_type=chargeback" is NOT actually processed. It's only been integrated for the future compatibility.
|
1260 |
+
At this time, PayPal® doesn't send enough information through "new_case" transactions for s2Member to process anything.
|
1261 |
+
However, that's OK. Refunds and Reversals ( i.e. chargebacks ) are still detected through "payment_status".
|
1262 |
+
|
1263 |
+
~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine.
|
1264 |
+
( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
|
1265 |
+
HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
|
1266 |
+
practice it never seems to happen. It's best to check the negative mc_gross amount instead.
|
1267 |
+
*/
|
1268 |
+
else if (/**/( /* Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine. */
|
1269 |
+
(preg_match ("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i", $paypal["txn_type"]) && ($recurring = 1))/**/
|
1270 |
+
|| (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]) && ($recurring = 1))/**/
|
1271 |
+
|| (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* ONLY for future compatibility. */
|
1272 |
+
|| (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
|
1273 |
+
&& ($paypal["period1"] || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || !$recurring || ($paypal["period1"] = "0 D"))/**/
|
1274 |
+
&& ($paypal["period3"] || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal)) || !$recurring) /* Was it even recurring? */
|
1275 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* A valid item_number? */
|
1276 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* Only "Membership Access". NOT for Specific Posts/Pages. */
|
1277 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)) || ($paypal["subscr_id"] = $paypal["parent_txn_id"]))/**/
|
1278 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))/**/
|
1279 |
+
/* 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. */
|
1280 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/)
|
1281 |
+
{
|
1282 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1283 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars ());
|
1284 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1285 |
+
/**/
|
1286 |
+
$is_refund = (preg_match ("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
1287 |
+
$is_reversal = (preg_match ("/^(reversed|reversal)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
1288 |
+
$is_reversal = (!$is_reversal) ? (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) : $is_reversal;
|
1289 |
+
$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. */
|
1290 |
+
$is_delayed_eot = (preg_match ("/^(subscr_eot|recurring_payment_expired)$/i", $paypal["txn_type"]) && preg_match ("/^I-/i", $paypal["subscr_id"]));
|
1291 |
+
/**/
|
1292 |
+
if ($is_refund_or_reversal)
|
1293 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
|
1294 |
+
else
|
1295 |
+
$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).";
|
1296 |
+
/**/
|
1297 |
+
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)
|
1298 |
+
{
|
1299 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed below. */
|
1300 |
+
/**/
|
1301 |
+
if ( /* Here we take action, BUT based on Auto EOT Behavior options; as configured by the Site Owner. */
|
1302 |
+
(!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))/**/
|
1303 |
+
|| ($is_refund_or_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals")/**/
|
1304 |
+
|| ($is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals")/**/
|
1305 |
+
|| ($is_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds")/**/)
|
1306 |
+
{
|
1307 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
1308 |
+
{
|
1309 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* EOT enabled? */
|
1310 |
+
{
|
1311 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
1312 |
+
{
|
1313 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1314 |
+
/**/
|
1315 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1316 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars ());
|
1317 |
+
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "ipn-refund-reversal-demotion");
|
1318 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1319 |
+
/**/
|
1320 |
+
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
|
1321 |
+
$existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
1322 |
+
/**/
|
1323 |
+
if ($existing_role !== $demotion_role) /* Only if NOT the existing Role. */
|
1324 |
+
$user->set_role ($demotion_role); /* Give User the demotion Role. */
|
1325 |
+
/**/
|
1326 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
1327 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
1328 |
+
$user->remove_cap ($ccap = $cap);
|
1329 |
+
/**/
|
1330 |
+
delete_user_option ($user_id, "s2member_custom");
|
1331 |
+
delete_user_option ($user_id, "s2member_subscr_id");
|
1332 |
+
delete_user_option ($user_id, "s2member_subscr_gateway");
|
1333 |
+
/**/
|
1334 |
+
delete_user_option ($user_id, "s2member_ipn_signup_vars");
|
1335 |
+
/**/
|
1336 |
+
if (!apply_filters ("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars ()))
|
1337 |
+
delete_user_option ($user_id, "s2member_paid_registration_times");
|
1338 |
+
/**/
|
1339 |
+
delete_user_option ($user_id, "s2member_last_status_scan");
|
1340 |
+
delete_user_option ($user_id, "s2member_last_payment_time");
|
1341 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
1342 |
+
/**/
|
1343 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
1344 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
1345 |
+
/**/
|
1346 |
+
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
1347 |
+
/**/
|
1348 |
+
$paypal["s2member_log"][] = "Member Level/Capabilities demoted to: " . ucwords (preg_replace ("/_/", " ", $demotion_role)) . ".";
|
1349 |
+
/**/
|
1350 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1351 |
+
{
|
1352 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
|
1353 |
+
/**/
|
1354 |
+
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)))
|
1355 |
+
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)))
|
1356 |
+
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)))
|
1357 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
1358 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
1359 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
1360 |
+
{
|
1361 |
+
if (is_array ($fields) && !empty ($fields))
|
1362 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1363 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
1364 |
+
break;
|
1365 |
+
/**/
|
1366 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
1367 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
1368 |
+
}
|
1369 |
+
/**/
|
1370 |
+
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
1371 |
+
}
|
1372 |
+
/**/
|
1373 |
+
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1374 |
+
{
|
1375 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
|
1376 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
1377 |
+
/**/
|
1378 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
1379 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
1380 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
1381 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
1382 |
+
$msg .= "user_email: %%user_email%%\n";
|
1383 |
+
$msg .= "user_login: %%user_login%%\n";
|
1384 |
+
$msg .= "user_id: %%user_id%%\n";
|
1385 |
+
/**/
|
1386 |
+
if (is_array ($fields) && !empty ($fields))
|
1387 |
+
foreach ($fields as $var => $val)
|
1388 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
1389 |
+
/**/
|
1390 |
+
$msg .= "cv0: %%cv0%%\n";
|
1391 |
+
$msg .= "cv1: %%cv1%%\n";
|
1392 |
+
$msg .= "cv2: %%cv2%%\n";
|
1393 |
+
$msg .= "cv3: %%cv3%%\n";
|
1394 |
+
$msg .= "cv4: %%cv4%%\n";
|
1395 |
+
$msg .= "cv5: %%cv5%%\n";
|
1396 |
+
$msg .= "cv6: %%cv6%%\n";
|
1397 |
+
$msg .= "cv7: %%cv7%%\n";
|
1398 |
+
$msg .= "cv8: %%cv8%%\n";
|
1399 |
+
$msg .= "cv9: %%cv9%%";
|
1400 |
+
/**/
|
1401 |
+
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)))
|
1402 |
+
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)))
|
1403 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
1404 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
1405 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
1406 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
1407 |
+
{
|
1408 |
+
if (is_array ($fields) && !empty ($fields))
|
1409 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1410 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
1411 |
+
break;
|
1412 |
+
/**/
|
1413 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
1414 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
|
1415 |
+
($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;
|
1416 |
+
}
|
1417 |
+
/**/
|
1418 |
+
$paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
|
1419 |
+
}
|
1420 |
+
/**/
|
1421 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1422 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_demote", get_defined_vars ());
|
1423 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1424 |
+
}
|
1425 |
+
/**/
|
1426 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
1427 |
+
{
|
1428 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1429 |
+
/**/
|
1430 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1431 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_delete", get_defined_vars ());
|
1432 |
+
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "ipn-refund-reversal-deletion");
|
1433 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1434 |
+
/**/
|
1435 |
+
if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
|
1436 |
+
{
|
1437 |
+
remove_user_from_blog ($user_id, $current_blog->blog_id);
|
1438 |
+
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
1439 |
+
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
|
1440 |
+
}
|
1441 |
+
/**/
|
1442 |
+
else /* Otherwise, we can actually delete them. */
|
1443 |
+
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
1444 |
+
wp_delete_user($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
|
1445 |
+
/**/
|
1446 |
+
$paypal["s2member_log"][] = "This Member's account has been " . ( (is_multisite ()) ? "removed" : "deleted") . ".";
|
1447 |
+
/**/
|
1448 |
+
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
1449 |
+
/**/
|
1450 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1451 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delete", get_defined_vars ());
|
1452 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1453 |
+
}
|
1454 |
+
/**/
|
1455 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1456 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot", get_defined_vars ());
|
1457 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1458 |
+
}
|
1459 |
+
/**/
|
1460 |
+
else /* Otherwise, treat this as if it were a cancellation. EOTs are currently disabled. */
|
1461 |
+
{
|
1462 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1463 |
+
/**/
|
1464 |
+
update_user_option ($user_id, "s2member_auto_eot_time", ($auto_eot_time = strtotime ("now")));
|
1465 |
+
/**/
|
1466 |
+
$paypal["s2member_log"][] = "Auto-EOT is currently disabled. Skipping immediate EOT (demote|delete), for now.";
|
1467 |
+
$paypal["s2member_log"][] = "Recording the Auto-EOT Time for this Member's account: " . date ("D M j, Y g:i a T", $auto_eot_time);
|
1468 |
+
/**/
|
1469 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1470 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_disabled", get_defined_vars ());
|
1471 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1472 |
+
}
|
1473 |
+
}
|
1474 |
+
else
|
1475 |
+
$paypal["s2member_log"][] = "Unable to (demote|delete) Member. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
1476 |
+
}
|
1477 |
+
/**/
|
1478 |
+
else if ($is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))
|
1479 |
+
{
|
1480 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
1481 |
+
{
|
1482 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1483 |
+
/**/
|
1484 |
+
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"], "", time ());
|
1485 |
+
/* We assume the last payment was today, because this is how newer PayPal® accounts function with respect to EOT handling.
|
1486 |
+
Newer PayPal® accounts ( i.e. Subscription IDs starting with `I-`, will have their EOT triggered upon the last payment. */
|
1487 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); /* s2Member will follow-up on this later. */
|
1488 |
+
/**/
|
1489 |
+
$paypal["s2member_log"][] = "Auto-EOT Time for this account ( delayed ), set to: " . date ("D M j, Y g:i a T", $auto_eot_time);
|
1490 |
+
/**/
|
1491 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1492 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delayed", get_defined_vars ());
|
1493 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1494 |
+
}
|
1495 |
+
else
|
1496 |
+
$paypal["s2member_log"][] = "Ignoring Delayed EOT. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
1497 |
+
}
|
1498 |
+
/**/
|
1499 |
+
else if (!$is_refund_or_reversal || $is_delayed_eot)
|
1500 |
+
$paypal["s2member_log"][] = "Skipping (demote|delete) Member, for now. An Auto-EOT Time is already set for this account. When an Auto-EOT Time has been recorded, s2Member will handle EOT (demote|delete) events using it's own Auto-EOT System - internally.";
|
1501 |
+
/**/
|
1502 |
+
else if ($is_reversal)
|
1503 |
+
$paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Chargeback Reversal. An s2Member API Notification will still be processed however.";
|
1504 |
+
/**/
|
1505 |
+
else if ($is_refund)
|
1506 |
+
$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.";
|
1507 |
+
}
|
1508 |
+
else
|
1509 |
+
$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.";
|
1510 |
+
/*
|
1511 |
+
Refunds and chargeback reversals. This is excluded from the processing check, because a Member *could* have already been (demoted|deleted).
|
1512 |
+
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
1513 |
+
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
|
1514 |
+
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
|
1515 |
+
*/
|
1516 |
+
if ($is_refund_or_reversal) /* Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection. */
|
1517 |
+
{
|
1518 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1519 |
+
{
|
1520 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
|
1521 |
+
/**/
|
1522 |
+
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)) && ($url = preg_replace ("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["parent_txn_id"])), $url)))
|
1523 |
+
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)))
|
1524 |
+
if (($url = preg_replace ("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_fee"])), $url)))
|
1525 |
+
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)))
|
1526 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
1527 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
1528 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
1529 |
+
{
|
1530 |
+
if (is_array ($fields) && !empty ($fields))
|
1531 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1532 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
1533 |
+
break;
|
1534 |
+
/**/
|
1535 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
1536 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
1537 |
+
}
|
1538 |
+
/**/
|
1539 |
+
$paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
|
1540 |
+
}
|
1541 |
+
/**/
|
1542 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1543 |
+
{
|
1544 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Refund/Reversal";
|
1545 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
1546 |
+
/**/
|
1547 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
1548 |
+
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
1549 |
+
$msg .= "item_number: %%item_number%%\n";
|
1550 |
+
$msg .= "item_name: %%item_name%%\n";
|
1551 |
+
$msg .= "-amount: %%-amount%%\n";
|
1552 |
+
$msg .= "-fee: %%-fee%%\n";
|
1553 |
+
$msg .= "first_name: %%first_name%%\n";
|
1554 |
+
$msg .= "last_name: %%last_name%%\n";
|
1555 |
+
$msg .= "full_name: %%full_name%%\n";
|
1556 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
1557 |
+
$msg .= "user_id: %%user_id%%\n";
|
1558 |
+
/**/
|
1559 |
+
if (is_array ($fields) && !empty ($fields))
|
1560 |
+
foreach ($fields as $var => $val)
|
1561 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
1562 |
+
/**/
|
1563 |
+
$msg .= "cv0: %%cv0%%\n";
|
1564 |
+
$msg .= "cv1: %%cv1%%\n";
|
1565 |
+
$msg .= "cv2: %%cv2%%\n";
|
1566 |
+
$msg .= "cv3: %%cv3%%\n";
|
1567 |
+
$msg .= "cv4: %%cv4%%\n";
|
1568 |
+
$msg .= "cv5: %%cv5%%\n";
|
1569 |
+
$msg .= "cv6: %%cv6%%\n";
|
1570 |
+
$msg .= "cv7: %%cv7%%\n";
|
1571 |
+
$msg .= "cv8: %%cv8%%\n";
|
1572 |
+
$msg .= "cv9: %%cv9%%";
|
1573 |
+
/**/
|
1574 |
+
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)) && ($msg = preg_replace ("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["parent_txn_id"]), $msg)))
|
1575 |
+
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)))
|
1576 |
+
if (($msg = preg_replace ("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_fee"]), $msg)))
|
1577 |
+
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)))
|
1578 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
1579 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
1580 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
1581 |
+
{
|
1582 |
+
if (is_array ($fields) && !empty ($fields))
|
1583 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
1584 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
1585 |
+
break;
|
1586 |
+
/**/
|
1587 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
1588 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"])) as $recipient)
|
1589 |
+
($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;
|
1590 |
+
}
|
1591 |
+
/**/
|
1592 |
+
$paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
|
1593 |
+
}
|
1594 |
+
/**/
|
1595 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1596 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_refund_reversal", get_defined_vars ());
|
1597 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1598 |
+
}
|
1599 |
+
/**/
|
1600 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1601 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_eot", get_defined_vars ());
|
1602 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1603 |
+
}
|
1604 |
+
/*
|
1605 |
+
Refunds/Reversals for Specific Post/Page Access.
|
1606 |
+
These are handled separately.
|
1607 |
+
|
1608 |
+
~ NOTE: "new_case" with "case_type=chargeback" is NOT actually processed. It's only been integrated for the future compatibility.
|
1609 |
+
At this time, PayPal® doesn't send enough information through "new_case" transactions for s2Member to process anything.
|
1610 |
+
However, that's OK. Refunds and Reversals ( i.e. chargebacks ) are still detected through "payment_status".
|
1611 |
+
|
1612 |
+
~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded ) is NOT processed by this routine, or any other s2Member routine.
|
1613 |
+
( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
|
1614 |
+
HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
|
1615 |
+
practice it never seems to happen. It's best to check the negative mc_gross amount instead.
|
1616 |
+
*/
|
1617 |
+
else if (/**/(/**/ (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* Future compatibility. */
|
1618 |
+
|| (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
|
1619 |
+
&& ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Required. */
|
1620 |
+
&& (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])) /* Only for "Specific Post/Page Access" here. NOT for Membership. */
|
1621 |
+
&& ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal))) /* ? */
|
1622 |
+
&& ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/
|
1623 |
+
&& ($paypal["parent_txn_id"])/**/)
|
1624 |
+
{
|
1625 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1626 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
|
1627 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1628 |
+
/**/
|
1629 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
|
1630 |
+
/**/
|
1631 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
1632 |
+
/*
|
1633 |
+
Refunds and chargeback reversals. This is excluded from the processing check.
|
1634 |
+
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
1635 |
+
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
|
1636 |
+
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
|
1637 |
+
*/
|
1638 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1639 |
+
{
|
1640 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url)
|
1641 |
+
/**/
|
1642 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["parent_txn_id"])), $url)))
|
1643 |
+
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)))
|
1644 |
+
if (($url = preg_replace ("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_fee"])), $url)))
|
1645 |
+
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)))
|
1646 |
+
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
1647 |
+
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
1648 |
+
/**/
|
1649 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
1650 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
1651 |
+
/**/
|
1652 |
+
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
|
1653 |
+
}
|
1654 |
+
/**/
|
1655 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
1656 |
+
{
|
1657 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Specific Post/Page ~ Refund/Reversal";
|
1658 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
1659 |
+
/**/
|
1660 |
+
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
1661 |
+
$msg .= "item_number: %%item_number%%\n";
|
1662 |
+
$msg .= "item_name: %%item_name%%\n";
|
1663 |
+
$msg .= "-amount: %%-amount%%\n";
|
1664 |
+
$msg .= "-fee: %%-fee%%\n";
|
1665 |
+
$msg .= "first_name: %%first_name%%\n";
|
1666 |
+
$msg .= "last_name: %%last_name%%\n";
|
1667 |
+
$msg .= "full_name: %%full_name%%\n";
|
1668 |
+
$msg .= "payer_email: %%payer_email%%\n";
|
1669 |
+
$msg .= "cv0: %%cv0%%\n";
|
1670 |
+
$msg .= "cv1: %%cv1%%\n";
|
1671 |
+
$msg .= "cv2: %%cv2%%\n";
|
1672 |
+
$msg .= "cv3: %%cv3%%\n";
|
1673 |
+
$msg .= "cv4: %%cv4%%\n";
|
1674 |
+
$msg .= "cv5: %%cv5%%\n";
|
1675 |
+
$msg .= "cv6: %%cv6%%\n";
|
1676 |
+
$msg .= "cv7: %%cv7%%\n";
|
1677 |
+
$msg .= "cv8: %%cv8%%\n";
|
1678 |
+
$msg .= "cv9: %%cv9%%";
|
1679 |
+
/**/
|
1680 |
+
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["parent_txn_id"]), $msg)))
|
1681 |
+
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)))
|
1682 |
+
if (($msg = preg_replace ("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_fee"]), $msg)))
|
1683 |
+
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)))
|
1684 |
+
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
1685 |
+
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
1686 |
+
/**/
|
1687 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
1688 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"])) as $recipient)
|
1689 |
+
($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;
|
1690 |
+
/**/
|
1691 |
+
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
|
1692 |
+
}
|
1693 |
+
/**/
|
1694 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1695 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_refund_reversal", get_defined_vars ());
|
1696 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1697 |
+
/**/
|
1698 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1699 |
+
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_refund_reversal", get_defined_vars ());
|
1700 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1701 |
+
}
|
1702 |
+
else
|
1703 |
+
$paypal["s2member_log"][] = "Ignoring this IPN request. The txn_type/status does NOT require any action on the part of s2Member.";
|
1704 |
+
}
|
1705 |
+
else /* Else a custom conditional has been applied by Filters. */
|
1706 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1707 |
+
}
|
1708 |
+
/*
|
1709 |
+
Else, check on cancelled recurring profiles.
|
1710 |
+
*/
|
1711 |
+
else if (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
|
1712 |
+
{
|
1713 |
+
$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.";
|
1714 |
+
$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.";
|
1715 |
+
}
|
1716 |
+
/*
|
1717 |
+
Else, check on other ^recurring_ transaction types.
|
1718 |
+
*/
|
1719 |
+
else if (preg_match ("/^recurring_/i", $paypal["txn_type"])) /* Otherwise, is this a ^recurring_ txn_type? */
|
1720 |
+
$paypal["s2member_log"][] = "Transaction type ( ^recurring_? ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
|
1721 |
+
/**/
|
1722 |
+
else /* Else, use the default _SERVER[HTTP_HOST] error. */
|
1723 |
+
$paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Possibly caused by a fraudulent request. If this error continues, please check the `custom` value in your Form and/or Button Code. It MUST always start with your domain name.";
|
1724 |
+
}
|
1725 |
+
/**/
|
1726 |
+
else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
|
1727 |
+
{
|
1728 |
+
$paypal["s2member_log"][] = "Unable to verify POST vars. Possibly caused by a fraudulent request. If this error continues, please run IPN tests against your server from a PayPal® Sandbox account. They provide special diagnostic tools to assist you.";
|
1729 |
+
$paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
|
1730 |
+
$paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
|
1731 |
+
$paypal["s2member_log"][] = var_export ($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */
|
1732 |
+
}
|
1733 |
+
/*
|
1734 |
+
Add IPN proxy ( when available ) to the $paypal array.
|
1735 |
+
*/
|
1736 |
+
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
|
1737 |
+
$paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
|
1738 |
+
/*
|
1739 |
+
Add IPN proxy use vars ( when available ) to the $paypal array.
|
1740 |
+
*/
|
1741 |
+
if ($_GET["s2member_paypal_proxy_use"]) /* For proxy specifications. */
|
1742 |
+
$paypal["s2member_paypal_proxy_use"] = $_GET["s2member_paypal_proxy_use"];
|
1743 |
+
/*
|
1744 |
+
Also add IPN proxy self-verification ( when available ) to the $paypal array.
|
1745 |
+
*/
|
1746 |
+
if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
|
1747 |
+
$paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
|
1748 |
+
/*
|
1749 |
+
If debugging/logging is enabled; we need to append $paypal to the log file.
|
1750 |
+
Logging now supports Multisite Networking as well.
|
1751 |
+
*/
|
1752 |
+
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
1753 |
+
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
1754 |
+
$log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
|
1755 |
+
/**/
|
1756 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
1757 |
+
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
1758 |
+
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
1759 |
+
file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
|
1760 |
+
/**/
|
1761 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1762 |
+
do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
|
1763 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1764 |
+
/**/
|
1765 |
+
header ("HTTP/1.0 200 OK"); /* Send a 200 OK status header. */
|
1766 |
+
exit ($paypal["s2member_paypal_proxy_return_url"]); /* Return. */
|
1767 |
+
}
|
1768 |
+
/**/
|
1769 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
1770 |
+
do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
|
1771 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
1772 |
+
}
|
1773 |
+
}
|
1774 |
+
}
|
1775 |
+
?>
|
includes/classes/paypal-notify.inc.php
ADDED
@@ -0,0 +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_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 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
?>
|
includes/classes/paypal-return-in.inc.php
ADDED
@@ -0,0 +1,518 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
27 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
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 " . /* Indicate Proxy Key. */
|
37 |
+
( ($postvars["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
38 |
+
/**/
|
39 |
+
$paypal["subscr_gateway"] = ($_GET["s2member_paypal_proxy"]) ? $_GET["s2member_paypal_proxy"] : "paypal";
|
40 |
+
/**/
|
41 |
+
if (!$_GET["s2member_paypal_proxy"] || !preg_match ("/ty-email/", $_GET["s2member_paypal_proxy_use"]))
|
42 |
+
{
|
43 |
+
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
44 |
+
/**/
|
45 |
+
if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
46 |
+
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
|
47 |
+
email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
|
48 |
+
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
|
49 |
+
/*
|
50 |
+
Custom conditionals can be applied by filters.
|
51 |
+
*/
|
52 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
53 |
+
if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
|
54 |
+
{
|
55 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
56 |
+
/*
|
57 |
+
Specific Post/Page Access ~ Sales.
|
58 |
+
*/
|
59 |
+
if (/**/(preg_match ("/^web_accept$/i", $paypal["txn_type"]))/**/
|
60 |
+
&& (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"]))/**/
|
61 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
|
62 |
+
&& ($paypal["txn_id"])/**/)
|
63 |
+
{
|
64 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
65 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
|
66 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
67 |
+
/**/
|
68 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page Access.";
|
69 |
+
/**/
|
70 |
+
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
71 |
+
/**/
|
72 |
+
if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
|
73 |
+
{
|
74 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
75 |
+
/**/
|
76 |
+
setcookie ("s2member_sp_tracking", c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["txn_id"]), time () + 31556926, "/");
|
77 |
+
/**/
|
78 |
+
$paypal["s2member_log"][] = "Transient Tracking Cookie set on (web_accept) for Specific Post/Page Access.";
|
79 |
+
/**/
|
80 |
+
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
81 |
+
{
|
82 |
+
if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $code)))
|
83 |
+
if (($code = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $code)))
|
84 |
+
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)))
|
85 |
+
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
86 |
+
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
87 |
+
/**/
|
88 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
|
89 |
+
{
|
90 |
+
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
91 |
+
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
/**/
|
95 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
96 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
|
97 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
98 |
+
/**/
|
99 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
|
100 |
+
/**/
|
101 |
+
wp_redirect ($sp_access_url); /* Redirect Customer immediately. */
|
102 |
+
}
|
103 |
+
else /* Otherwise, the ID must have been invalid. Or the Post/Page was deleted. */
|
104 |
+
{
|
105 |
+
$paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?";
|
106 |
+
/**/
|
107 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
|
108 |
+
/**/
|
109 |
+
echo '<script type="text/javascript">' . "\n";
|
110 |
+
echo "alert('ERROR: Unable to generate Access Link. Please contact Support for assistance.');" . "\n";
|
111 |
+
echo "window.location = '" . esc_js (home_url ("/")) . "';";
|
112 |
+
echo '</script>' . "\n";
|
113 |
+
}
|
114 |
+
/**/
|
115 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
116 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
|
117 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
118 |
+
}
|
119 |
+
/*
|
120 |
+
New Subscriptions.
|
121 |
+
Possibly containing advanced update vars
|
122 |
+
( option_name1, option_selection1 ); which allow account modifications.
|
123 |
+
|
124 |
+
With Auto-Return URLs via PDT, PayPal® will send subscr_payment instead of subscr_signup.
|
125 |
+
So we need to look for (web_accept|subscr_signup|subscr_payment), and treat the same.
|
126 |
+
*/
|
127 |
+
else if (/**/(preg_match ("/^(web_accept|subscr_signup|subscr_payment)$/i", $paypal["txn_type"]))/**/
|
128 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
|
129 |
+
&& ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
|
130 |
+
&& (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/)
|
131 |
+
{
|
132 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
133 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars ());
|
134 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
135 |
+
/**/
|
136 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
|
137 |
+
/**/
|
138 |
+
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
139 |
+
/*
|
140 |
+
New Subscription with advanced update vars ( option_name1, option_selection1 ).
|
141 |
+
*/
|
142 |
+
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced Subscription update modifications. */
|
143 |
+
/* 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
|
144 |
+
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. */
|
145 |
+
{
|
146 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
147 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars ());
|
148 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
149 |
+
/**/
|
150 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/ update vars.";
|
151 |
+
/**/
|
152 |
+
/* Check for both the old & new subscr_id's, just in case the IPN routine already changed it. */
|
153 |
+
if (($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)
|
154 |
+
{
|
155 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
156 |
+
{
|
157 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
158 |
+
/**/
|
159 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
160 |
+
{
|
161 |
+
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
162 |
+
$user = new WP_User ($user_id);
|
163 |
+
}
|
164 |
+
/**/
|
165 |
+
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
166 |
+
/**/
|
167 |
+
if ($current_role !== "s2member_level" . $paypal["level"]) /* Only if we need to. */
|
168 |
+
$user->set_role ("s2member_level" . $paypal["level"]); /* (upgrade/downgrade) */
|
169 |
+
/**/
|
170 |
+
if (!preg_match ("/^\+/", $paypal["ccaps"]))
|
171 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
172 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
173 |
+
$user->remove_cap ($ccap = $cap);
|
174 |
+
/**/
|
175 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($paypal["ccaps"], "+")) as $ccap)
|
176 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
177 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
178 |
+
/**/
|
179 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
180 |
+
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
181 |
+
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
182 |
+
/**/
|
183 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
184 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
185 |
+
/**/
|
186 |
+
if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
187 |
+
update_user_option ($user_id, "s2member_auto_eot_time", c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"]));
|
188 |
+
else /* Otherwise, we need to clear the Auto-EOT Time. */
|
189 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
190 |
+
/**/
|
191 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
192 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
193 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
194 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
195 |
+
/**/
|
196 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
197 |
+
/**/
|
198 |
+
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
199 |
+
/**/
|
200 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
201 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars ());
|
202 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
203 |
+
/**/
|
204 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
|
205 |
+
/**/
|
206 |
+
echo '<script type="text/javascript">' . "\n";
|
207 |
+
echo "alert('Thank you! You\\'ve been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nPlease log back in now.');" . "\n";
|
208 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';" . "\n";
|
209 |
+
echo '</script>' . "\n";
|
210 |
+
}
|
211 |
+
else
|
212 |
+
{
|
213 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
214 |
+
/**/
|
215 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
216 |
+
/**/
|
217 |
+
echo '<script type="text/javascript">' . "\n";
|
218 |
+
echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
|
219 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
220 |
+
echo '</script>' . "\n";
|
221 |
+
}
|
222 |
+
}
|
223 |
+
else
|
224 |
+
{
|
225 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
|
226 |
+
/**/
|
227 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
228 |
+
/**/
|
229 |
+
echo '<script type="text/javascript">' . "\n";
|
230 |
+
echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
|
231 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
232 |
+
echo '</script>' . "\n";
|
233 |
+
}
|
234 |
+
/**/
|
235 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
236 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars ());
|
237 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
238 |
+
}
|
239 |
+
/*
|
240 |
+
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
241 |
+
*/
|
242 |
+
else /* Else this is a normal Subscription signup, we are not updating an existing Subscription. */
|
243 |
+
{
|
244 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
245 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars ());
|
246 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
247 |
+
/**/
|
248 |
+
$processing = $during = true; /* Yes, we ARE processing this new Subscription request. */
|
249 |
+
/**/
|
250 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
|
251 |
+
/**/
|
252 |
+
setcookie ("s2member_subscr_gateway", c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["subscr_gateway"]), time () + 31556926, "/");
|
253 |
+
setcookie ("s2member_subscr_id", c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["subscr_id"]), time () + 31556926, "/");
|
254 |
+
setcookie ("s2member_custom", c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["custom"]), time () + 31556926, "/");
|
255 |
+
setcookie ("s2member_level", c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["item_number"]), time () + 31556926, "/");
|
256 |
+
/**/
|
257 |
+
$paypal["s2member_log"][] = "Registration Cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
|
258 |
+
/**/
|
259 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
260 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars ());
|
261 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
262 |
+
/**/
|
263 |
+
$paypal["s2member_log"][] = "Redirecting Customer to Registration Page. They need to Register now.";
|
264 |
+
/**/
|
265 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ())
|
266 |
+
{
|
267 |
+
echo '<script type="text/javascript">' . "\n";
|
268 |
+
echo "alert('Thank you! Your account has been approved.\\nThe next step is to Register.\\n\\nPlease click OK to Register now.');" . "\n";/**/
|
269 |
+
echo "window.location = '" . esc_js (c_ws_plugin__s2member_utils_urls::wp_signup_url ()) . "';" . "\n";
|
270 |
+
echo '</script>' . "\n";
|
271 |
+
}
|
272 |
+
else /* Otherwise, this is NOT a Multisite install. Or it is, but the Super Administrator is NOT selling Blog creation. */
|
273 |
+
{
|
274 |
+
echo '<script type="text/javascript">' . "\n";
|
275 |
+
echo "alert('Thank you! Your account has been approved.\\nThe next step is to Register a Username.\\n\\nPlease click OK to Register now.');" . "\n";/**/
|
276 |
+
echo "window.location = '" . esc_js (c_ws_plugin__s2member_utils_urls::wp_register_url ()) . "';" . "\n";
|
277 |
+
echo '</script>' . "\n";
|
278 |
+
}
|
279 |
+
/**/
|
280 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
281 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars ());
|
282 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
283 |
+
}
|
284 |
+
/**/
|
285 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
286 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars ());
|
287 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
288 |
+
}
|
289 |
+
/*
|
290 |
+
Subscription modifications.
|
291 |
+
*/
|
292 |
+
else if (/**/(preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))/**/
|
293 |
+
&& (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
|
294 |
+
&& ($paypal["subscr_id"])/**/)
|
295 |
+
{
|
296 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
297 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars ());
|
298 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
299 |
+
/**/
|
300 |
+
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
|
301 |
+
/**/
|
302 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
|
303 |
+
/**/
|
304 |
+
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)
|
305 |
+
{
|
306 |
+
if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
|
307 |
+
{
|
308 |
+
$processing = $during = true; /* Yes, we ARE processing this. */
|
309 |
+
/**/
|
310 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
311 |
+
{
|
312 |
+
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
313 |
+
$user = new WP_User ($user_id);
|
314 |
+
}
|
315 |
+
/**/
|
316 |
+
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
317 |
+
/**/
|
318 |
+
if ($current_role !== "s2member_level" . $paypal["level"]) /* Only if we need to. */
|
319 |
+
$user->set_role ("s2member_level" . $paypal["level"]); /* (upgrade/downgrade) */
|
320 |
+
/**/
|
321 |
+
if (!preg_match ("/^\+/", $paypal["ccaps"]))
|
322 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
323 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
324 |
+
$user->remove_cap ($ccap = $cap);
|
325 |
+
/**/
|
326 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($paypal["ccaps"], "+")) as $ccap)
|
327 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
328 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
329 |
+
/**/
|
330 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
331 |
+
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
332 |
+
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
333 |
+
/**/
|
334 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
335 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
336 |
+
/**/
|
337 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
338 |
+
/**/
|
339 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
340 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
|
341 |
+
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
342 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
343 |
+
/**/
|
344 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
345 |
+
/**/
|
346 |
+
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
|
347 |
+
/**/
|
348 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
349 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars ());
|
350 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
351 |
+
/**/
|
352 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
|
353 |
+
/**/
|
354 |
+
echo '<script type="text/javascript">' . "\n";
|
355 |
+
echo "alert('Thank you! You\\'ve been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nPlease log back in now.');" . "\n";
|
356 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
357 |
+
echo '</script>' . "\n";
|
358 |
+
}
|
359 |
+
else
|
360 |
+
{
|
361 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
362 |
+
/**/
|
363 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
364 |
+
/**/
|
365 |
+
echo '<script type="text/javascript">' . "\n";
|
366 |
+
echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
|
367 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
368 |
+
echo '</script>' . "\n";
|
369 |
+
}
|
370 |
+
}
|
371 |
+
else
|
372 |
+
{
|
373 |
+
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
374 |
+
/**/
|
375 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
376 |
+
/**/
|
377 |
+
echo '<script type="text/javascript">' . "\n";
|
378 |
+
echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
|
379 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
380 |
+
echo '</script>' . "\n";
|
381 |
+
}
|
382 |
+
/**/
|
383 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
384 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars ());
|
385 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
386 |
+
}
|
387 |
+
else
|
388 |
+
{
|
389 |
+
$paypal["s2member_log"][] = "Unexpected txn_type. The PayPal® txn_type/status did not match a required action.";
|
390 |
+
/**/
|
391 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
392 |
+
/**/
|
393 |
+
echo '<script type="text/javascript">' . "\n";
|
394 |
+
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";
|
395 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
396 |
+
echo '</script>' . "\n";
|
397 |
+
}
|
398 |
+
}
|
399 |
+
else /* Else a custom conditional has been applied by filters. */
|
400 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
401 |
+
}
|
402 |
+
else
|
403 |
+
{
|
404 |
+
$paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Please check the `custom` value in your Button Code. It MUST start with your domain name.";
|
405 |
+
/**/
|
406 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
407 |
+
/**/
|
408 |
+
echo '<script type="text/javascript">' . "\n";
|
409 |
+
echo "alert('ERROR: Unable to verify _SERVER[HTTP_HOST]. Please contact Support for assistance.\\n\\nIf you are the site owner, please check the `custom` value in your Button Code. It MUST start with your domain name.');" . "\n";
|
410 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
411 |
+
echo '</script>' . "\n";
|
412 |
+
}
|
413 |
+
}
|
414 |
+
else /* In this case ... a Proxy has explicitly requested ty-email processing. */
|
415 |
+
{
|
416 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
417 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_ty_email", get_defined_vars ());
|
418 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
419 |
+
/**/
|
420 |
+
$paypal["s2member_log"][] = "Customer must wait for Email Confirmation ( proxy_use: ty-email ).";
|
421 |
+
/**/
|
422 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
423 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_ty_email", get_defined_vars ());
|
424 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
425 |
+
/**/
|
426 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page.";
|
427 |
+
/**/
|
428 |
+
echo '<script type="text/javascript">' . "\n";
|
429 |
+
echo "alert('Thank you! ( please check your email ).\\n\\n* Note: It can take ( up to 15 minutes ) for Email Confirmation. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.');" . "\n";
|
430 |
+
echo ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "alert('** Sandbox Mode ** You may NOT receive this Email Confirmation in Sandbox Mode. Sandbox addresses are usually bogus ( for testing ).');" . "\n" : "";
|
431 |
+
echo "window.location = '" . esc_js (home_url ("/")) . "';";
|
432 |
+
echo '</script>' . "\n";
|
433 |
+
/**/
|
434 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
435 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_ty_email", get_defined_vars ());
|
436 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
437 |
+
}
|
438 |
+
}
|
439 |
+
else if (!isset ($_GET["tx"]) && (empty ($_POST) || $_POST["auth"]))
|
440 |
+
{
|
441 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
442 |
+
do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
|
443 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
444 |
+
/**/
|
445 |
+
$paypal["s2member_log"][] = "No Return-Data from PayPal®. Customer must wait for Email Confirmation.";
|
446 |
+
/**/
|
447 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
448 |
+
do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
|
449 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
450 |
+
/**/
|
451 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page.";
|
452 |
+
/**/
|
453 |
+
echo '<script type="text/javascript">' . "\n";
|
454 |
+
echo "alert('Thank you! ( please check your email ).\\n\\n* Note: It can take ( up to 15 minutes ) for Email Confirmation. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.');" . "\n";
|
455 |
+
echo ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "alert('** Sandbox Mode ** You may NOT receive this Email Confirmation in Sandbox Mode. Sandbox addresses are usually bogus ( for testing ).');" . "\n" : "";
|
456 |
+
echo "window.location = '" . esc_js (home_url ("/")) . "';";
|
457 |
+
echo '</script>' . "\n";
|
458 |
+
/**/
|
459 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
460 |
+
do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
|
461 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
462 |
+
}
|
463 |
+
else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
|
464 |
+
{
|
465 |
+
$paypal["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid PayPal® configuration. Please check: s2Member -> PayPal® Options.";
|
466 |
+
$paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
|
467 |
+
$paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
|
468 |
+
$paypal["s2member_log"][] = var_export ($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */
|
469 |
+
/**/
|
470 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
|
471 |
+
/**/
|
472 |
+
echo '<script type="text/javascript">' . "\n";
|
473 |
+
echo "alert('ERROR: Unable to verify POST vars. Please contact Support for assistance.\\n\\nThis is most likely related to an invalid PayPal® configuration. If you are the site owner, please check: s2Member -> PayPal® Options.');" . "\n";
|
474 |
+
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
|
475 |
+
echo '</script>' . "\n";
|
476 |
+
}
|
477 |
+
/*
|
478 |
+
Add RTN proxy ( when available ) to the $paypal array.
|
479 |
+
*/
|
480 |
+
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
|
481 |
+
$paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
|
482 |
+
/*
|
483 |
+
Add IPN proxy use vars ( when available ) to the $paypal array.
|
484 |
+
*/
|
485 |
+
if ($_GET["s2member_paypal_proxy_use"]) /* For proxy specifications. */
|
486 |
+
$paypal["s2member_paypal_proxy_use"] = $_GET["s2member_paypal_proxy_use"];
|
487 |
+
/*
|
488 |
+
Also add RTN proxy self-verification ( when available ) to the $paypal array.
|
489 |
+
*/
|
490 |
+
if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
|
491 |
+
$paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
|
492 |
+
/*
|
493 |
+
If debugging/logging is enabled; we need to append $paypal to the log file.
|
494 |
+
Logging now supports Multisite Networking as well.
|
495 |
+
*/
|
496 |
+
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
497 |
+
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
498 |
+
$log2 = (is_multisite () && !is_main_site ()) ? "paypal-rtn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
|
499 |
+
/**/
|
500 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
501 |
+
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
502 |
+
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
503 |
+
file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
|
504 |
+
/**/
|
505 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
506 |
+
do_action ("ws_plugin__s2member_during_paypal_return", get_defined_vars ());
|
507 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
508 |
+
/**/
|
509 |
+
exit ();
|
510 |
+
}
|
511 |
+
/**/
|
512 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
513 |
+
do_action ("ws_plugin__s2member_after_paypal_return", get_defined_vars ());
|
514 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
?>
|
includes/{functions → classes}/paypal-return.inc.php
RENAMED
@@ -13,20 +13,21 @@ Direct access denial.
|
|
13 |
*/
|
14 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
exit ("Do not access this file directly.");
|
16 |
-
|
17 |
-
|
18 |
-
This is used ONLY in PayPal® Standard Integration.
|
19 |
-
Attach to: add_action("init");
|
20 |
-
*/
|
21 |
-
if (!function_exists ("ws_plugin__s2member_paypal_return"))
|
22 |
{
|
23 |
-
|
24 |
{
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
{
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
}
|
31 |
}
|
32 |
}
|
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 |
+
}
|
31 |
}
|
32 |
}
|
33 |
}
|
includes/classes/paypal-utilities.inc.php
ADDED
@@ -0,0 +1,378 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
26 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
27 |
+
do_action ("ws_plugin__s2member_before_paypal_postvars", get_defined_vars ());
|
28 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
29 |
+
/*
|
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";
|
41 |
+
$postback["at"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"];
|
42 |
+
/**/
|
43 |
+
$endpoint = ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com";
|
44 |
+
/**/
|
45 |
+
if (preg_match ("/^SUCCESS/i", ($response = trim (c_ws_plugin__s2member_utils_urls::remote ("https://" . $endpoint . "/cgi-bin/webscr", $postback, array ("timeout" => 20))))))
|
46 |
+
{
|
47 |
+
foreach (preg_split ("/[\r\n]+/", preg_replace ("/^SUCCESS/i", "", $response)) as $varline)
|
48 |
+
{
|
49 |
+
list ($key, $value) = preg_split ("/\=/", $varline, 2);
|
50 |
+
if (strlen ($key = trim ($key)) && strlen ($value = trim ($value)))
|
51 |
+
$postvars[$key] = trim (stripslashes (urldecode ($value)));
|
52 |
+
}
|
53 |
+
/**/
|
54 |
+
return apply_filters ("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars ());
|
55 |
+
}
|
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))
|
63 |
+
unset ($postvars[$key]);
|
64 |
+
/**/
|
65 |
+
$postback = $postvars; /* Copy. */
|
66 |
+
$postback["cmd"] = "_notify-validate";
|
67 |
+
/**/
|
68 |
+
$postvars = c_ws_plugin__s2member_utils_strings::trim_deep ($postvars);
|
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. */
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
else /* Nope. */
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
else /* Else a custom conditional has been applied by Filters. */
|
85 |
+
{
|
86 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
87 |
+
/**/
|
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 |
+
{
|
96 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
97 |
+
/**/
|
98 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 |
+
{
|
115 |
+
global $current_site, $current_blog; /* For Multisite support. */
|
116 |
+
/**/
|
117 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 in array format. */
|
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"];
|
129 |
+
/**/
|
130 |
+
$input_time = date ("D M j, Y g:i:s a T"); /* Record input/nvp for logging. */
|
131 |
+
/**/
|
132 |
+
$nvp = trim (c_ws_plugin__s2member_utils_urls::remote ($url, $post_vars, array ("timeout" => 20)));
|
133 |
+
/**/
|
134 |
+
$output_time = date ("D M j, Y g:i:s a T"); /* Now record after output time. */
|
135 |
+
/**/
|
136 |
+
wp_parse_str ($nvp, $response); /* Parse NVP response. */
|
137 |
+
$response = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($response));
|
138 |
+
/**/
|
139 |
+
if (!$response["ACK"] || !preg_match ("/^(Success|SuccessWithWarning)$/i", $response["ACK"]))
|
140 |
+
{
|
141 |
+
if (strlen ($response["L_ERRORCODE0"]) || $response["L_SHORTMESSAGE0"] || $response["L_LONGMESSAGE0"]) /* Did we at least get an error msg? */
|
142 |
+
$response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". " . rtrim ($response["L_SHORTMESSAGE0"], ".") . ". " . rtrim ($response["L_LONGMESSAGE0"], ".") . ".";
|
143 |
+
/**/
|
144 |
+
else /* Else, generate an error messsage - so something is reported back to the Customer. */
|
145 |
+
$response["__error"] = "Error. Please contact Support for assistance.";
|
146 |
+
}
|
147 |
+
/*
|
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 |
+
{
|
174 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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.";
|
182 |
+
/**/
|
183 |
+
else if ($response["L_ERRORCODE0"] == 10435)
|
184 |
+
$response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". Transaction declined. Express Checkout was NOT confirmed.";
|
185 |
+
/**/
|
186 |
+
else if ($response["L_ERRORCODE0"] == 10417)
|
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 |
+
{
|
197 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
198 |
+
do_action ("ws_plugin__s2member_before_paypal_pro_term", get_defined_vars ());
|
199 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
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 |
+
{
|
212 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
213 |
+
do_action ("ws_plugin__s2member_before_paypal_std_term", get_defined_vars ());
|
214 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
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 |
+
{
|
227 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 |
+
{
|
246 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 |
+
{
|
272 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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 |
+
{
|
297 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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)
|
316 |
+
eval ('$num = "2"; $span = "W";');
|
317 |
+
/**/
|
318 |
+
if (strlen ($span) !== 1) /* To Standard format. */
|
319 |
+
$span = c_ws_plugin__s2member_paypal_utilities::paypal_std_term ($span);
|
320 |
+
/**/
|
321 |
+
$span = (preg_match ("/^[DWMY]$/i", $span)) ? $span : "";
|
322 |
+
$num = ($span && is_numeric ($num) && $num >= 0) ? $num : "";
|
323 |
+
/**/
|
324 |
+
$period1 = ($num && $span) ? $num . " " . strtoupper ($span) : "0 D";
|
325 |
+
/**/
|
326 |
+
return apply_filters ("ws_plugin__s2member_paypal_pro_period1", $period1, get_defined_vars ());
|
327 |
+
}
|
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 |
+
{
|
342 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
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)
|
361 |
+
eval ('$num = "2"; $span = "W";');
|
362 |
+
/**/
|
363 |
+
if (strlen ($span) !== 1) /* To Standard format. */
|
364 |
+
$span = c_ws_plugin__s2member_paypal_utilities::paypal_std_term ($span);
|
365 |
+
/**/
|
366 |
+
$span = (preg_match ("/^[DWMY]$/i", $span)) ? $span : "";
|
367 |
+
$num = ($span && is_numeric ($num) && $num >= 0) ? $num : "";
|
368 |
+
/**/
|
369 |
+
$period3 = ($num && $span) ? $num . " " . strtoupper ($span) : "1 D";
|
370 |
+
/**/
|
371 |
+
return apply_filters ("ws_plugin__s2member_paypal_pro_period3", $period3, get_defined_vars ());
|
372 |
+
}
|
373 |
+
else /* Default. */
|
374 |
+
return apply_filters ("ws_plugin__s2member_paypal_pro_period3", "1 D", get_defined_vars ());
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
?>
|
includes/classes/posts-sp.inc.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function 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 |
+
{
|
38 |
+
do_action ("ws_plugin__s2member_before_check_specific_post_level_access", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_specific_post_level_access_excluded", false, get_defined_vars ());
|
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")))
|
100 |
+
return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_sp_req" => $post_id), get_defined_vars ());
|
101 |
+
}
|
102 |
+
/**/
|
103 |
+
do_action ("ws_plugin__s2member_during_check_specific_post_level_access", get_defined_vars ());
|
104 |
+
}
|
105 |
+
/**/
|
106 |
+
return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", null, get_defined_vars ());
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
?>
|
includes/classes/posts.inc.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function for handling 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 |
+
{
|
38 |
+
global $post; /* get_the_ID() unavailable outside The Loop. */
|
39 |
+
/**/
|
40 |
+
do_action ("ws_plugin__s2member_before_check_post_level_access", get_defined_vars ());
|
41 |
+
/**/
|
42 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_post_level_access_excluded", false, get_defined_vars ());
|
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 ();
|
126 |
+
}
|
127 |
+
}
|
128 |
+
/**/
|
129 |
+
do_action ("ws_plugin__s2member_during_check_post_level_access", get_defined_vars ());
|
130 |
+
}
|
131 |
+
/**/
|
132 |
+
do_action ("ws_plugin__s2member_after_check_post_level_access", get_defined_vars ());
|
133 |
+
/**/
|
134 |
+
return; /* For uniformity. */
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
?>
|
includes/classes/profile-mods-in.inc.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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 |
+
$_POST = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Clean POST vars. */
|
38 |
+
/**/
|
39 |
+
$userdata["ID"] = $user_id = $current_user->ID;
|
40 |
+
/**/
|
41 |
+
include_once ABSPATH . WPINC . "/registration.php";
|
42 |
+
/**/
|
43 |
+
if (is_email ($_POST["ws_plugin__s2member_profile_email"]))
|
44 |
+
if (!email_exists ($_POST["ws_plugin__s2member_profile_email"]))
|
45 |
+
$userdata["user_email"] = $_POST["ws_plugin__s2member_profile_email"];
|
46 |
+
/**/
|
47 |
+
if ($_POST["ws_plugin__s2member_profile_password"])
|
48 |
+
if ($current_user->user_login !== "demo") /* No pass change on demo. */
|
49 |
+
$userdata["user_pass"] = $_POST["ws_plugin__s2member_profile_password"];
|
50 |
+
/**/
|
51 |
+
if ($_POST["ws_plugin__s2member_profile_first_name"])
|
52 |
+
$userdata["first_name"] = $_POST["ws_plugin__s2member_profile_first_name"];
|
53 |
+
/**/
|
54 |
+
if ($_POST["ws_plugin__s2member_profile_display_name"])
|
55 |
+
$userdata["display_name"] = $_POST["ws_plugin__s2member_profile_display_name"];
|
56 |
+
/**/
|
57 |
+
if ($_POST["ws_plugin__s2member_profile_last_name"])
|
58 |
+
$userdata["last_name"] = $_POST["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"))
|
64 |
+
{
|
65 |
+
$_existing_fields = get_user_option ("s2member_custom_fields", $user_id);
|
66 |
+
/**/
|
67 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
68 |
+
{
|
69 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
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 ($_POST["ws_plugin__s2member_profile_" . $field_var])/**/
|
76 |
+
&& $_POST["ws_plugin__s2member_profile_" . $field_var] !== "0") /* Allow zeros. */
|
77 |
+
$fields[$field_var] = $_existing_fields[$field_var];
|
78 |
+
/**/
|
79 |
+
else /* Otherwise, we can use the newly updated value. */
|
80 |
+
$fields[$field_var] = $_POST["ws_plugin__s2member_profile_" . $field_var];
|
81 |
+
}
|
82 |
+
/**/
|
83 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
84 |
+
}
|
85 |
+
/**/
|
86 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
87 |
+
do_action ("ws_plugin__s2member_during_handle_profile_modifications", get_defined_vars ());
|
88 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
89 |
+
/**/
|
90 |
+
$current_user = new WP_User ($user_id); /* Update the WP_User object for current User/Member. */
|
91 |
+
(function_exists ("setup_userdata")) ? setup_userdata () : null; /* Update global vars. */
|
92 |
+
/**/
|
93 |
+
if (!$_POST["ws_plugin__s2member_sc_profile_save"]) /* But NOT with Shortcode Profiles. */
|
94 |
+
{
|
95 |
+
echo '<script type="text/javascript">' . "\n";
|
96 |
+
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"])) . "'; }";
|
97 |
+
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"])) . "'; }";
|
98 |
+
echo "else { alert('Profile updated successfully!'); window.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
|
99 |
+
echo '</script>' . "\n";
|
100 |
+
/**/
|
101 |
+
exit (); /* Clean exit. */
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
/**/
|
106 |
+
do_action ("ws_plugin__s2member_after_handle_profile_modifications", get_defined_vars ());
|
107 |
+
/**/
|
108 |
+
return; /* Return for uniformity. */
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
?>
|
includes/classes/profile-mods.inc.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
?>
|
includes/classes/profile.inc.php
ADDED
@@ -0,0 +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_profile"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_profile
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that displays a Profile Modification Form.
|
23 |
+
Attach to: add_action("template_redirect");
|
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 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_after_profile", get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
return; /* Return for uniformity. */
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
?>
|
includes/classes/ptags-sp.inc.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function 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 |
+
}
|
61 |
+
}
|
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 |
+
/**/
|
97 |
+
do_action ("ws_plugin__s2member_during_check_specific_ptag_level_access", get_defined_vars ());
|
98 |
+
}
|
99 |
+
/**/
|
100 |
+
return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", null, get_defined_vars ());
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
?>
|
includes/classes/ptags.inc.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
Function for handling 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 |
+
{
|
38 |
+
global $wp_query, $post; /* get_the_ID() is NOT available outside The Loop. */
|
39 |
+
/**/
|
40 |
+
do_action ("ws_plugin__s2member_before_check_ptag_level_access", get_defined_vars ());
|
41 |
+
/**/
|
42 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_ptag_level_access_excluded", false, get_defined_vars ());
|
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 ()));
|
66 |
+
exit ();
|
67 |
+
}
|
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, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
75 |
+
{
|
76 |
+
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 ()));
|
77 |
+
exit ();
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
do_action ("ws_plugin__s2member_during_check_ptag_level_access", get_defined_vars ());
|
83 |
+
}
|
84 |
+
/**/
|
85 |
+
do_action ("ws_plugin__s2member_after_check_ptag_level_access", get_defined_vars ());
|
86 |
+
/**/
|
87 |
+
return; /* For uniformity. */
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
?>
|
includes/classes/querys.inc.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_querys"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_querys
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
This can filter all WordPress® Post/Page queries.
|
23 |
+
( based on s2Member's configuration )
|
24 |
+
|
25 |
+
s2Member respects the query var: `suppress_filters`.
|
26 |
+
If you need to make a query without it being filtered,
|
27 |
+
$wp_query->set ("suppress_filters", true);
|
28 |
+
|
29 |
+
WordPress® 3.0+ Menus set: `suppress_filters`.
|
30 |
+
So this will NOT affect WP Menus.
|
31 |
+
( intended behavior )
|
32 |
+
|
33 |
+
Don't call this function directly, use one of these API functions:
|
34 |
+
|
35 |
+
Attach query filters:
|
36 |
+
- attach_s2member_query_filters();
|
37 |
+
|
38 |
+
Detach query filters:
|
39 |
+
- detach_s2member_query_filters();
|
40 |
+
|
41 |
+
see: `/s2member/includes/functions/api-functions.inc.php`.
|
42 |
+
*/
|
43 |
+
public static function query_level_access (&$wp_query = FALSE, $force = FALSE)
|
44 |
+
{
|
45 |
+
static $initial_query = true; /* Tracks initial query filtering. */
|
46 |
+
/**/
|
47 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
48 |
+
do_action ("ws_plugin__s2member_before_query_level_access", get_defined_vars ());
|
49 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
50 |
+
/**/
|
51 |
+
if (($o = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"]) !== "none" || $force) /* If `none`, the ONLY way to filter is with $force. */
|
52 |
+
if ($force /* Forcing this routine bypasses all of these conditions. This works with the API function `attach_s2member_query_filters()`. */
|
53 |
+
|| ($initial_query && preg_match ("/^(all|searches,feeds|searches)$/", $o) && is_search ()) /* Initial query; filter search results? */
|
54 |
+
|| ($initial_query && preg_match ("/^(all|searches,feeds|feeds)$/", $o) && is_feed ()) /* Initital query; filter feed listings? */
|
55 |
+
|| ($o === "all" && ! ($initial_query && is_singular ())) /* << do NOT create 404's. Allow the Security Gate to handle these. */)
|
56 |
+
{
|
57 |
+
if (!is_admin () && is_object ($wp_query) && !$wp_query->get ("suppress_filters")) /* These are ALWAYS requirements. */
|
58 |
+
{
|
59 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
60 |
+
/*
|
61 |
+
Filter all Posts/Pages requiring Custom Capabilities that the current User does NOT have access to.
|
62 |
+
*/
|
63 |
+
if (is_array ($ccaps = c_ws_plugin__s2member_utils_gets::get_singular_ids_with_ccaps_req ($current_user)) && !empty ($ccaps))
|
64 |
+
$wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $ccaps)));
|
65 |
+
/*
|
66 |
+
Filter all Posts/Pages requiring Specific Post/Page Access that the current Visitor does NOT have access to.
|
67 |
+
*/
|
68 |
+
if (is_array ($sps = c_ws_plugin__s2member_utils_gets::get_singular_ids_with_sp_req ()) && !empty ($sps))
|
69 |
+
$wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $sps)));
|
70 |
+
/**/
|
71 |
+
for ($i = 0; $i <= 4; $i++) /* Category Level Restrictions. Go through each Membership Level. */
|
72 |
+
{
|
73 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
74 |
+
{
|
75 |
+
$wp_query->set ("category__not_in", c_ws_plugin__s2member_utils_gets::get_all_category_ids ());
|
76 |
+
break; /* All Categories will be locked down. */
|
77 |
+
}
|
78 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
79 |
+
{
|
80 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
|
81 |
+
$catgs = array_merge ((array)$catgs, array ($catg), c_ws_plugin__s2member_utils_gets::get_all_child_category_ids ($catg));
|
82 |
+
$wp_query->set ("category__not_in", array_unique (array_merge ((array)$wp_query->get ("category__not_in"), $catgs)));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
/**/
|
86 |
+
for ($i = 0; $i <= 4; $i++) /* Tag Level Restrictions. Go through each Membership Level. */
|
87 |
+
{
|
88 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
89 |
+
{
|
90 |
+
$wp_query->set ("tag__not_in", c_ws_plugin__s2member_utils_gets::get_all_tag_ids ());
|
91 |
+
break; /* ALL Tags will be locked down. */
|
92 |
+
}
|
93 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
94 |
+
{
|
95 |
+
$tags = c_ws_plugin__s2member_utils_gets::convert_tags_2_ids ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]);
|
96 |
+
$wp_query->set ("tag__not_in", array_unique (array_merge ((array)$wp_query->get ("tag__not_in"), $tags)));
|
97 |
+
}
|
98 |
+
}
|
99 |
+
/**/
|
100 |
+
for ($i = 0; $i <= 4; $i++) /* Post Level Restrictions. Go through each Membership Level. */
|
101 |
+
{
|
102 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
103 |
+
{
|
104 |
+
$wp_query->set ("post__not_in", c_ws_plugin__s2member_utils_gets::get_all_post_ids ());
|
105 |
+
break; /* ALL Posts will be locked down. */
|
106 |
+
}
|
107 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
108 |
+
{
|
109 |
+
$posts = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"]);
|
110 |
+
$wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $posts)));
|
111 |
+
}
|
112 |
+
}
|
113 |
+
/**/
|
114 |
+
for ($i = 0; $i <= 4; $i++) /* Page Level Restrictions. Go through each Membership Level. */
|
115 |
+
{
|
116 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
117 |
+
{
|
118 |
+
$wp_query->set ("post__not_in", c_ws_plugin__s2member_utils_gets::get_all_page_ids ());
|
119 |
+
break; /* ALL Pages will be locked down. */
|
120 |
+
}
|
121 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
122 |
+
{
|
123 |
+
$pages = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"]);
|
124 |
+
$wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $pages)));
|
125 |
+
}
|
126 |
+
}
|
127 |
+
/**/
|
128 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
129 |
+
do_action ("ws_plugin__s2member_during_query_level_access", get_defined_vars ());
|
130 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
131 |
+
}
|
132 |
+
}
|
133 |
+
/**/
|
134 |
+
if ($initial_query && !is_admin ()) /* Systematics. */
|
135 |
+
c_ws_plugin__s2member_querys::_query_level_access_sys ($wp_query);
|
136 |
+
/**/
|
137 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
138 |
+
do_action ("ws_plugin__s2member_after_query_level_access", get_defined_vars ());
|
139 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
140 |
+
/**/
|
141 |
+
$initial_query = false; /* No longer. */
|
142 |
+
/**/
|
143 |
+
return; /* For uniformity. */
|
144 |
+
}
|
145 |
+
/*
|
146 |
+
This filters Systematics in search results & feeds.
|
147 |
+
|
148 |
+
Specifically, these 3 Pages:
|
149 |
+
- Membership Options
|
150 |
+
- Login Welcome
|
151 |
+
- Download Limit Exceeded
|
152 |
+
|
153 |
+
s2Member respects the query var: `suppress_filters`.
|
154 |
+
If you need to make a query without it being filtered,
|
155 |
+
$wp_query->set ("suppress_filters", true);
|
156 |
+
|
157 |
+
Don't call this function directly, use one of these API functions:
|
158 |
+
|
159 |
+
Attach query filters:
|
160 |
+
- attach_s2member_query_filters();
|
161 |
+
|
162 |
+
Detach query filters:
|
163 |
+
- detach_s2member_query_filters();
|
164 |
+
|
165 |
+
see: `/s2member/includes/functions/api-functions.inc.php`.
|
166 |
+
*/
|
167 |
+
public static function _query_level_access_sys (&$wp_query = FALSE)
|
168 |
+
{
|
169 |
+
static $initial_query = true; /* Tracks initial query filtering. */
|
170 |
+
/**/
|
171 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
172 |
+
do_action ("_ws_plugin__s2member_before_query_level_access_sys", get_defined_vars ());
|
173 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
174 |
+
/**/
|
175 |
+
if ($initial_query && !is_admin () && (is_search () || is_feed ())) /* Searches/feeds. */
|
176 |
+
/**/
|
177 |
+
if (is_object ($wp_query) && !$wp_query->get ("suppress_filters")) /* Respect. */
|
178 |
+
{
|
179 |
+
$s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
180 |
+
$s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
181 |
+
$s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
182 |
+
/**/
|
183 |
+
$wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $s)));
|
184 |
+
/**/
|
185 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
186 |
+
do_action ("_ws_plugin__s2member_during_query_level_access_sys", get_defined_vars ());
|
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_after_query_level_access_sys", get_defined_vars ());
|
192 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
193 |
+
/**/
|
194 |
+
$initial_query = false; /* No longer. */
|
195 |
+
/**/
|
196 |
+
return; /* For uniformity. */
|
197 |
+
}
|
198 |
+
/*
|
199 |
+
Forces query filters ( on-demand ).
|
200 |
+
But still respects: `suppress_filters`.
|
201 |
+
|
202 |
+
s2Member respects the query var: `suppress_filters`.
|
203 |
+
If you need to make a query without it being filtered,
|
204 |
+
$wp_query->set ("suppress_filters", true);
|
205 |
+
|
206 |
+
Don't call this function directly, use one of these API functions:
|
207 |
+
|
208 |
+
Attach query filters:
|
209 |
+
- attach_s2member_query_filters();
|
210 |
+
|
211 |
+
Detach query filters:
|
212 |
+
- detach_s2member_query_filters();
|
213 |
+
|
214 |
+
see: `/s2member/includes/functions/api-functions.inc.php`.
|
215 |
+
*/
|
216 |
+
public static function force_query_level_access (&$wp_query = FALSE)
|
217 |
+
{
|
218 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
219 |
+
do_action ("ws_plugin__s2member_before_force_query_level_access", get_defined_vars ());
|
220 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
221 |
+
/**/
|
222 |
+
c_ws_plugin__s2member_querys::query_level_access ($wp_query, "force-filters");
|
223 |
+
/**/
|
224 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
225 |
+
do_action ("ws_plugin__s2member_after_force_query_level_access", get_defined_vars ());
|
226 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
227 |
+
/**/
|
228 |
+
return; /* For uniformity. */
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
?>
|
includes/classes/readmes.inc.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_readmes"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_readmes
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles readme.txt parsing.
|
23 |
+
*/
|
24 |
+
public static function parse_readme ($specific_path = FALSE, $specific_section = FALSE, $_blank_targets = TRUE, $process_wp_syntax = FALSE)
|
25 |
+
{
|
26 |
+
if (! ($path = $specific_path)) /* Was a specific path passed in? */
|
27 |
+
{
|
28 |
+
$path = dirname (dirname (dirname (__FILE__))) . "/readme.txt";
|
29 |
+
$dev_path = dirname (dirname (dirname (__FILE__))) . "/readme-dev.txt";
|
30 |
+
$path = (file_exists ($dev_path)) ? $dev_path : $path;
|
31 |
+
}
|
32 |
+
/**/
|
33 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
34 |
+
do_action ("ws_plugin__s2member_before_parse_readme", get_defined_vars ());
|
35 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
36 |
+
/**/
|
37 |
+
if (file_exists ($path)) /* Give hooks a chance. */
|
38 |
+
{
|
39 |
+
$o_pcre = @ini_get ("pcre.backtrack_limit");
|
40 |
+
@ini_set ("pcre.backtrack_limit", 10000000);
|
41 |
+
/**/
|
42 |
+
if (!function_exists ("NC_Markdown"))
|
43 |
+
include_once dirname (dirname (__FILE__)) . "/markdown/nc-markdown.inc.php";
|
44 |
+
/**/
|
45 |
+
$rm = file_get_contents ($path); /* Get readme.txt file contents. */
|
46 |
+
$mb = function_exists ("mb_convert_encoding") ? @mb_convert_encoding ($rm, "UTF-8",@mb_detect_encoding ($rm, "WINDOWS-1252, UTF-8")) : $rm;
|
47 |
+
$rm = ($mb) ? $mb : $rm; /* Double check this, just in case conversion fails on an unpredicted charset. */
|
48 |
+
/**/
|
49 |
+
if ($specific_section) /* If we are ONLY parsing a specific section. This is a very useful way of pulling details out. */
|
50 |
+
{
|
51 |
+
preg_match ("/(\=\= )(" . preg_quote ($specific_section, "/") . ")( \=\=)(.+?)([\r\n]+\=\= |$)/si", $rm, $m);
|
52 |
+
/**/
|
53 |
+
if ($rm = trim ($m[4])) /* Looking for a specific section, indicated by `$specific_section`. */
|
54 |
+
{
|
55 |
+
$rm = preg_replace ("/(\=\=\=)( )(.+?)( )(\=\=\=)/", "<h4 id=\"rm-specs\">Specifications</h4>", $rm);
|
56 |
+
$rm = preg_replace ("/(\=\=)( )(Installation)( )(\=\=)/", "<h4 id=\"rm-installation\">$3</h4>", $rm);
|
57 |
+
$rm = preg_replace ("/(\=\=)( )(Description)( )(\=\=)/", "<h4 id=\"rm-description\">$3</h4>", $rm);
|
58 |
+
$rm = preg_replace ("/(\=\=)( )(Screenshots)( )(\=\=)/", "<h4 id=\"rm-screenshots\">$3</h4>", $rm);
|
59 |
+
$rm = preg_replace ("/(\=\=)( )(Frequently Asked Questions)( )(\=\=)/", "<h4 id=\"rm-faqs\">$3</h4>", $rm);
|
60 |
+
$rm = preg_replace ("/(\=\=)( )(Changelog)( )(\=\=)/", "<h4 id=\"rm-changelog\">$3</h4>", $rm);
|
61 |
+
$rm = preg_replace ("/(\=\=)( )(.+?)( )(\=\=)/", "<h4>$3</h4>", $rm);
|
62 |
+
$rm = preg_replace ("/(\=)( )(.+?)( )(\=)/", "<h6>$3</h6>", $rm);
|
63 |
+
/**/
|
64 |
+
$rm = NC_Markdown ($rm); /* Parse out the Markdown syntax. */
|
65 |
+
/**/
|
66 |
+
$r1 = "/(\<a)( href)/i"; /* Modify all links. Assume a nofollow relationship. */
|
67 |
+
/**/
|
68 |
+
if ($_blank_targets) /* Modify all links. Always nofollow. ( with _blank targets ? ). */
|
69 |
+
$rm = preg_replace ($r1, "$1" . ' target="_blank" rel="nofollow external"' . "$2", $rm);
|
70 |
+
else /* Otherwise, we don't need to set _blank targets. So external is removed also. */
|
71 |
+
$rm = preg_replace ($r1, "$1" . ' rel="nofollow"' . "$2", $rm);
|
72 |
+
/**/
|
73 |
+
if ($process_wp_syntax) /* If we're processing <pre><code> tags for WP-Syntax. */
|
74 |
+
if (function_exists ("wp_syntax_before_filter") && function_exists ("wp_syntax_before_filter"))
|
75 |
+
{
|
76 |
+
$rm = preg_replace ("/\<pre\>\<code\>/i", '<pre lang="php" escaped="true">', $rm);
|
77 |
+
$rm = preg_replace ("/\<\/code\>\<\/pre\>/i", '</pre>', $rm);
|
78 |
+
$rm = wp_syntax_after_filter (wp_syntax_before_filter ($rm));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
@ini_set ("pcre.backtrack_limit", $o_pcre);
|
83 |
+
/**/
|
84 |
+
$readme = '<div class="readme">' . "\n";
|
85 |
+
$readme .= $rm . "\n"; /* Content. */
|
86 |
+
$readme .= '</div>' . "\n";
|
87 |
+
/**/
|
88 |
+
return apply_filters ("ws_plugin__s2member_parse_readme", $readme, get_defined_vars ());
|
89 |
+
}
|
90 |
+
else /* Otherwise, we're going for the entire readme file. Here we have lots of work to do. */
|
91 |
+
{
|
92 |
+
$rm = preg_replace ("/(\=\=\=)( )(.+?)( )(\=\=\=)/", "<h2 id=\"rm-specs\">Specifications</h2>", $rm);
|
93 |
+
$rm = preg_replace ("/(\=\=)( )(Installation)( )(\=\=)/", "<h2 id=\"rm-installation\">$3</h2>", $rm);
|
94 |
+
$rm = preg_replace ("/(\=\=)( )(Description)( )(\=\=)/", "<h2 id=\"rm-description\">$3</h2>", $rm);
|
95 |
+
$rm = preg_replace ("/(\=\=)( )(Screenshots)( )(\=\=)/", "<h2 id=\"rm-screenshots\">$3</h2>", $rm);
|
96 |
+
$rm = preg_replace ("/(\=\=)( )(Frequently Asked Questions)( )(\=\=)/", "<h2 id=\"rm-faqs\">$3</h2>", $rm);
|
97 |
+
$rm = preg_replace ("/(\=\=)( )(Changelog)( )(\=\=)/", "<h2 id=\"rm-changelog\">$3</h2>", $rm);
|
98 |
+
$rm = preg_replace ("/(\=\=)( )(.+?)( )(\=\=)/", "<h2>$3</h2>", $rm);
|
99 |
+
$rm = preg_replace ("/(\=)( )(.+?)( )(\=)/", "<h3>$3</h3>", $rm);
|
100 |
+
/**/
|
101 |
+
$rm = NC_Markdown ($rm); /* Parse out the Markdown syntax. */
|
102 |
+
/**/
|
103 |
+
$r1 = "/(\<h2(.*?)\>)(.+?)(\<\/h2\>)(.+?)(\<h2(.*?)\>|$)/si";
|
104 |
+
$r2 = "/(\<\/div\>)(\<h2(.*?)\>)(.+?)(\<\/h2\>)(.+?)(\<div class\=\"section\"\>\<h2(.*?)\>|$)/si";
|
105 |
+
$r3 = "/(\<div class\=\"section\"\>)(\<h2 id\=\"rm-specs\"\>)(Specifications)(\<\/h2\>)(\<div class\=\"content\"\>)(.+?)(\<\/div\>\<\/div\>)/sei";
|
106 |
+
$r4 = "/(\<div class\=\"section\"\>)(\<h2 id\=\"rm-screenshots\"\>)(Screenshots)(\<\/h2\>)(\<div class\=\"content\"\>)(.+?)(\<\/div\>\<\/div\>)/sei";
|
107 |
+
$r5 = "/(\<a)( href)/i"; /* Modify all links. Assume a nofollow relationship since destinations are unknown. */
|
108 |
+
/**/
|
109 |
+
$rm = preg_replace ($r1, '<div class="section">' . "$1$3$4" . '<div class="content">' . "$5" . '</div></div>' . "$6", $rm);
|
110 |
+
$rm = preg_replace ($r2, "$1" . '<div class="section">' . "$2$4$5" . '<div class="content">' . "$6" . '</div></div>' . "$7", $rm);
|
111 |
+
$rm = stripslashes (preg_replace ($r3, "'$1$2$3$4$5'.c_ws_plugin__s2member_readmes::_parse_readme_specs('$6').'$7'", $rm, 1));
|
112 |
+
$rm = preg_replace ($r4, "", $rm, 1); /* Here we just remove the screenshots completely. */
|
113 |
+
/**/
|
114 |
+
if ($_blank_targets) /* Modify all links. Always nofollow. ( with _blank targets ? ). */
|
115 |
+
$rm = preg_replace ($r5, "$1" . ' target="_blank" rel="nofollow external"' . "$2", $rm);
|
116 |
+
else /* Otherwise, we don't need to set _blank targets. So external is removed also. */
|
117 |
+
$rm = preg_replace ($r5, "$1" . ' rel="nofollow"' . "$2", $rm);
|
118 |
+
/**/
|
119 |
+
if ($process_wp_syntax) /* If we're processing <pre><code> tags for WP-Syntax. */
|
120 |
+
if (function_exists ("wp_syntax_before_filter") && function_exists ("wp_syntax_before_filter"))
|
121 |
+
{
|
122 |
+
$rm = preg_replace ("/\<pre\>\<code\>/i", '<pre lang="php" escaped="true">', $rm);
|
123 |
+
$rm = preg_replace ("/\<\/code\>\<\/pre\>/i", '</pre>', $rm);
|
124 |
+
$rm = wp_syntax_after_filter (wp_syntax_before_filter ($rm));
|
125 |
+
}
|
126 |
+
/**/
|
127 |
+
@ini_set ("pcre.backtrack_limit", $o_pcre);
|
128 |
+
/**/
|
129 |
+
$readme = '<div class="readme">' . "\n";
|
130 |
+
$readme .= $rm . "\n"; /* Content. */
|
131 |
+
$readme .= '</div>' . "\n";
|
132 |
+
/**/
|
133 |
+
return apply_filters ("ws_plugin__s2member_parse_readme", $readme, get_defined_vars ());
|
134 |
+
}
|
135 |
+
}
|
136 |
+
else /* Just in case readme.txt was deleted by the site owner. */
|
137 |
+
{
|
138 |
+
return "Unable to parse /readme.txt.";
|
139 |
+
}
|
140 |
+
}
|
141 |
+
/*
|
142 |
+
Callback function that helps readme file parsing with specs.
|
143 |
+
*/
|
144 |
+
public static function _parse_readme_specs ($str = FALSE)
|
145 |
+
{
|
146 |
+
do_action ("_ws_plugin__s2member_before_parse_readme_specs", get_defined_vars ());
|
147 |
+
/**/
|
148 |
+
$str = preg_replace ("/(\<p\>|^)(.+?)(\:)( )(.+?)($|\<\/p\>)/mi", "$1" . '<li><strong>' . "$2" . '</strong>' . "$3" . ' <code>' . "$5" . '</code></li>' . "$6", $str);
|
149 |
+
$str = preg_replace ("/\<p\>\<li\>/i", '<ul><li>', $str); /* Open the list items. */
|
150 |
+
$str = preg_replace ("/\<\/li\>\<\/p\>/i", '</li></ul><br />', $str);
|
151 |
+
/**/
|
152 |
+
return apply_filters ("_ws_plugin__s2member_parse_readme_specs", $str, get_defined_vars ());
|
153 |
+
}
|
154 |
+
/*
|
155 |
+
Function for parsing readme.txt files and returning a key value.
|
156 |
+
*/
|
157 |
+
public static function parse_readme_value ($key = FALSE, $specific_path = FALSE)
|
158 |
+
{
|
159 |
+
static $readme = array (); /* For repeated lookups across different paths. */
|
160 |
+
/**/
|
161 |
+
if (! ($path = $specific_path)) /* Was a specific path passed in? */
|
162 |
+
{
|
163 |
+
$path = dirname (dirname (dirname (__FILE__))) . "/readme.txt";
|
164 |
+
$dev_path = dirname (dirname (dirname (__FILE__))) . "/readme-dev.txt";
|
165 |
+
$path = (file_exists ($dev_path)) ? $dev_path : $path;
|
166 |
+
}
|
167 |
+
/**/
|
168 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
169 |
+
do_action ("ws_plugin__s2member_before_parse_readme_value", get_defined_vars ());
|
170 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
171 |
+
/**/
|
172 |
+
if ($readme[$path] || file_exists ($path))
|
173 |
+
{
|
174 |
+
if (!$readme[$path]) /* If not already opened, we need open it up now. */
|
175 |
+
{
|
176 |
+
$readme[$path] = file_get_contents ($path); /* Get readme.txt file contents. */
|
177 |
+
$mb = function_exists ("mb_convert_encoding") ? @mb_convert_encoding ($readme[$path], "UTF-8",@mb_detect_encoding ($readme[$path], "WINDOWS-1252, UTF-8")) : $readme[$path];
|
178 |
+
$readme[$path] = ($mb) ? $mb : $readme[$path]; /* Double check this, just in case conversion fails on an unpredicted charset. */
|
179 |
+
}
|
180 |
+
/**/
|
181 |
+
preg_match ("/(^)(" . preg_quote ($key, "/") . ")(\:)( )(.+?)($)/m", $readme[$path], $m);
|
182 |
+
/**/
|
183 |
+
return strlen ($m[5] = trim ($m[5])) ? apply_filters ("ws_plugin__s2member_parse_readme_value", $m[5], get_defined_vars ()) : false;
|
184 |
+
}
|
185 |
+
else /* Nope. */
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
?>
|
includes/classes/register-access.inc.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_register_access"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_register_access
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Generates registration links.
|
23 |
+
*/
|
24 |
+
public static function register_link_gen ($subscr_gateway = FALSE, $subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
|
25 |
+
{
|
26 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
27 |
+
do_action ("ws_plugin__s2member_before_register_link_gen", get_defined_vars ());
|
28 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
29 |
+
/**/
|
30 |
+
if ($subscr_gateway && $subscr_id && $custom && $item_number) /* Must have all of these. */
|
31 |
+
{
|
32 |
+
$register = c_ws_plugin__s2member_utils_encryption::encrypt ("subscr_gateway_subscr_id_custom_item_number_time:.:|:.:" . $subscr_gateway . ":.:|:.:" . $subscr_id . ":.:|:.:" . $custom . ":.:|:.:" . $item_number . ":.:|:.:" . strtotime ("now"));
|
33 |
+
$register_link = site_url ("/?s2member_register=" . urlencode ($register));
|
34 |
+
/**/
|
35 |
+
if ($shrink && ($tinyurl = c_ws_plugin__s2member_utils_urls::remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($register_link))))
|
36 |
+
return apply_filters ("ws_plugin__s2member_register_link_gen", $tinyurl . "#" . $_SERVER["HTTP_HOST"], get_defined_vars ());
|
37 |
+
else /* Else use the long one; tinyURL will fail when/if their server is down periodically. */
|
38 |
+
return apply_filters ("ws_plugin__s2member_register_link_gen", $register_link, get_defined_vars ());
|
39 |
+
}
|
40 |
+
/**/
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
/*
|
44 |
+
Generates Registration Access links via ajax tools.
|
45 |
+
Attach to: add_action("wp_ajax_ws_plugin__s2member_reg_access_link_via_ajax");
|
46 |
+
*/
|
47 |
+
public static function reg_access_link_via_ajax ()
|
48 |
+
{
|
49 |
+
do_action ("ws_plugin__s2member_before_reg_access_link_via_ajax", get_defined_vars ());
|
50 |
+
/**/
|
51 |
+
if (current_user_can ("create_users")) /* Check priveledges as well. */
|
52 |
+
if (($nonce = $_POST["ws_plugin__s2member_reg_access_link_via_ajax"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-reg-access-link-via-ajax") && ($p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))))
|
53 |
+
echo apply_filters ("ws_plugin__s2member_reg_access_link_via_ajax", c_ws_plugin__s2member_register_access::register_link_gen ($p["s2member_reg_access_link_subscr_gateway"], $p["s2member_reg_access_link_subscr_id"], $p["s2member_reg_access_link_custom"], $p["s2member_reg_access_link_item_number"]), get_defined_vars ());
|
54 |
+
/**/
|
55 |
+
exit (); /* Clean exit. */
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
?>
|
includes/classes/register-in.inc.php
ADDED
@@ -0,0 +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_register_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_register_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Handles registration links.
|
23 |
+
Attach to: add_action("init");
|
24 |
+
*/
|
25 |
+
public static function register ()
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_register", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
if ($_GET["s2member_register"]) /* If they're attempting to access the registration system. */
|
30 |
+
{
|
31 |
+
if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", c_ws_plugin__s2member_utils_encryption::decrypt (trim (stripslashes ($_GET["s2member_register"]))))))
|
32 |
+
{
|
33 |
+
if (count ($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time" && $register[1] && $register[2] && $register[3] && $register[4] && $register[5])
|
34 |
+
{
|
35 |
+
if ($register[5] <= strtotime ("now") && $register[5] >= strtotime ("-2 days")) /* Customers have 2 days to register. */
|
36 |
+
{
|
37 |
+
setcookie ("s2member_subscr_gateway", c_ws_plugin__s2member_utils_encryption::encrypt ($register[1]), time () + 31556926, "/");
|
38 |
+
setcookie ("s2member_subscr_id", c_ws_plugin__s2member_utils_encryption::encrypt ($register[2]), time () + 31556926, "/");
|
39 |
+
setcookie ("s2member_custom", c_ws_plugin__s2member_utils_encryption::encrypt ($register[3]), time () + 31556926, "/");
|
40 |
+
setcookie ("s2member_level", c_ws_plugin__s2member_utils_encryption::encrypt ($register[4]), time () + 31556926, "/");
|
41 |
+
/**/
|
42 |
+
do_action ("ws_plugin__s2member_during_register", get_defined_vars ());
|
43 |
+
/**/
|
44 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ())
|
45 |
+
{
|
46 |
+
echo '<script type="text/javascript">' . "\n";
|
47 |
+
echo "window.location = '" . esc_js (c_ws_plugin__s2member_utils_urls::wp_signup_url ()) . "';";
|
48 |
+
echo '</script>' . "\n";
|
49 |
+
}
|
50 |
+
else /* Otherwise, this is NOT a Multisite install. Or it is, but the Super Admin is NOT selling Blogs. */
|
51 |
+
{
|
52 |
+
echo '<script type="text/javascript">' . "\n";
|
53 |
+
echo "window.location = '" . esc_js (c_ws_plugin__s2member_utils_urls::wp_register_url ()) . "';";
|
54 |
+
echo '</script>' . "\n";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
/**/
|
60 |
+
echo '<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.';
|
61 |
+
/**/
|
62 |
+
exit (); /* $_GET["s2member_register"] has expired. Or it is simply invalid. */
|
63 |
+
}
|
64 |
+
/**/
|
65 |
+
do_action ("ws_plugin__s2member_after_register", get_defined_vars ());
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
?>
|
includes/classes/register.inc.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_register"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_register
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Handles registration links.
|
23 |
+
Attach to: add_action("init");
|
24 |
+
*/
|
25 |
+
public static function register ()
|
26 |
+
{
|
27 |
+
if ($_GET["s2member_register"]) /* Call inner function? */
|
28 |
+
{
|
29 |
+
return c_ws_plugin__s2member_register_in::register ();
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
?>
|
includes/classes/registration-times.inc.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_registration_times"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_registration_times
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that synchronizes Paid Registration Times with Role assignments.
|
23 |
+
Attach to: add_action("set_user_role");
|
24 |
+
*/
|
25 |
+
public static function synchronize_paid_reg_times ($user_id = FALSE, $role = FALSE)
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_synchronize_paid_reg_times", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
if ($user_id && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
32 |
+
if (($level = c_ws_plugin__s2member_user_access::user_access_level ($user)) > 0)
|
33 |
+
{
|
34 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
35 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
36 |
+
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
37 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
38 |
+
}
|
39 |
+
/**/
|
40 |
+
return; /* Return for uniformity. */
|
41 |
+
}
|
42 |
+
/*
|
43 |
+
Retrieves a Registration Time.
|
44 |
+
$user_id defaults to the current User; if logged in.
|
45 |
+
*/
|
46 |
+
public static function registration_time ($user_id = FALSE)
|
47 |
+
{
|
48 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
49 |
+
do_action ("ws_plugin__s2member_before_registration_time", get_defined_vars ());
|
50 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
51 |
+
/**/
|
52 |
+
$user = ($user_id) ? new WP_User ($user_id) : ( (is_user_logged_in ()) ? wp_get_current_user () : false);
|
53 |
+
/**/
|
54 |
+
if (is_object ($user) && ($user_id = $user->ID) && $user->user_registered)
|
55 |
+
{
|
56 |
+
return apply_filters ("ws_plugin__s2member_registration_time", strtotime ($user->user_registered), get_defined_vars ());
|
57 |
+
}
|
58 |
+
else /* Else we return a default value of 0, because there is insufficient data. */
|
59 |
+
return apply_filters ("ws_plugin__s2member_registration_time", 0, get_defined_vars ());
|
60 |
+
}
|
61 |
+
/*
|
62 |
+
Retrieves a Paid Registration Time.
|
63 |
+
|
64 |
+
The $level argument is optional. It defaults to the first/initial Paid Registration Time, regardless of Level#.
|
65 |
+
Or you could do this: s2member_paid_registration_time("level1"); which will give you the Registration Time at Level #1.
|
66 |
+
If a User/Member has never paid for Level #1 ( i.e. they signed up at Level#2 ), the function will return 0.
|
67 |
+
|
68 |
+
Here are some other examples:
|
69 |
+
$time = c_ws_plugin__s2member_registration_times::registration_time (); // ... first registration time ( free or otherwise ).
|
70 |
+
$time = c_ws_plugin__s2member_registration_times::paid_registration_time (); // ... first "paid" registration and/or upgrade time.
|
71 |
+
$time = c_ws_plugin__s2member_registration_times::paid_registration_time ("level1"); // ... first "paid" registration or upgrade time at Level#1.
|
72 |
+
$time = c_ws_plugin__s2member_registration_times::paid_registration_time ("level2"); // ... first "paid" registration or upgrade time at Level#2.
|
73 |
+
$time = c_ws_plugin__s2member_registration_times::paid_registration_time ("level3"); // ... first "paid" registration or upgrade time at Level#3.
|
74 |
+
$time = c_ws_plugin__s2member_registration_times::paid_registration_time ("level4"); // ... first "paid" registration or upgrade time at Level#4.
|
75 |
+
|
76 |
+
The argument $user_id defaults to the current User; if logged in.
|
77 |
+
*/
|
78 |
+
public static function paid_registration_time ($level = FALSE, $user_id = FALSE)
|
79 |
+
{
|
80 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
81 |
+
do_action ("ws_plugin__s2member_before_paid_registration_time", get_defined_vars ());
|
82 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
83 |
+
/**/
|
84 |
+
$level = (!strlen ($level)) ? "level" : "level" . preg_replace ("/[^0-9]/", "", $level);
|
85 |
+
$user = ($user_id) ? new WP_User ($user_id) : ( (is_user_logged_in ()) ? wp_get_current_user () : false);
|
86 |
+
/**/
|
87 |
+
if ($level && is_object ($user) && ($user_id = $user->ID) && is_array ($pr_times = get_user_option ("s2member_paid_registration_times", $user_id)))
|
88 |
+
{
|
89 |
+
return apply_filters ("ws_plugin__s2member_paid_registration_time", (int)$pr_times[$level], get_defined_vars ());
|
90 |
+
}
|
91 |
+
else /* Else we return a default value of 0, because there is insufficient data. */
|
92 |
+
return apply_filters ("ws_plugin__s2member_paid_registration_time", 0, get_defined_vars ());
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
?>
|
includes/classes/registrations.inc.php
ADDED
@@ -0,0 +1,839 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_registrations"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_registrations
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
This function filters WordPress® generated Passwords.
|
23 |
+
Attach to: add_filter("random_password");
|
24 |
+
*/
|
25 |
+
public static function generate_password ($password = FALSE)
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_generate_password", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
32 |
+
if ($custom = trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"])))
|
33 |
+
{
|
34 |
+
$password = $custom; /* Yes, use s2Member custom Password supplied by User. */
|
35 |
+
}
|
36 |
+
/**/
|
37 |
+
$GLOBALS["ws_plugin__s2member_generate_password_return"] = $password; /* Global reference. */
|
38 |
+
/**/
|
39 |
+
return apply_filters ("ws_plugin__s2member_generate_password", $password, get_defined_vars ());
|
40 |
+
}
|
41 |
+
/*
|
42 |
+
Function that filters Multisite User validation.
|
43 |
+
Attach to: add_filter("wpmu_validate_user_signup");
|
44 |
+
|
45 |
+
This can ONLY be fired through `/wp-signup.php` on the front-side.
|
46 |
+
Or through `/register` via BuddyPress.
|
47 |
+
*/
|
48 |
+
public static function ms_validate_user_signup ($result = FALSE)
|
49 |
+
{
|
50 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
51 |
+
do_action ("ws_plugin__s2member_before_ms_validate_user_signup", get_defined_vars ());
|
52 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
53 |
+
/**/
|
54 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
55 |
+
if (!is_admin () && ( (preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && preg_match ("/^validate-(user|blog)-signup$/", $_POST["stage"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_REGISTER_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]))))
|
56 |
+
{
|
57 |
+
if (c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($result["user_name"], $result["user_email"]))
|
58 |
+
$result["errors"] = new WP_Error ();
|
59 |
+
/**/
|
60 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
61 |
+
do_action ("ws_plugin__s2member_during_ms_validate_user_signup", get_defined_vars ());
|
62 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
63 |
+
}
|
64 |
+
/**/
|
65 |
+
return apply_filters ("ws_plugin__s2member_ms_validate_user_signup", $result, get_defined_vars ());
|
66 |
+
}
|
67 |
+
/*
|
68 |
+
Function that adds hidden fields to POST vars on signup.
|
69 |
+
Attach to: add_filter("signup_hidden_fields");
|
70 |
+
|
71 |
+
This can ONLY be fired through `/wp-signup.php` on the front-side.
|
72 |
+
Or through `/register` via BuddyPress.
|
73 |
+
*/
|
74 |
+
public static function ms_process_signup_hidden_fields ()
|
75 |
+
{
|
76 |
+
do_action ("ws_plugin__s2member_before_ms_process_signup_hidden_fields", get_defined_vars ());
|
77 |
+
/**/
|
78 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
79 |
+
if (!is_admin () && ( (preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && preg_match ("/^validate-(user|blog)-signup$/", $_POST["stage"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_REGISTER_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]))))
|
80 |
+
{
|
81 |
+
foreach ((array)c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
82 |
+
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
83 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
84 |
+
echo '<input type="hidden" name="' . esc_attr ($key) . '" value="' . esc_attr (maybe_serialize ($value)) . '" />' . "\n";
|
85 |
+
/**/
|
86 |
+
do_action ("ws_plugin__s2member_during_ms_process_signup_hidden_fields", get_defined_vars ());
|
87 |
+
}
|
88 |
+
/**/
|
89 |
+
do_action ("ws_plugin__s2member_after_ms_process_signup_hidden_fields", get_defined_vars ());
|
90 |
+
}
|
91 |
+
/*
|
92 |
+
Function that adds customs fields to $meta on signup.
|
93 |
+
Attach to: add_filter("add_signup_meta");
|
94 |
+
Attach to: add_filter("bp_signup_usermeta");
|
95 |
+
|
96 |
+
This can ONLY be fired through `/wp-signup.php` on the front-side.
|
97 |
+
Or possibly through `/user-new.php` in the admin.
|
98 |
+
Or through `/register` via BuddyPress.
|
99 |
+
*/
|
100 |
+
public static function ms_process_signup_meta ($meta = FALSE)
|
101 |
+
{
|
102 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
103 |
+
/**/
|
104 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
105 |
+
do_action ("ws_plugin__s2member_before_ms_process_signup_meta", get_defined_vars ());
|
106 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
107 |
+
/**/
|
108 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
109 |
+
if ((c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php") || (!is_admin () && ( (preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && preg_match ("/^validate-(user|blog)-signup$/", $_POST["stage"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_REGISTER_SLUG, "/") . "/", $_SERVER["REQUEST_URI"])))))
|
110 |
+
{
|
111 |
+
c_ws_plugin__s2member_email_configs::email_config (); /* Configures From: header used in notifications. */
|
112 |
+
/**/
|
113 |
+
foreach ((array)c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
114 |
+
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
115 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
116 |
+
$meta["s2member_ms_signup_meta"][$key] = maybe_unserialize ($value);
|
117 |
+
}
|
118 |
+
/**/
|
119 |
+
return apply_filters ("ws_plugin__s2member_ms_process_signup_meta", $meta, get_defined_vars ());
|
120 |
+
}
|
121 |
+
/*
|
122 |
+
This routine intersects with `wpmu_activate_signup()` through s2Member's Multisite Networking patch.
|
123 |
+
Attach to: add_filter("_wpmu_activate_existing_error_");
|
124 |
+
|
125 |
+
This function should return the same array that `wpmu_activate_signup()` returns; with the assumption that $user_already_exists.
|
126 |
+
* Which is exactly where this function intersects inside the `/wp-includes/ms-functions.php`.
|
127 |
+
|
128 |
+
This can ONLY be fired through `/wp-activate.php` on the front-side.
|
129 |
+
Or through `/activate` via BuddyPress.
|
130 |
+
*/
|
131 |
+
public static function ms_activate_existing_user ($__error = FALSE, $vars = FALSE)
|
132 |
+
{
|
133 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
134 |
+
do_action ("ws_plugin__s2member_before_ms_activate_existing_user", get_defined_vars ());
|
135 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
136 |
+
/**/
|
137 |
+
if (is_array ($vars)) /* Make sure this IS an array first. */
|
138 |
+
extract($vars); /* Extract all variables from `wpmu_activate_signup()` function. */
|
139 |
+
/**/
|
140 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
141 |
+
if (!is_admin () && ( (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]))))
|
142 |
+
{
|
143 |
+
if ($user_id && $password && $meta && $user_already_exists && c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email))
|
144 |
+
{
|
145 |
+
$role = ($meta["new_role"]) ? $meta["new_role"] : get_site_option ("default_role"); /* Role? */
|
146 |
+
add_user_to_blog ($meta["add_to_blog"], $user_id, $meta["new_role"]); /* Add existing User to Blog. */
|
147 |
+
/**/
|
148 |
+
wp_update_user (array ("ID" => $user_id, "user_pass" => $password)); /* Update Password so it's the same as in the following msg. */
|
149 |
+
wpmu_welcome_user_notification ($user_id, $password, $meta); /* Send welcome letter via email just like `wpmu_activate_signup()` does. */
|
150 |
+
/**/
|
151 |
+
do_action ("wpmu_activate_user", $user_id, $password, $meta); /* Process Hook that would have been fired inside `wpmu_activate_signup()`. */
|
152 |
+
/**/
|
153 |
+
return apply_filters ("ws_plugin__s2member_ms_activate_existing_user", array ("user_id" => $user_id, "password" => $password, "meta" => $meta), get_defined_vars ());
|
154 |
+
}
|
155 |
+
}
|
156 |
+
/**/
|
157 |
+
return apply_filters ("ws_plugin__s2member_ms_activate_existing_user", $__error, get_defined_vars ()); /* Else, return the standardized error. */
|
158 |
+
}
|
159 |
+
/*
|
160 |
+
Function for configuring new users.
|
161 |
+
Attach to: add_action("wpmu_activate_user");
|
162 |
+
|
163 |
+
This can ONLY be fired in the admin via ( `/user-new.php` ).
|
164 |
+
Or also during an actual activation; through `/wp-activate.php`.
|
165 |
+
Or also during an actual activation; through `/activate` via BuddyPress.
|
166 |
+
*/
|
167 |
+
public static function configure_user_on_ms_user_activation ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
168 |
+
{
|
169 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
170 |
+
/**/
|
171 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
172 |
+
do_action ("ws_plugin__s2member_before_configure_user_on_ms_user_activation", get_defined_vars ());
|
173 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
174 |
+
/**/
|
175 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
176 |
+
if ((c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php" && isset ($_POST["noconfirmation"])) || (!is_admin () && ( (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"])))))
|
177 |
+
{
|
178 |
+
c_ws_plugin__s2member_registrations::configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
179 |
+
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
180 |
+
}
|
181 |
+
/**/
|
182 |
+
do_action ("ws_plugin__s2member_after_configure_user_on_ms_user_activation", get_defined_vars ());
|
183 |
+
/**/
|
184 |
+
return; /* Return for uniformity. */
|
185 |
+
}
|
186 |
+
/*
|
187 |
+
Function for configuring new users.
|
188 |
+
Attach to: add_action("wpmu_activate_blog");
|
189 |
+
|
190 |
+
This does NOT fire for a Super Admin managing Network Blogs.
|
191 |
+
~ Actually they do; BUT it's blocked by the routine below.
|
192 |
+
Which is good. A Super Admin should NOT trigger this event.
|
193 |
+
|
194 |
+
This function should ONLY be fired through `/wp-activate.php`.
|
195 |
+
Or also through `/activate` via BuddyPress.
|
196 |
+
*/
|
197 |
+
public static function configure_user_on_ms_blog_activation ($blog_id = FALSE, $user_id = FALSE, $password = FALSE, $title = FALSE, $meta = FALSE)
|
198 |
+
{
|
199 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
200 |
+
do_action ("ws_plugin__s2member_before_configure_user_on_ms_blog_activation", get_defined_vars ());
|
201 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
202 |
+
/**/
|
203 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
204 |
+
if (!is_admin () && ( (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]))))
|
205 |
+
{
|
206 |
+
c_ws_plugin__s2member_registrations::configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
207 |
+
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
208 |
+
}
|
209 |
+
/**/
|
210 |
+
do_action ("ws_plugin__s2member_after_configure_user_on_ms_blog_activation", get_defined_vars ());
|
211 |
+
/**/
|
212 |
+
return; /* Return for uniformity. */
|
213 |
+
}
|
214 |
+
/*
|
215 |
+
This routine intersects with `register_new_user()` through s2Member's Multisite Networking patch.
|
216 |
+
Attach to: add_filter("registration_errors");
|
217 |
+
|
218 |
+
This function Filters registration errors inside `/wp-login.php` via `register_new_user()`.
|
219 |
+
When an existing Multisite User is registering, this takes over registration processing.
|
220 |
+
|
221 |
+
This can ONLY be fired through `/wp-login.php` on the front-side.
|
222 |
+
*/
|
223 |
+
public static function ms_register_existing_user ($errors = FALSE, $user_login = FALSE, $user_email = FALSE)
|
224 |
+
{
|
225 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
226 |
+
do_action ("ws_plugin__s2member_before_ms_register_existing_user", get_defined_vars ());
|
227 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
228 |
+
/**/
|
229 |
+
if (is_multisite ()) /* Should ONLY be processed with Multisite Networking. */
|
230 |
+
if (!is_admin () && preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
|
231 |
+
if (is_wp_error ($errors) && $errors->get_error_code ())
|
232 |
+
{
|
233 |
+
if (($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email)))
|
234 |
+
{
|
235 |
+
foreach ($errors->get_error_codes () as $error_code)
|
236 |
+
if (!preg_match ("/^(username_exists|email_exists)$/i", $error_code))
|
237 |
+
$other_important_errors_exist = true;
|
238 |
+
/**/
|
239 |
+
if (!$other_important_errors_exist) /* Only if/when NO other important errors exist. */
|
240 |
+
{
|
241 |
+
$user_pass = wp_generate_password (); /* A new Password is now generated here. */
|
242 |
+
c_ws_plugin__s2member_registrations::ms_create_existing_user ($user_login, $user_email, $user_pass, $user_id);
|
243 |
+
update_user_option ($user_id, "default_password_nag", true, true); /* Set up the Password change nag screen. */
|
244 |
+
wp_new_user_notification ($user_id, $user_pass); /* Welcome email, just like `register_new_user()` does. */
|
245 |
+
/**/
|
246 |
+
$redirect_to = trim (stripslashes ($_REQUEST["redirect_to"]));
|
247 |
+
$redirect_to = ($redirect_to) ? $redirect_to : add_query_arg ("checkemail", urlencode ("registered"), wp_login_url ());
|
248 |
+
/**/
|
249 |
+
do_action ("ws_plugin__s2member_during_ms_register_existing_user", get_defined_vars ());
|
250 |
+
/**/
|
251 |
+
wp_safe_redirect($redirect_to); /* Use safe redirect; like `register_new_user()`. */
|
252 |
+
/**/
|
253 |
+
exit (); /* Clean exit. */
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
else if (($r = wpmu_validate_user_signup ($user_login, $user_email)) && is_wp_error ($e = $r["errors"]) && $e->get_error_code ())
|
258 |
+
$errors->add ($e->get_error_code (), $e->get_error_message ());
|
259 |
+
/**/
|
260 |
+
do_action ("ws_plugin__s2member_after_ms_register_existing_user", get_defined_vars ());
|
261 |
+
/**/
|
262 |
+
return apply_filters ("ws_plugin__s2member_ms_register_existing_user", $errors, get_defined_vars ());
|
263 |
+
}
|
264 |
+
/*
|
265 |
+
For Multisite Networksing, this function is used to add a User to an existing Blog; and to simulate `wp_create_user()` behavior.
|
266 |
+
The $user_id value will be returned by this function, just like `wp_create_user()` does.
|
267 |
+
* This function will fire the Hook `user_register`.
|
268 |
+
*/
|
269 |
+
public static function ms_create_existing_user ($user_login = FALSE, $user_email = FALSE, $user_pass = FALSE, $user_id = FALSE)
|
270 |
+
{
|
271 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
272 |
+
do_action ("ws_plugin__s2member_before_ms_create_existing_user", get_defined_vars ());
|
273 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
274 |
+
/**/
|
275 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
276 |
+
{
|
277 |
+
if (($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email))) && $user_pass)
|
278 |
+
{
|
279 |
+
$role = get_option ("default_role"); /* Use default Role. */
|
280 |
+
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => $role)); /* Add existing User. */
|
281 |
+
wp_update_user (array ("ID" => $user_id, "user_pass" => $user_pass)); /* Update Password to $user_pass. */
|
282 |
+
/**/
|
283 |
+
do_action ("ws_plugin__s2member_during_ms_create_existing_user", get_defined_vars ());
|
284 |
+
do_action ("user_register", $user_id); /* So s2Member knows a User is registering. */
|
285 |
+
/**/
|
286 |
+
return apply_filters ("ws_plugin__s2member_ms_create_existing_user", $user_id, get_defined_vars ());
|
287 |
+
}
|
288 |
+
}
|
289 |
+
/**/
|
290 |
+
return apply_filters ("ws_plugin__s2member_ms_create_existing_user", false, get_defined_vars ());
|
291 |
+
}
|
292 |
+
/*
|
293 |
+
Function for configuring new users.
|
294 |
+
Attach to: add_action("user_register");
|
295 |
+
|
296 |
+
This also receives Multisite events.
|
297 |
+
Attach to: add_action("wpmu_activate_user");
|
298 |
+
Attach to: add_action("wpmu_activate_blog");
|
299 |
+
|
300 |
+
The Hook `user_register` is also fired by calling:
|
301 |
+
`c_ws_plugin__s2member_registrations::ms_create_existing_user()`
|
302 |
+
`wpmu_create_user()`
|
303 |
+
|
304 |
+
This function also receives simulated events from s2Member Pro.
|
305 |
+
*/
|
306 |
+
public static function configure_user_registration ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
307 |
+
{
|
308 |
+
global $wpdb; /* Global database object may be required for this routine. */
|
309 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
310 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
311 |
+
static $email_config, $processed; /* No duplicate processing. */
|
312 |
+
/**/
|
313 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
314 |
+
do_action ("ws_plugin__s2member_before_configure_user_registration", get_defined_vars ());
|
315 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
316 |
+
/**/
|
317 |
+
/* With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_user|blog`. */
|
318 |
+
if (!$email_config && ($email_config = true)) /* Anytime this routine is fired; we config email; no exceptions. */
|
319 |
+
c_ws_plugin__s2member_email_configs::email_config (); /* Configures From: header that will be used in new user notifications. */
|
320 |
+
/**/
|
321 |
+
if (!$processed /* Process only once. Safeguard this routine against duplicate processing via plugins ( or even WordPress® itself ). */
|
322 |
+
&& (is_array ($post = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))) || is_array ($meta = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($meta))))/**/
|
323 |
+
/* These negative matches are designed to prevent this routine from running under certain conditions; where we need to wait for `wpmu_activate_user|blog` instead of processing now. */
|
324 |
+
&& ! (is_multisite () && c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php" && isset ($post["noconfirmation"]) && is_super_admin () && func_num_args () !== 3)/**/
|
325 |
+
&& ! (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"]) && func_num_args () !== 3) /* If activating; we MUST have a $meta arg to proceed. */
|
326 |
+
&& ! (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]) && func_num_args () !== 3)
|
327 |
+
/* The $meta argument is ONLY passed in by hand-offs from `wpmu_activate_user|blog`. So this is how we check for these events. */
|
328 |
+
/**/
|
329 |
+
&& $user_id && is_object ($user = new WP_User ($user_id)) && $user->ID && ($processed = true)) /* Process only once. */
|
330 |
+
{
|
331 |
+
foreach ((array)$post as $key => $value) /* Scan $post vars; adding `custom_reg_field` uniformity keys. */
|
332 |
+
if (preg_match ("/^ws_plugin__s2member_user_new_/", $key)) /* Looking for `user_new` keys here. */
|
333 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
334 |
+
$post[$key] = $value; /* Add these keys for uniformity. */
|
335 |
+
unset ($key, $value); /* Prevents bleeding vars into Hooks/Filters. */
|
336 |
+
/**/
|
337 |
+
if (!is_admin () && ($post["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"] || $post["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"] || $post["ws_plugin__s2member_custom_reg_field_s2member_custom"] || $post["ws_plugin__s2member_custom_reg_field_s2member_ccaps"] || $post["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"] || $post["ws_plugin__s2member_custom_reg_field_s2member_notes"]))
|
338 |
+
exit ("s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!");
|
339 |
+
/**/
|
340 |
+
$_pm = array_merge ((array)$post, (array)$meta); /* Merge these two data sources together now; ALWAYS after the security routine above ^. */
|
341 |
+
unset ($post, $meta); /* These can be unset now; no longer needed ( we use $_pm instead, it's a combination of the two arrays ). */
|
342 |
+
/**/
|
343 |
+
if (!is_admin () /* Only run this particular routine whenever a Member Level [1-4] is registering themselves with paid authorization cookies in their browser. */
|
344 |
+
&& ($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"])))/**/
|
345 |
+
&& (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1")))
|
346 |
+
/* ^ This is for security ^ It checks the database to make sure the User/Member has not already registered in the past, with the same Paid Subscr. ID. */
|
347 |
+
{ /*
|
348 |
+
This routine could be processed through `wp-login.php?action=register`, `wp-activate.php`, or `/activate` via BuddyPress`.
|
349 |
+
This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
|
350 |
+
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
351 |
+
*/
|
352 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
353 |
+
/**/
|
354 |
+
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
355 |
+
list ($level, $ccaps, $eotper) = preg_split ("/\:/", $level, 3);
|
356 |
+
$role = "s2member_level" . $level; /* Level 1-4. */
|
357 |
+
/**/
|
358 |
+
$email = $user->user_email;
|
359 |
+
$login = $user->user_login;
|
360 |
+
$ip = $_SERVER["REMOTE_ADDR"];
|
361 |
+
$cv = preg_split ("/\|/", $custom);
|
362 |
+
/**/
|
363 |
+
if ($eotper) /* If a specific EOT Period has been attached; calculate that now. */
|
364 |
+
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $eotper);
|
365 |
+
/**/
|
366 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
367 |
+
/**/
|
368 |
+
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
369 |
+
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
370 |
+
/**/
|
371 |
+
if (! ($fname = $user->first_name))
|
372 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
373 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
374 |
+
/**/
|
375 |
+
if (!$fname) /* Also try BuddyPress. */
|
376 |
+
if ($_pm["field_1"]) /* BuddyPress. */
|
377 |
+
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
378 |
+
/**/
|
379 |
+
if (! ($lname = $user->last_name))
|
380 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
381 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
382 |
+
/**/
|
383 |
+
if (!$lname) /* Also try BuddyPress. */
|
384 |
+
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
385 |
+
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
386 |
+
/**/
|
387 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
388 |
+
/**/
|
389 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
390 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
391 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
392 |
+
/**/
|
393 |
+
if (!$pass) /* Also try BuddyPress Password. */
|
394 |
+
if ($_pm["signup_password"]) /* BuddyPress. */
|
395 |
+
$pass = $_pm["signup_password"];
|
396 |
+
/**/
|
397 |
+
if ($pass) /* No Password nag. Update this globally. */
|
398 |
+
{
|
399 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
400 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
401 |
+
}
|
402 |
+
/**/
|
403 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
404 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
|
405 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
406 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
407 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
408 |
+
/**/
|
409 |
+
if (!$user->first_name && $fname)
|
410 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
411 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
412 |
+
/**/
|
413 |
+
if (!$user->last_name && $lname)
|
414 |
+
update_user_meta ($user_id, "last_name", $lname);
|
415 |
+
/**/
|
416 |
+
if (is_multisite ()) /* Should we handle Main Site permissions and Originating Blog ID#? */
|
417 |
+
{
|
418 |
+
if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
|
419 |
+
remove_user_from_blog ($user_id, $current_site->blog_id); /* No Main Site Role. */
|
420 |
+
/**/
|
421 |
+
if (!get_user_meta ($user_id, "s2member_originating_blog", true)) /* Recorded yet? */
|
422 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
423 |
+
}
|
424 |
+
/**/
|
425 |
+
if ($current_role !== $role) /* Only if NOT the current Role. */
|
426 |
+
$user->set_role ($role); /* s2Member. */
|
427 |
+
/**/
|
428 |
+
if (!preg_match ("/^\+/", $ccaps))
|
429 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
430 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
431 |
+
$user->remove_cap ($ccap = $cap);
|
432 |
+
/**/
|
433 |
+
if ($ccaps) /* Add Custom Capabilities. */
|
434 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($ccaps, "+")) as $ccap)
|
435 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
436 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
437 |
+
/**/
|
438 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
439 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
440 |
+
{
|
441 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
442 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
443 |
+
/**/
|
444 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
445 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
446 |
+
}
|
447 |
+
/**/
|
448 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
449 |
+
/**/
|
450 |
+
if (($transient = "s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array ($subscr_payment = get_transient ($transient)))
|
451 |
+
{
|
452 |
+
$proxy = array ("s2member_paypal_notify" => "1", "s2member_paypal_proxy" => stripslashes ($subscr_payment["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen ());
|
453 |
+
c_ws_plugin__s2member_utils_urls::remote (add_query_arg (urlencode_deep ($proxy), site_url ("/")), stripslashes_deep ($subscr_payment), array ("timeout" => 20));
|
454 |
+
delete_transient($transient); /* This can be deleted now. */
|
455 |
+
}
|
456 |
+
/**/
|
457 |
+
if (($transient = "s2m_" . md5 ("s2member_transient_ipn_signup_vars_" . $subscr_id)) && is_array ($ipn_signup_vars = get_transient ($transient)))
|
458 |
+
{
|
459 |
+
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars); /* For future reference. */
|
460 |
+
delete_transient($transient); /* This can be deleted now. */
|
461 |
+
}
|
462 |
+
/**/
|
463 |
+
setcookie ("s2member_signup_tracking", c_ws_plugin__s2member_utils_encryption::encrypt ($subscr_id), time () + 31556926, "/");
|
464 |
+
/**/
|
465 |
+
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
466 |
+
{
|
467 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
468 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
469 |
+
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
470 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
471 |
+
}
|
472 |
+
/**/
|
473 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
474 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars ());
|
475 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
476 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
477 |
+
}
|
478 |
+
/**/
|
479 |
+
else if (!is_admin ()) /* Otherwise, if we are NOT inside the Dashboard during the creation of this account. */
|
480 |
+
{ /*
|
481 |
+
This routine could be processed through `wp-login.php?action=register`, `wp-activate.php`, or `/activate` via BuddyPress`.
|
482 |
+
This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
|
483 |
+
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
484 |
+
*/
|
485 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
486 |
+
/**/
|
487 |
+
$role = ($current_role = c_ws_plugin__s2member_user_access::user_access_role ($user));
|
488 |
+
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise default. */
|
489 |
+
/**/
|
490 |
+
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
491 |
+
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
492 |
+
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
493 |
+
$level = (!$level) ? "0" : $level;
|
494 |
+
/**/
|
495 |
+
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
|
496 |
+
/**/
|
497 |
+
$email = $user->user_email;
|
498 |
+
$login = $user->user_login;
|
499 |
+
$ip = $_SERVER["REMOTE_ADDR"];
|
500 |
+
$custom = $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"];
|
501 |
+
$subscr_id = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
|
502 |
+
$subscr_gateway = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
|
503 |
+
$cv = preg_split ("/\|/", $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
|
504 |
+
/**/
|
505 |
+
$auto_eot_time = ($eot = $_pm["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
506 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
507 |
+
/**/
|
508 |
+
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
509 |
+
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
510 |
+
/**/
|
511 |
+
if (! ($fname = $user->first_name))
|
512 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
513 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
514 |
+
/**/
|
515 |
+
if (!$fname) /* Also try BuddyPress. */
|
516 |
+
if ($_pm["field_1"]) /* BuddyPress. */
|
517 |
+
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
518 |
+
/**/
|
519 |
+
if (! ($lname = $user->last_name))
|
520 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
521 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
522 |
+
/**/
|
523 |
+
if (!$lname) /* Also try BuddyPress. */
|
524 |
+
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
525 |
+
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
526 |
+
/**/
|
527 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
528 |
+
/**/
|
529 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
530 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
531 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
532 |
+
/**/
|
533 |
+
if (!$pass) /* Also try BuddyPress Password. */
|
534 |
+
if ($_pm["signup_password"]) /* BuddyPress. */
|
535 |
+
$pass = $_pm["signup_password"];
|
536 |
+
/**/
|
537 |
+
if ($pass) /* No Password nag. Update this globally. */
|
538 |
+
{
|
539 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
540 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
541 |
+
}
|
542 |
+
/**/
|
543 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
544 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
|
545 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
546 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
547 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
548 |
+
/**/
|
549 |
+
if (!$user->first_name && $fname)
|
550 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
551 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
552 |
+
/**/
|
553 |
+
if (!$user->last_name && $lname)
|
554 |
+
update_user_meta ($user_id, "last_name", $lname);
|
555 |
+
/**/
|
556 |
+
if (is_multisite ()) /* Should we handle Main Site permissions and Originating Blog ID#? */
|
557 |
+
{
|
558 |
+
if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
|
559 |
+
remove_user_from_blog ($user_id, $current_site->blog_id); /* No Main Site Role. */
|
560 |
+
/**/
|
561 |
+
if (!get_user_meta ($user_id, "s2member_originating_blog", true)) /* Recorded yet? */
|
562 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
563 |
+
}
|
564 |
+
/**/
|
565 |
+
if ($current_role !== $role) /* Only if NOT the current Role. */
|
566 |
+
$user->set_role ($role); /* s2Member. */
|
567 |
+
/**/
|
568 |
+
if (!preg_match ("/^\+/", $ccaps))
|
569 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
570 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
571 |
+
$user->remove_cap ($ccap = $cap);
|
572 |
+
/**/
|
573 |
+
if ($ccaps) /* Add Custom Capabilities. */
|
574 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($ccaps, "+")) as $ccap)
|
575 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
576 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
577 |
+
/**/
|
578 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
579 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
580 |
+
{
|
581 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
582 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
583 |
+
/**/
|
584 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
585 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
586 |
+
}
|
587 |
+
/**/
|
588 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
589 |
+
/**/
|
590 |
+
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
591 |
+
{
|
592 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
593 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
594 |
+
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
595 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
596 |
+
}
|
597 |
+
/**/
|
598 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
599 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars ());
|
600 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
601 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
602 |
+
}
|
603 |
+
/**/
|
604 |
+
else if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php")
|
605 |
+
{ /*
|
606 |
+
This routine can ONLY be processed through `user-new.php` in the Administrative panel.
|
607 |
+
*/
|
608 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
609 |
+
/**/
|
610 |
+
$role = ($current_role = c_ws_plugin__s2member_user_access::user_access_role ($user));
|
611 |
+
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise default. */
|
612 |
+
/**/
|
613 |
+
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
614 |
+
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
615 |
+
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
616 |
+
$level = (!$level) ? "0" : $level;
|
617 |
+
/**/
|
618 |
+
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
|
619 |
+
/**/
|
620 |
+
$email = $user->user_email;
|
621 |
+
$login = $user->user_login;
|
622 |
+
$ip = ""; /* N/Applicable. */
|
623 |
+
$custom = $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"];
|
624 |
+
$subscr_id = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
|
625 |
+
$subscr_gateway = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
|
626 |
+
$cv = preg_split ("/\|/", $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
|
627 |
+
/**/
|
628 |
+
$auto_eot_time = ($eot = $_pm["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
629 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
630 |
+
/**/
|
631 |
+
$opt_in = ($_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
|
632 |
+
/**/
|
633 |
+
if (! ($fname = $user->first_name)) /* `Users -> Add New`. */
|
634 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
635 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
636 |
+
/**/
|
637 |
+
if (! ($lname = $user->last_name)) /* `Users -> Add New`. */
|
638 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
639 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
640 |
+
/**/
|
641 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
642 |
+
/**/
|
643 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
644 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
645 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
646 |
+
/**/
|
647 |
+
if (!$pass) /* Also try the `Users -> Add New` form. */
|
648 |
+
if ($_pm["pass1"]) /* Field in user-new.php. */
|
649 |
+
$pass = $_pm["pass1"];
|
650 |
+
/**/
|
651 |
+
if ($pass) /* No Password nag. Update this globally. */
|
652 |
+
{
|
653 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
654 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
655 |
+
}
|
656 |
+
/**/
|
657 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
658 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
|
659 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
660 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
661 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
662 |
+
/**/
|
663 |
+
if (!$user->first_name && $fname)
|
664 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
665 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
666 |
+
/**/
|
667 |
+
if (!$user->last_name && $lname)
|
668 |
+
update_user_meta ($user_id, "last_name", $lname);
|
669 |
+
/**/
|
670 |
+
if (is_multisite ()) /* Should we handle Main Site permissions and Originating Blog ID#? */
|
671 |
+
{
|
672 |
+
if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
|
673 |
+
remove_user_from_blog ($user_id, $current_site->blog_id); /* No Main Site Role. */
|
674 |
+
/**/
|
675 |
+
if (!get_user_meta ($user_id, "s2member_originating_blog", true)) /* Recorded yet? */
|
676 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
677 |
+
}
|
678 |
+
/**/
|
679 |
+
if ($current_role !== $role) /* Only if NOT the current Role. */
|
680 |
+
$user->set_role ($role); /* s2Member. */
|
681 |
+
/**/
|
682 |
+
if (!preg_match ("/^\+/", $ccaps))
|
683 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
684 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
685 |
+
$user->remove_cap ($ccap = $cap);
|
686 |
+
/**/
|
687 |
+
if ($ccaps) /* Add Custom Capabilities. */
|
688 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", ltrim ($ccaps, "+")) as $ccap)
|
689 |
+
if (strlen ($ccap)) /* Don't add empty Custom Capabilities. */
|
690 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
691 |
+
/**/
|
692 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
693 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
694 |
+
{
|
695 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
696 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
697 |
+
/**/
|
698 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
699 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
700 |
+
}
|
701 |
+
/**/
|
702 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
703 |
+
/**/
|
704 |
+
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
705 |
+
{
|
706 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
707 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
708 |
+
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
709 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
710 |
+
}
|
711 |
+
/**/
|
712 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
713 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars ());
|
714 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
715 |
+
}
|
716 |
+
/**/
|
717 |
+
if ($processed === "yes") /* If registration was processed by one of the routines above. */
|
718 |
+
{
|
719 |
+
if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
|
720 |
+
/**/
|
721 |
+
foreach (preg_split ("/[\r\n\t]+/", $urls) as $url) /* Notify each of the urls. */
|
722 |
+
/**/
|
723 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
|
724 |
+
if (($url = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($role)), $url)))
|
725 |
+
if (($url = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($level)), $url)))
|
726 |
+
if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($fname)), $url)))
|
727 |
+
if (($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($lname)), $url)))
|
728 |
+
if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($name)), $url)))
|
729 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($email)), $url)))
|
730 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($login)), $url)))
|
731 |
+
if (($url = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($pass)), $url)))
|
732 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
733 |
+
{
|
734 |
+
if (is_array ($fields) && !empty ($fields))
|
735 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
736 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
737 |
+
break;
|
738 |
+
/**/
|
739 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
740 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
741 |
+
}
|
742 |
+
/**/
|
743 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"])
|
744 |
+
{
|
745 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Registration";
|
746 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
747 |
+
/**/
|
748 |
+
$msg .= "role: %%role%%\n";
|
749 |
+
$msg .= "level: %%level%%\n";
|
750 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
751 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
752 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
753 |
+
$msg .= "user_email: %%user_email%%\n";
|
754 |
+
$msg .= "user_login: %%user_login%%\n";
|
755 |
+
$msg .= "user_pass: %%user_pass%%\n";
|
756 |
+
$msg .= "user_id: %%user_id%%\n";
|
757 |
+
/**/
|
758 |
+
if (is_array ($fields) && !empty ($fields))
|
759 |
+
foreach ($fields as $var => $val)
|
760 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
761 |
+
/**/
|
762 |
+
$msg .= "cv0: %%cv0%%\n";
|
763 |
+
$msg .= "cv1: %%cv1%%\n";
|
764 |
+
$msg .= "cv2: %%cv2%%\n";
|
765 |
+
$msg .= "cv3: %%cv3%%\n";
|
766 |
+
$msg .= "cv4: %%cv4%%\n";
|
767 |
+
$msg .= "cv5: %%cv5%%\n";
|
768 |
+
$msg .= "cv6: %%cv6%%\n";
|
769 |
+
$msg .= "cv7: %%cv7%%\n";
|
770 |
+
$msg .= "cv8: %%cv8%%\n";
|
771 |
+
$msg .= "cv9: %%cv9%%";
|
772 |
+
/**/
|
773 |
+
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
774 |
+
if (($msg = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($role), $msg)))
|
775 |
+
if (($msg = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($level), $msg)))
|
776 |
+
if (($msg = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($fname), $msg)))
|
777 |
+
if (($msg = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($lname), $msg)))
|
778 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($name), $msg)))
|
779 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($email), $msg)))
|
780 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($login), $msg)))
|
781 |
+
if (($msg = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($pass), $msg)))
|
782 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
783 |
+
{
|
784 |
+
if (is_array ($fields) && !empty ($fields))
|
785 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
786 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
787 |
+
break;
|
788 |
+
/**/
|
789 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
790 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"])) as $recipient)
|
791 |
+
($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_registration_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_registration_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;
|
792 |
+
}
|
793 |
+
}
|
794 |
+
/**/
|
795 |
+
if ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"])
|
796 |
+
/**/
|
797 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
|
798 |
+
if (($url = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($role)), $url)))
|
799 |
+
if (($url = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($level)), $url)))
|
800 |
+
if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($fname)), $url)))
|
801 |
+
if (($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($lname)), $url)))
|
802 |
+
if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($name)), $url)))
|
803 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($email)), $url)))
|
804 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($login)), $url)))
|
805 |
+
if (($url = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($pass)), $url)))
|
806 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
807 |
+
{
|
808 |
+
if (is_array ($fields) && !empty ($fields))
|
809 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
810 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
811 |
+
break;
|
812 |
+
/**/
|
813 |
+
if (($url = trim ($url))) /* Preserve remaining Replacements. */
|
814 |
+
/* Because the parent routine may perform replacements too. */
|
815 |
+
$GLOBALS["ws_plugin__s2member_registration_return_url"] = $url;
|
816 |
+
}
|
817 |
+
/**/
|
818 |
+
c_ws_plugin__s2member_list_servers::process_list_servers ($role, $level, $email, $fname, $lname, $ip, $opt_in, $user_id);
|
819 |
+
/**/
|
820 |
+
setcookie ("s2member_subscr_gateway", "", time () + 31556926, "/");
|
821 |
+
setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
|
822 |
+
setcookie ("s2member_custom", "", time () + 31556926, "/");
|
823 |
+
setcookie ("s2member_level", "", time () + 31556926, "/");
|
824 |
+
/**/
|
825 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
826 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration", get_defined_vars ());
|
827 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
828 |
+
}
|
829 |
+
}
|
830 |
+
/**/
|
831 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
832 |
+
do_action ("ws_plugin__s2member_after_configure_user_registration", get_defined_vars ());
|
833 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
834 |
+
/**/
|
835 |
+
return; /* Return for uniformity. */
|
836 |
+
}
|
837 |
+
}
|
838 |
+
}
|
839 |
+
?>
|
includes/classes/ruris-sp.inc.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_ruris_sp"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_ruris_sp
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function checks Request URI Level Access restrictions - for a specific URI/URL.
|
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_uri_protected_by_s2member($uri [ or full url ]);
|
28 |
+
- is_protected_by_s2member($uri [ or full url ], "uri");
|
29 |
+
|
30 |
+
Is the current User permitted/authorized?
|
31 |
+
- is_uri_permitted_by_s2member($uri [ or full url ]);
|
32 |
+
- is_permitted_by_s2member($uri [ or full url ], "uri");
|
33 |
+
|
34 |
+
see: `/s2member/includes/functions/api-functions.inc.php`.
|
35 |
+
*/
|
36 |
+
public static function check_specific_ruri_level_access ($__uri = FALSE, $check_user = TRUE)
|
37 |
+
{
|
38 |
+
do_action ("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
if ($__uri && is_string ($__uri)) /* We need to parse a URI. A full URL can be passed in. */
|
41 |
+
{
|
42 |
+
$path = parse_url ($__uri, PHP_URL_PATH); /* Parse req path. */
|
43 |
+
$query = parse_url ($__uri, PHP_URL_QUERY); /* Parse query. */
|
44 |
+
$uri = ($query) ? $path . "?" . $query : $path;
|
45 |
+
}
|
46 |
+
/**/
|
47 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars ());
|
48 |
+
/**/
|
49 |
+
if (!$excluded && $uri && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Has it been excluded? */
|
50 |
+
{
|
51 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
52 |
+
/**/
|
53 |
+
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, "/") . "$/", $uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
|
54 |
+
return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
55 |
+
/**/
|
56 |
+
else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
|
57 |
+
{
|
58 |
+
for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
|
59 |
+
{
|
60 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
|
61 |
+
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)
|
62 |
+
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
|
63 |
+
return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
|
64 |
+
}
|
65 |
+
}
|
66 |
+
/**/
|
67 |
+
do_action ("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars ());
|
68 |
+
}
|
69 |
+
/**/
|
70 |
+
return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars ());
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
?>
|
includes/classes/ruris.inc.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_ruris"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_ruris
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function for handling Request URI 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_uri_protected_by_s2member($uri [ or full url ]);
|
28 |
+
- is_protected_by_s2member($uri [ or full url ], "uri");
|
29 |
+
|
30 |
+
Is the current User permitted/authorized?
|
31 |
+
- is_uri_permitted_by_s2member($uri [ or full url ]);
|
32 |
+
- is_permitted_by_s2member($uri [ or full url ], "uri");
|
33 |
+
|
34 |
+
see: `/s2member/includes/functions/api-functions.inc.php`.
|
35 |
+
*/
|
36 |
+
public static function check_ruri_level_access ()
|
37 |
+
{
|
38 |
+
do_action ("ws_plugin__s2member_before_check_ruri_level_access", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_ruri_level_access_excluded", false, get_defined_vars ());
|
41 |
+
/**/
|
42 |
+
if (!$excluded && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Has it been excluded? */
|
43 |
+
{
|
44 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
45 |
+
/**/
|
46 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = 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")))
|
47 |
+
{
|
48 |
+
wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ruri-" . base64_encode ($_SERVER["REQUEST_URI"]), "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 ()));
|
49 |
+
exit ();
|
50 |
+
}
|
51 |
+
else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
|
52 |
+
{
|
53 |
+
for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
|
54 |
+
{
|
55 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
|
56 |
+
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)
|
57 |
+
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)))
|
58 |
+
{
|
59 |
+
wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ruri-" . base64_encode ($_SERVER["REQUEST_URI"]), "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 |
+
}
|
64 |
+
/**/
|
65 |
+
do_action ("ws_plugin__s2member_during_check_ruri_level_access", get_defined_vars ());
|
66 |
+
}
|
67 |
+
/**/
|
68 |
+
do_action ("ws_plugin__s2member_after_check_ruri_level_access", get_defined_vars ());
|
69 |
+
/**/
|
70 |
+
return; /* For uniformity. */
|
71 |
+
}
|
72 |
+
/*
|
73 |
+
Function that fills replacement code variables in URIs; collectively.
|
74 |
+
*/
|
75 |
+
public static function fill_ruri_level_access_rc_vars ($uris = FALSE, $user = FALSE)
|
76 |
+
{
|
77 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
78 |
+
do_action ("ws_plugin__s2member_before_fill_ruri_level_access_rc_vars", get_defined_vars ());
|
79 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
80 |
+
/**/
|
81 |
+
$user = (is_object ($user)) ? $user : wp_get_current_user ();
|
82 |
+
$user_login = (is_object ($user)) ? strtolower ($user->user_login) : "";
|
83 |
+
$user_id = (is_object ($user)) ? (string)$user->ID : "";
|
84 |
+
$user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
|
85 |
+
$user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
|
86 |
+
$user_ccaps = implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
87 |
+
/**/
|
88 |
+
$uris = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $uris);
|
89 |
+
$uris = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $uris);
|
90 |
+
$uris = preg_replace ("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_level), $uris);
|
91 |
+
$uris = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $uris);
|
92 |
+
$uris = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $uris);
|
93 |
+
/**/
|
94 |
+
return apply_filters ("ws_plugin__s2member_fill_ruri_level_access_rc_vars", $uris, get_defined_vars ());
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
?>
|
includes/classes/sc-gets-in.inc.php
ADDED
@@ -0,0 +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_sc_gets_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_gets_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for:
|
23 |
+
[s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /]
|
24 |
+
[s2Get user_field="a_custom_registration_field_id" /]
|
25 |
+
[s2Get user_option="s2member_subscr_id" /]
|
26 |
+
|
27 |
+
Attach to: add_shortcode("s2Get");
|
28 |
+
*/
|
29 |
+
public static function sc_get_details ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
30 |
+
{
|
31 |
+
static $current_user; /* Optimizes this routine a bit. */
|
32 |
+
$current_user = (!isset ($current_user)) ? wp_get_current_user () : $current_user;
|
33 |
+
/**/
|
34 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
35 |
+
do_action ("ws_plugin__s2member_before_sc_get_details", get_defined_vars ());
|
36 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
37 |
+
/**/
|
38 |
+
$attr = c_ws_plugin__s2member_utils_strings::trim_quot_deep ((array)$attr); /* Force array, and fix ". */
|
39 |
+
/**/
|
40 |
+
$attr = shortcode_atts (array ("constant" => "", "user_field" => "", "user_option" => ""), $attr);
|
41 |
+
/**/
|
42 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
43 |
+
do_action ("ws_plugin__s2member_before_sc_get_details_after_shortcode_atts", get_defined_vars ());
|
44 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
45 |
+
/**/
|
46 |
+
if ($attr["constant"] && defined ($attr["constant"])) /* Security check here. It must start with S2MEMBER_ on a Blog Farm. */
|
47 |
+
{
|
48 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || preg_match ("/^S2MEMBER_/i", $attr["constant"]))
|
49 |
+
$get = constant ($attr["constant"]);
|
50 |
+
}
|
51 |
+
/**/
|
52 |
+
else if ($attr["user_field"] && $current_user)
|
53 |
+
$get = c_ws_plugin__s2member_utils_users::get_user_field ($attr["user_field"]);
|
54 |
+
/**/
|
55 |
+
else if ($attr["user_option"] && $current_user)
|
56 |
+
$get = get_user_option ($attr["user_option"]);
|
57 |
+
/**/
|
58 |
+
return apply_filters ("ws_plugin__s2member_sc_get_details", $get, get_defined_vars ());
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
includes/classes/sc-gets.inc.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_gets"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_gets
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for:
|
23 |
+
[s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /]
|
24 |
+
[s2Get user_field="a_custom_registration_field_id" /]
|
25 |
+
[s2Get user_option="s2member_subscr_id" /]
|
26 |
+
|
27 |
+
Attach to: add_shortcode("s2Get");
|
28 |
+
*/
|
29 |
+
public static function sc_get_details ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
30 |
+
{
|
31 |
+
return c_ws_plugin__s2member_sc_gets_in::sc_get_details ($attr, $content, $shortcode);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
?>
|
includes/classes/sc-if-conds-in.inc.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_if_conds_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_if_conds_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for [s2If ... simple conditionals][/s2If].
|
23 |
+
- These Shortcodes are also safe to use on a Multisite Blog Farm.
|
24 |
+
|
25 |
+
Attach to: add_shortcode("s2If") + _s2If, __s2If, ___s2If for nesting.
|
26 |
+
|
27 |
+
Is Multisite Networking enabled? Please keep the following in mind.
|
28 |
+
* current_user_can(), will ALWAYS return true for a Super Admin!
|
29 |
+
( this can be confusing when testing conditionals )
|
30 |
+
|
31 |
+
If you're running a Multisite Blog Farm, you can Filter this array:
|
32 |
+
ws_plugin__s2member_sc_if_conditionals_blog_farm_safe
|
33 |
+
$blog_farm_safe
|
34 |
+
*/
|
35 |
+
public static function sc_if_conditionals ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
36 |
+
{
|
37 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
38 |
+
do_action ("ws_plugin__s2member_before_sc_if_conditionals", get_defined_vars ());
|
39 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
40 |
+
/**/
|
41 |
+
$blog_farm_safe = apply_filters ("ws_plugin__s2member_sc_if_conditionals_blog_farm_safe", array ("is_user_logged_in", "is_user_not_logged_in", "current_user_is", "current_user_is_not", "current_user_can", "current_user_cannot", "is_admin", "is_blog_admin", "is_user_admin", "is_network_admin", "is_404", "is_home", "is_front_page", "is_singular", "is_single", "is_page", "is_page_template", "is_attachment", "is_feed", "is_archive", "is_search", "is_category", "is_tax", "is_tag", "has_tag", "is_author", "is_date", "is_day", "is_month", "is_time", "is_year", "is_sticky", "is_paged", "is_preview", "is_comments_popup", "in_the_loop", "comments_open", "pings_open", "has_excerpt", "has_post_thumbnail"), get_defined_vars ());
|
42 |
+
/**/
|
43 |
+
$attr = c_ws_plugin__s2member_utils_strings::trim_quot_deep ((array)$attr); /* Force array, and fix " in attrs. */
|
44 |
+
/**/
|
45 |
+
foreach ($attr as $attr_key => $attr_value) /* Detects and removes logical attributes. */
|
46 |
+
/* It's NOT possible to mix logic. You MUST stick to one type of logic or another. */
|
47 |
+
/* If both types of logic are needed, you MUST use two different Shortcodes. */
|
48 |
+
if (preg_match ("/^(&&|&&|&&|AND|\|\||OR|[\!\=\<\>]+)$/i", $attr_value))
|
49 |
+
{ /* Stick with AND/OR. Ampersands are corrupted by the Visual Editor. */
|
50 |
+
/**/
|
51 |
+
$logicals[] = strtolower ($attr_value); /* Place all logicals into an array here. */
|
52 |
+
unset ($attr[$attr_key]); /* ^ Detect logic here. We'll use the first key #0. */
|
53 |
+
/**/
|
54 |
+
if (preg_match ("/^[\!\=\<\>]+$/i", $attr_value)) /* Error on these operators. */
|
55 |
+
{
|
56 |
+
trigger_error ("s2If, invalid operator [ " . $attr_value . " ]. Simple Conditionals cannot process operators like ( == != <> ). Please use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
|
57 |
+
return ""; /* Return now; empty string in this case. */
|
58 |
+
}
|
59 |
+
}
|
60 |
+
/**/
|
61 |
+
if (is_array ($logicals) && !empty ($logicals) && count (array_unique ($logicals)) > 1)
|
62 |
+
{
|
63 |
+
trigger_error ("s2If, AND/OR malformed conditional logic. It's NOT possible to mix logic using AND/OR combinations. You MUST stick to one type of logic or another. If both types of logic are needed, you MUST use two different Shortcode expressions. Or, use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
|
64 |
+
return ""; /* Return now; empty string in this case. */
|
65 |
+
}
|
66 |
+
/**/
|
67 |
+
$conditional_logic = (is_array ($logicals) && !empty ($logicals) && preg_match ("/^(\|\||OR)$/i", $logicals[0])) ? "OR" : "AND";
|
68 |
+
/**/
|
69 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
70 |
+
do_action ("ws_plugin__s2member_before_sc_if_conditionals_after_conditional_logic", get_defined_vars ());
|
71 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
72 |
+
/**/
|
73 |
+
if ($conditional_logic === "AND") /* This is the AND variation. This routine analyzes conditionals using AND logic ( the default behavior ). */
|
74 |
+
{
|
75 |
+
foreach ($attr as $attr_value) /* This is the AND variation. This routine analyzes conditionals using AND logic ( the default behavior ). */
|
76 |
+
{
|
77 |
+
if (preg_match ("/^(\!?)(.+?)(\()(.*?)(\))$/", $attr_value, $m) && ($exclamation = $m[1]) !== "nill" && ($conditional = $m[2]) && ($attr_args = preg_replace ("/[\r\n\t\s ]/", "", $m[4])) !== "nill")
|
78 |
+
{
|
79 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || !preg_match ("/[\(\)]/", $attr_args)) /* Disallow functions as arguments on a Multisite Blog Farm. */
|
80 |
+
{
|
81 |
+
if (is_array ($args = preg_split ("/[;,]+/", $attr_args, 0, PREG_SPLIT_NO_EMPTY))) /* Convert all arguments into an array. And take note; possibly into an empty array. */
|
82 |
+
{
|
83 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || in_array (strtolower ($conditional), $blog_farm_safe))
|
84 |
+
{
|
85 |
+
$test = ($exclamation) ? false : true; /* If !exclamation ( false ) otherwise this defaults to true. */
|
86 |
+
/**/
|
87 |
+
if (preg_match ("/^\{(.*?)\}$/", $attr_args)) /* Single argument passed as an array. */
|
88 |
+
{
|
89 |
+
if ($test === true && !call_user_func ($conditional, $args))
|
90 |
+
{
|
91 |
+
$condition_failed = true;
|
92 |
+
break;
|
93 |
+
}
|
94 |
+
else if ($test === false && call_user_func ($conditional, $args))
|
95 |
+
{
|
96 |
+
$condition_failed = true;
|
97 |
+
break;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
/**/
|
101 |
+
else if (empty ($args)) /* No arguments at all. */
|
102 |
+
{
|
103 |
+
if ($test === true && !call_user_func ($conditional))
|
104 |
+
{
|
105 |
+
$condition_failed = true;
|
106 |
+
break;
|
107 |
+
}
|
108 |
+
/**/
|
109 |
+
else if ($test === false && call_user_func ($conditional))
|
110 |
+
{
|
111 |
+
$condition_failed = true;
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
/**/
|
116 |
+
else if ($test === true && !call_user_func_array ($conditional, $args))
|
117 |
+
{
|
118 |
+
$condition_failed = true;
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
/**/
|
122 |
+
else if ($test === false && call_user_func_array ($conditional, $args))
|
123 |
+
{
|
124 |
+
$condition_failed = true;
|
125 |
+
break;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
else
|
129 |
+
{
|
130 |
+
trigger_error ("s2If, unsafe conditional function [ " . $attr_value . " ]", E_USER_ERROR);
|
131 |
+
return ""; /* Return now; empty string in this case. */
|
132 |
+
}
|
133 |
+
}
|
134 |
+
else
|
135 |
+
{
|
136 |
+
trigger_error ("s2If, conditional args are NOT an array [ " . $attr_value . " ]", E_USER_ERROR);
|
137 |
+
return ""; /* Return now; empty string in this case. */
|
138 |
+
}
|
139 |
+
}
|
140 |
+
else
|
141 |
+
{
|
142 |
+
trigger_error ("s2If, unsafe conditional args [ " . $attr_value . " ]", E_USER_ERROR);
|
143 |
+
return ""; /* Return now; empty string in this case. */
|
144 |
+
}
|
145 |
+
}
|
146 |
+
else
|
147 |
+
{
|
148 |
+
trigger_error ("s2If, malformed conditional [ " . $attr_value . " ]", E_USER_ERROR);
|
149 |
+
return ""; /* Return now; empty string in this case. */
|
150 |
+
}
|
151 |
+
}
|
152 |
+
/* Supports nested Shortcodes. */
|
153 |
+
return do_shortcode (apply_filters ("ws_plugin__s2member_sc_if_conditionals", (($condition_failed) ? "" : $content), get_defined_vars ()));
|
154 |
+
}
|
155 |
+
/**/
|
156 |
+
else if ($conditional_logic === "OR") /* This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic. */
|
157 |
+
{
|
158 |
+
foreach ($attr as $attr_value) /* This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic. */
|
159 |
+
{
|
160 |
+
if (preg_match ("/^(\!?)(.+?)(\()(.*?)(\))$/", $attr_value, $m) && ($exclamation = $m[1]) !== "nill" && ($conditional = $m[2]) && ($attr_args = preg_replace ("/[\r\n\t\s ]/", "", $m[4])) !== "nill")
|
161 |
+
{
|
162 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || !preg_match ("/[\(\)]/", $attr_args)) /* Disallow functions as arguments on a Multisite Blog Farm. */
|
163 |
+
{
|
164 |
+
if (is_array ($args = preg_split ("/[;,]+/", $attr_args, 0, PREG_SPLIT_NO_EMPTY))) /* Convert all arguments into an array. And take note; possibly into an empty array. */
|
165 |
+
{
|
166 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || in_array (strtolower ($conditional), $blog_farm_safe))
|
167 |
+
{
|
168 |
+
$test = ($exclamation) ? false : true; /* If !exclamation ( false ) otherwise this defaults to true. */
|
169 |
+
/**/
|
170 |
+
if (preg_match ("/^\{(.*?)\}$/", $attr_args)) /* Single argument passed as an array. */
|
171 |
+
{
|
172 |
+
if ($test === true && call_user_func ($conditional, $args))
|
173 |
+
{
|
174 |
+
$condition_succeeded = true;
|
175 |
+
break;
|
176 |
+
}
|
177 |
+
else if ($test === false && !call_user_func ($conditional, $args))
|
178 |
+
{
|
179 |
+
$condition_succeeded = true;
|
180 |
+
break;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
/**/
|
184 |
+
else if (empty ($args)) /* No arguments at all. */
|
185 |
+
{
|
186 |
+
if ($test === true && call_user_func ($conditional))
|
187 |
+
{
|
188 |
+
$condition_succeeded = true;
|
189 |
+
break;
|
190 |
+
}
|
191 |
+
/**/
|
192 |
+
else if ($test === false && !call_user_func ($conditional))
|
193 |
+
{
|
194 |
+
$condition_succeeded = true;
|
195 |
+
break;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
/**/
|
199 |
+
else if ($test === true && call_user_func_array ($conditional, $args))
|
200 |
+
{
|
201 |
+
$condition_succeeded = true;
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
/**/
|
205 |
+
else if ($test === false && !call_user_func_array ($conditional, $args))
|
206 |
+
{
|
207 |
+
$condition_succeeded = true;
|
208 |
+
break;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
else
|
212 |
+
{
|
213 |
+
trigger_error ("s2If, unsafe conditional function [ " . $attr_value . " ]", E_USER_ERROR);
|
214 |
+
return ""; /* Return now; empty string in this case. */
|
215 |
+
}
|
216 |
+
}
|
217 |
+
else
|
218 |
+
{
|
219 |
+
trigger_error ("s2If, conditional args are NOT an array [ " . $attr_value . " ]", E_USER_ERROR);
|
220 |
+
return ""; /* Return now; empty string in this case. */
|
221 |
+
}
|
222 |
+
}
|
223 |
+
else
|
224 |
+
{
|
225 |
+
trigger_error ("s2If, unsafe conditional args [ " . $attr_value . " ]", E_USER_ERROR);
|
226 |
+
return ""; /* Return now; empty string in this case. */
|
227 |
+
}
|
228 |
+
}
|
229 |
+
else
|
230 |
+
{
|
231 |
+
trigger_error ("s2If, malformed conditional [ " . $attr_value . " ]", E_USER_ERROR);
|
232 |
+
return ""; /* Return now; empty string in this case. */
|
233 |
+
}
|
234 |
+
}
|
235 |
+
/* Supports nested Shortcodes. */
|
236 |
+
return do_shortcode (apply_filters ("ws_plugin__s2member_sc_if_conditionals", (($condition_succeeded) ? $content : ""), get_defined_vars ()));
|
237 |
+
}
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
?>
|
includes/classes/sc-if-conds.inc.php
ADDED
@@ -0,0 +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_sc_if_conds"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_if_conds
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for [s2If ... simple conditionals][/s2If].
|
23 |
+
- These Shortcodes are also safe to use on a Multisite Blog Farm.
|
24 |
+
|
25 |
+
Attach to: add_shortcode("s2If") + _s2If, __s2If, ___s2If for nesting.
|
26 |
+
|
27 |
+
Is Multisite Networking enabled? Please keep the following in mind.
|
28 |
+
* current_user_can(), will ALWAYS return true for a Super Admin!
|
29 |
+
( this can be confusing when testing conditionals )
|
30 |
+
|
31 |
+
If you're running a Multisite Blog Farm, you can filter this array:
|
32 |
+
ws_plugin__s2member_sc_if_conditionals_blog_farm_safe
|
33 |
+
$blog_farm_safe
|
34 |
+
*/
|
35 |
+
public static function sc_if_conditionals ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
36 |
+
{
|
37 |
+
return c_ws_plugin__s2member_sc_if_conds_in::sc_if_conditionals ($attr, $content, $shortcode);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
?>
|
includes/classes/sc-paypal-button-e.inc.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
+
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
+
|
6 |
+
Released under the terms of the GNU General Public License.
|
7 |
+
You should have received a copy of the GNU General Public License,
|
8 |
+
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_sc_paypal_button_e"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_paypal_button_e
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Handles PayPal® Button encryption ( when/if configured ).
|
23 |
+
This uses the PayPal® API. s2Member will NOT attempt to encrypt Buttons until there is at least a Business Email Address and API Username configured.
|
24 |
+
s2Member also maintains a log of communication with the PayPal® API. If logging is enabled, check: `/wp-content/plugins/s2member-logs/paypal-api.log`.
|
25 |
+
*/
|
26 |
+
public static function sc_paypal_button_encryption ($code = FALSE, $vars = FALSE)
|
27 |
+
{
|
28 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
29 |
+
do_action ("ws_plugin__s2member_before_sc_paypal_button_encryption", get_defined_vars ());
|
30 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
31 |
+
/**/
|
32 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_btn_encryption"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"])
|
33 |
+
{
|
34 |
+
$cache = apply_filters ("ws_plugin__s2member_sc_paypal_button_encryption_cache", true, get_defined_vars ()); /* Are we caching? */
|
35 |
+
/**/
|
36 |
+
eval ('$_code = $vars["_code"]; $attr = $vars["attr"];'); /* Let's unpack ( i.e. use shorter references ) to these two important data vars. */
|
37 |
+
/**/
|
38 |
+
if ($cache && ($transient = "s2m_btn_" . md5 ($code . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"])) && ($cache = get_transient ($transient)))
|
39 |
+
$code = $cache; /* Great, so we can use the cached version here to save processing time. Notice the MD5 hash uses $code and NOT $_code; just in case a different `output=""` format was requested. */
|
40 |
+
/**/
|
41 |
+
else if (is_array ($inputs = c_ws_plugin__s2member_utils_forms::form_whips_2_array ($_code)) && !empty ($inputs)) /* Were we able to parse the hidden inputs variables? */
|
42 |
+
{
|
43 |
+
$paypal = array ("METHOD" => "BMCreateButton", "BUTTONCODE" => "ENCRYPTED", "BUTTONTYPE" => ( ($attr["sp"] || $attr["rr"] === "BN") ? "BUYNOW" : "SUBSCRIBE"));
|
44 |
+
/**/
|
45 |
+
$i = 0; /* Initialize incremental variable counter. PayPal® wants these numbered using L_BUTTONVAR{n}; where {n} starts at zero. */
|
46 |
+
foreach ($inputs as $input => $value) /* Now run through each of the input variables that we parsed from the Full Button Code */
|
47 |
+
if (!preg_match ("/^cmd$/i", $input)) /* Don't include the `cmd` var; it will produce major errors in the API response. */
|
48 |
+
eval ('$paypal["L_BUTTONVAR" . $i] = $input . "=" . $value; $i++;'); /* Just keeping this on one line is all. */
|
49 |
+
/**/
|
50 |
+
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal)) && !$paypal["__error"] && $paypal["WEBSITECODE"] && ($code = $paypal["WEBSITECODE"]))
|
51 |
+
/* Only proceed if we DID get a valid response from the PayPal® API. This works as a nice fallback; just in case the API connection fails. */
|
52 |
+
{
|
53 |
+
$default_image = "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"; /* Default PayPal® image. */
|
54 |
+
/**/
|
55 |
+
$code = preg_replace ("/\<img[^\>]+\>/i", "", $code); /* Remove the 1x1 pixel tracking image that PayPal® sticks in there. */
|
56 |
+
$code = preg_replace ("/(\<input)([^\>]+)(\>)/ie", "'\\1'.rtrim(stripslashes('\\2'),'/').' /\\3'", $code); /* Use XHTML! */
|
57 |
+
/**/
|
58 |
+
$code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
|
59 |
+
/**/
|
60 |
+
$code = ($attr["output"] === "anchor") ? '<a href="' . esc_attr (c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code)) . '"><img src="' . esc_attr (($attr["image"] && $attr["image"] !== "default") ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal®" /></a>' : $code;
|
61 |
+
$code = ($attr["output"] === "url") ? c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code) : $code;
|
62 |
+
/**/
|
63 |
+
($cache && $transient) ? set_transient ($transient, $code, apply_filters ("ws_plugin__s2member_sc_paypal_button_encryption_cache_exp_time", 3600, get_defined_vars ())) : null; /* Caching? */
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
/* No WordPress® Filters apply here. */
|
68 |
+
/* Instead, use: `ws_plugin__s2member_sc_paypal_button`. */
|
69 |
+
return $code; /* Button Code. Possibly w/ API encryption applied now. */
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
?>
|
includes/classes/sc-paypal-button-in.inc.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_paypal_button_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_paypal_button_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function handles the Shortcode for [s2Member-PayPal-Button /].
|
23 |
+
Attach to: add_shortcode("s2Member-PayPal-Button");
|
24 |
+
*/
|
25 |
+
public static function sc_paypal_button ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_sc_paypal_button", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
c_ws_plugin__s2member_nocache::nocache_constants (true); /* No caching on pages that contain this Button. */
|
32 |
+
/**/
|
33 |
+
$attr = c_ws_plugin__s2member_utils_strings::trim_quot_deep ((array)$attr); /* Force array, and fix " in attrs. */
|
34 |
+
/**/
|
35 |
+
$attr = shortcode_atts (array ("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "ps" => "paypal", "cc" => "USD", "ns" => "1", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "button"), $attr);
|
36 |
+
/**/
|
37 |
+
$attr["tt"] = strtoupper ($attr["tt"]); /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */
|
38 |
+
$attr["rt"] = strtoupper ($attr["rt"]); /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */
|
39 |
+
$attr["rr"] = strtoupper ($attr["rr"]); /* Must be provided in upper-case format. Numerical, or BN value. Only after running shortcode_atts(). */
|
40 |
+
$attr["ccaps"] = strtolower ($attr["ccaps"]); /* Custom Capabilities must be typed in lower-case format. Only after running shortcode_atts(). */
|
41 |
+
$attr["rr"] = ($attr["rt"] === "L") ? "BN" : $attr["rr"]; /* Lifetime Subscriptions require Buy Now. Only after running shortcode_atts(). */
|
42 |
+
/**/
|
43 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
44 |
+
do_action ("ws_plugin__s2member_before_sc_paypal_button_after_shortcode_atts", get_defined_vars ());
|
45 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
46 |
+
/**/
|
47 |
+
if ($attr["cancel"]) /* This is a special routine for Cancellation Buttons. Cancellation Buttons use a different template. */
|
48 |
+
{
|
49 |
+
$default_image = "https://www.paypal.com/en_US/i/btn/btn_unsubscribe_LG.gif"; /* Default Image. */
|
50 |
+
/**/
|
51 |
+
$code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/templates/buttons/paypal-cancellation-button.html"));
|
52 |
+
$code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code);
|
53 |
+
$code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
|
54 |
+
/**/
|
55 |
+
$code = preg_replace ("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")), $code);
|
56 |
+
$code = preg_replace ("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code);
|
57 |
+
/**/
|
58 |
+
$code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
|
59 |
+
/**/
|
60 |
+
$code = ($attr["output"] === "anchor") ? $code : $code; /* Cancellation Buttons are already in anchor format; Button format is not used in Cancellations. */
|
61 |
+
$code = ($attr["output"] === "url") ? "https://" . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com") . "/cgi-bin/webscr?cmd=_subscr-find&alias=" . urlencode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]) : $code;
|
62 |
+
/**/
|
63 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
64 |
+
do_action ("ws_plugin__s2member_during_sc_paypal_cancellation_button", get_defined_vars ());
|
65 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
66 |
+
}
|
67 |
+
/**/
|
68 |
+
else if ($attr["sp"]) /* This is a special routine for Specific Post/Page Buttons. Specific Post/Page Buttons use a different template. */
|
69 |
+
{
|
70 |
+
$default_image = "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"; /* Default Image. */
|
71 |
+
/**/
|
72 |
+
$attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"]; /* Combined "sp:ids:expiration hours". */
|
73 |
+
/**/
|
74 |
+
$code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/templates/buttons/paypal-sp-checkout-button.html"));
|
75 |
+
$code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code);
|
76 |
+
$code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
|
77 |
+
/**/
|
78 |
+
$code = preg_replace ("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")), $code);
|
79 |
+
$code = preg_replace ("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code);
|
80 |
+
$code = preg_replace ("/%%cancel_return%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (home_url ("/"))), $code);
|
81 |
+
$code = preg_replace ("/%%notify_url%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ("/?s2member_paypal_notify=1"))), $code);
|
82 |
+
$code = preg_replace ("/%%return%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ("/?s2member_paypal_return=1"))), $code);
|
83 |
+
$code = preg_replace ("/%%custom%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($_SERVER["HTTP_HOST"])), $code);
|
84 |
+
/**/
|
85 |
+
$code = preg_replace ('/ name\="no_shipping" value\="(.*?)"/', ' name="no_shipping" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ns"])) . '"', $code);
|
86 |
+
$code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["desc"])) . '"', $code);
|
87 |
+
$code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["sp_ids_exp"])) . '"', $code);
|
88 |
+
$code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ps"])) . '"', $code);
|
89 |
+
$code = preg_replace ('/ name\="currency_code" value\="(.*?)"/', ' name="currency_code" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["cc"])) . '"', $code);
|
90 |
+
$code = preg_replace ('/ name\="custom" value\="(.*?)"/', ' name="custom" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["custom"])) . '"', $code);
|
91 |
+
$code = preg_replace ('/ name\="amount" value\="(.*?)"/', ' name="amount" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ra"])) . '"', $code);
|
92 |
+
/**/
|
93 |
+
$code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
|
94 |
+
/**/
|
95 |
+
$code = ($attr["output"] === "anchor") ? '<a href="' . esc_attr (c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code)) . '"><img src="' . esc_attr (($attr["image"] && $attr["image"] !== "default") ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal®" /></a>' : $code;
|
96 |
+
$code = ($attr["output"] === "url") ? c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code) : $code;
|
97 |
+
/**/
|
98 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
99 |
+
do_action ("ws_plugin__s2member_during_sc_paypal_sp_button", get_defined_vars ());
|
100 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
101 |
+
}
|
102 |
+
else /* Otherwise, we'll process this Button normally, using the Membership routines. Also handles Modification Buttons. */
|
103 |
+
{
|
104 |
+
$default_image = "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"; /* Default PayPal® Image. */
|
105 |
+
/**/
|
106 |
+
$attr["desc"] = (!$attr["desc"]) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"];
|
107 |
+
/**/
|
108 |
+
$attr["level_ccaps_eotper"] = ($attr["rr"] === "BN" && $attr["rt"] !== "L") ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
|
109 |
+
$attr["level_ccaps_eotper"] = rtrim ($attr["level_ccaps_eotper"], ":"); /* Clean any trailing separators from this string. */
|
110 |
+
/**/
|
111 |
+
$code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/templates/buttons/paypal-checkout-button.html"));
|
112 |
+
$code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code);
|
113 |
+
$code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
|
114 |
+
/**/
|
115 |
+
$code = preg_replace ("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")), $code);
|
116 |
+
$code = preg_replace ("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code);
|
117 |
+
$code = preg_replace ("/%%level_label%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"])), $code);
|
118 |
+
$code = preg_replace ("/%%cancel_return%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (home_url ("/"))), $code); /* This brings them back to Front Page. */
|
119 |
+
$code = preg_replace ("/%%notify_url%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ("/?s2member_paypal_notify=1"))), $code);
|
120 |
+
$code = preg_replace ("/%%return%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ("/?s2member_paypal_return=1"))), $code);
|
121 |
+
$code = preg_replace ("/%%custom%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($_SERVER["HTTP_HOST"])), $code);
|
122 |
+
$code = preg_replace ("/%%level%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["level"])), $code);
|
123 |
+
/**/
|
124 |
+
$code = preg_replace ('/ \<\!--(\<input type\="hidden" name\="(amount|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/', " $1", $code);
|
125 |
+
$code = ($attr["rr"] === "BN") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick$3", $code) : $code;
|
126 |
+
$code = ($attr["rr"] === "BN") ? preg_replace ('/ (\<input type\="hidden" name\="(src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
|
127 |
+
$code = ($attr["rr"] === "BN" || !$attr["tp"]) ? preg_replace ('/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
|
128 |
+
$code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick-subscriptions$3", $code) : $code;
|
129 |
+
$code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
|
130 |
+
/**/
|
131 |
+
$code = preg_replace ('/ name\="no_shipping" value\="(.*?)"/', ' name="no_shipping" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ns"])) . '"', $code);
|
132 |
+
$code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["desc"])) . '"', $code);
|
133 |
+
$code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["level_ccaps_eotper"])) . '"', $code);
|
134 |
+
$code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ps"])) . '"', $code);
|
135 |
+
$code = preg_replace ('/ name\="currency_code" value\="(.*?)"/', ' name="currency_code" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["cc"])) . '"', $code);
|
136 |
+
$code = preg_replace ('/ name\="custom" value\="(.*?)"/', ' name="custom" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["custom"])) . '"', $code);
|
137 |
+
$code = preg_replace ('/ name\="on0" value\="(.*?)"/', ' name="on0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0)) . '"', $code);
|
138 |
+
$code = preg_replace ('/ name\="os0" value\="(.*?)"/', ' name="os0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0)) . '"', $code);
|
139 |
+
$code = preg_replace ('/ name\="modify" value\="(.*?)"/', ' name="modify" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (($attr["modify"]) ? "1" : "0")) . '"', $code);
|
140 |
+
$code = preg_replace ('/ name\="amount" value\="(.*?)"/', ' name="amount" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ra"])) . '"', $code);
|
141 |
+
$code = preg_replace ('/ name\="src" value\="(.*?)"/', ' name="src" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["rr"])) . '"', $code);
|
142 |
+
$code = preg_replace ('/ name\="a1" value\="(.*?)"/', ' name="a1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ta"])) . '"', $code);
|
143 |
+
$code = preg_replace ('/ name\="p1" value\="(.*?)"/', ' name="p1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["tp"])) . '"', $code);
|
144 |
+
$code = preg_replace ('/ name\="t1" value\="(.*?)"/', ' name="t1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["tt"])) . '"', $code);
|
145 |
+
$code = preg_replace ('/ name\="a3" value\="(.*?)"/', ' name="a3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["ra"])) . '"', $code);
|
146 |
+
$code = preg_replace ('/ name\="p3" value\="(.*?)"/', ' name="p3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["rp"])) . '"', $code);
|
147 |
+
$code = preg_replace ('/ name\="t3" value\="(.*?)"/', ' name="t3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["rt"])) . '"', $code);
|
148 |
+
/**/
|
149 |
+
$code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
|
150 |
+
/**/
|
151 |
+
$code = ($attr["output"] === "anchor") ? '<a href="' . esc_attr (c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code)) . '"><img src="' . esc_attr (($attr["image"] && $attr["image"] !== "default") ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal®" /></a>' : $code;
|
152 |
+
$code = ($attr["output"] === "url") ? c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code) : $code;
|
153 |
+
/**/
|
154 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
155 |
+
($attr["modify"]) ? do_action ("ws_plugin__s2member_during_sc_paypal_modification_button", get_defined_vars ()) : do_action ("ws_plugin__s2member_during_sc_paypal_button", get_defined_vars ());
|
156 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
157 |
+
}
|
158 |
+
/**/
|
159 |
+
$code = c_ws_plugin__s2member_sc_paypal_button_e::sc_paypal_button_encryption ($code, get_defined_vars ());
|
160 |
+
/**/
|
161 |
+
return apply_filters ("ws_plugin__s2member_sc_paypal_button", $code, get_defined_vars ()); /* Gives Filters a chance too. */
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
?>
|
includes/classes/sc-paypal-button.inc.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_paypal_button"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_paypal_button
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function handles the Shortcode for [s2Member-PayPal-Button /].
|
23 |
+
Attach to: add_shortcode("s2Member-PayPal-Button");
|
24 |
+
*/
|
25 |
+
public static function sc_paypal_button ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
26 |
+
{
|
27 |
+
return c_ws_plugin__s2member_sc_paypal_button_in::sc_paypal_button ($attr, $content, $shortcode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
?>
|
includes/classes/sc-profile-in.inc.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_profile_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_profile_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for [s2Member-Profile /].
|
23 |
+
Attach to: add_shortcode("s2Member-Profile");
|
24 |
+
*/
|
25 |
+
public static function sc_profile ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_sc_profile", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
c_ws_plugin__s2member_nocache::nocache_constants (true); /* No caching on pages with this. */
|
32 |
+
/**/
|
33 |
+
if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false)) /* OK? */
|
34 |
+
{
|
35 |
+
$attr = c_ws_plugin__s2member_utils_strings::trim_quot_deep ((array)$attr);
|
36 |
+
/**/
|
37 |
+
$attr = shortcode_atts (array (), $attr); /* Possible Attributes. None at this time. */
|
38 |
+
/**/
|
39 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
40 |
+
do_action ("ws_plugin__s2member_before_sc_profile_after_shortcode_atts", get_defined_vars ());
|
41 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
42 |
+
/**/
|
43 |
+
ob_start (); /* Start buffering. Allows Hooks to echo output like: `/?s2member_profile=1`. */
|
44 |
+
/**/
|
45 |
+
echo '<form method="post" name="ws_plugin__s2member_profile" id="ws-plugin--s2member-profile">' . "\n";
|
46 |
+
/**/
|
47 |
+
if ($GLOBALS["ws_plugin__s2member_profile_saved"]) /* Respond to successful updates. */
|
48 |
+
{
|
49 |
+
echo '<div id="ws-plugin--s2member-profile-saved">' . "\n";
|
50 |
+
echo 'Profile updated successfully.' . "\n";
|
51 |
+
echo '</div>' . "\n";
|
52 |
+
}
|
53 |
+
/**/
|
54 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
55 |
+
do_action ("ws_plugin__s2member_during_profile_before_table", get_defined_vars ());
|
56 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
57 |
+
/**/
|
58 |
+
echo '<table style="width:100%; border:0;">' . "\n";
|
59 |
+
echo '<tbody>' . "\n";
|
60 |
+
/**/
|
61 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
62 |
+
do_action ("ws_plugin__s2member_during_profile_before_fields", get_defined_vars ());
|
63 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
64 |
+
/**/
|
65 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_username", true, get_defined_vars ()))
|
66 |
+
{
|
67 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
68 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_username", get_defined_vars ());
|
69 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
70 |
+
/**/
|
71 |
+
echo '<tr>' . "\n";
|
72 |
+
echo '<td>' . "\n";
|
73 |
+
echo '<label>' . "\n";
|
74 |
+
echo '<strong>Username *</strong> ( cannot be changed )<br />' . "\n";
|
75 |
+
echo '<input aria-required="true" type="text" maxlength="60" name="ws_plugin__s2member_profile_login" id="ws-plugin--s2member-profile-login" style="width:99%;" value="' . format_to_edit ($current_user->user_login) . '" disabled="disabled" />' . "\n";
|
76 |
+
echo '</label>' . "\n";
|
77 |
+
echo '</td>' . "\n";
|
78 |
+
echo '</tr>' . "\n";
|
79 |
+
/**/
|
80 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
81 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_username", get_defined_vars ());
|
82 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
83 |
+
}
|
84 |
+
/**/
|
85 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_email", true, get_defined_vars ()))
|
86 |
+
{
|
87 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
88 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_email", get_defined_vars ());
|
89 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
90 |
+
/**/
|
91 |
+
echo '<tr>' . "\n";
|
92 |
+
echo '<td>' . "\n";
|
93 |
+
echo '<label>' . "\n";
|
94 |
+
echo '<strong>Email Address *</strong><br />' . "\n";
|
95 |
+
echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_email" id="ws-plugin--s2member-profile-email" style="width:99%;" value="' . format_to_edit ($current_user->user_email) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
96 |
+
echo '</label>' . "\n";
|
97 |
+
echo '</td>' . "\n";
|
98 |
+
echo '</tr>' . "\n";
|
99 |
+
/**/
|
100 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
101 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_email", get_defined_vars ());
|
102 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
103 |
+
}
|
104 |
+
/**/
|
105 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_first_name", true, get_defined_vars ()))
|
106 |
+
{
|
107 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
108 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_first_name", get_defined_vars ());
|
109 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
110 |
+
/**/
|
111 |
+
echo '<tr>' . "\n";
|
112 |
+
echo '<td>' . "\n";
|
113 |
+
echo '<label>' . "\n";
|
114 |
+
echo '<strong>First Name *</strong><br />' . "\n";
|
115 |
+
echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_first_name" id="ws-plugin--s2member-profile-first-name" style="width:99%;" value="' . format_to_edit ($current_user->first_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
116 |
+
echo '</label>' . "\n";
|
117 |
+
echo '</td>' . "\n";
|
118 |
+
echo '</tr>' . "\n";
|
119 |
+
/**/
|
120 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
121 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_first_name", get_defined_vars ());
|
122 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
123 |
+
}
|
124 |
+
/**/
|
125 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_last_name", true, get_defined_vars ()))
|
126 |
+
{
|
127 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
128 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_last_name", get_defined_vars ());
|
129 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
130 |
+
/**/
|
131 |
+
echo '<tr>' . "\n";
|
132 |
+
echo '<td>' . "\n";
|
133 |
+
echo '<label>' . "\n";
|
134 |
+
echo '<strong>Last Name *</strong><br />' . "\n";
|
135 |
+
echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_last_name" id="ws-plugin--s2member-profile-last-name" style="width:99%;" value="' . format_to_edit ($current_user->last_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
136 |
+
echo '</label>' . "\n";
|
137 |
+
echo '</td>' . "\n";
|
138 |
+
echo '</tr>' . "\n";
|
139 |
+
/**/
|
140 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
141 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_last_name", get_defined_vars ());
|
142 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
143 |
+
}
|
144 |
+
/**/
|
145 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_display_name", true, get_defined_vars ()))
|
146 |
+
{
|
147 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
148 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_display_name", get_defined_vars ());
|
149 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
150 |
+
/**/
|
151 |
+
echo '<tr>' . "\n";
|
152 |
+
echo '<td>' . "\n";
|
153 |
+
echo '<label>' . "\n";
|
154 |
+
echo '<strong>Display Name *</strong><br />' . "\n";
|
155 |
+
echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_display_name" id="ws-plugin--s2member-profile-display-name" style="width:99%;" value="' . format_to_edit ($current_user->display_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
156 |
+
echo '</label>' . "\n";
|
157 |
+
echo '</td>' . "\n";
|
158 |
+
echo '</tr>' . "\n";
|
159 |
+
/**/
|
160 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
161 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_last_name", get_defined_vars ());
|
162 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
163 |
+
}
|
164 |
+
/**/
|
165 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_custom_fields", true, get_defined_vars ()))
|
166 |
+
{
|
167 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) /* Now, do we have Custom Fields? */
|
168 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection"))
|
169 |
+
{
|
170 |
+
$fields = get_user_option ("s2member_custom_fields", $current_user->ID); /* Existing fields. */
|
171 |
+
/**/
|
172 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
173 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_custom_fields", get_defined_vars ());
|
174 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
175 |
+
/**/
|
176 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
177 |
+
{
|
178 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
179 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_before", get_defined_vars ());
|
180 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
181 |
+
/**/
|
182 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
183 |
+
{
|
184 |
+
if ($field["editable"] !== "no-invisible") /* Uneditable/invisible? */
|
185 |
+
{
|
186 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
187 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
188 |
+
/**/
|
189 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
190 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_display", true, get_defined_vars ()))
|
191 |
+
{
|
192 |
+
echo '<tr>' . "\n";
|
193 |
+
echo '<td>' . "\n";
|
194 |
+
echo '<label>' . "\n";
|
195 |
+
echo '<strong' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . ( ($field["required"] === "yes") ? ' *' : '') . '</strong>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n";
|
196 |
+
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen ("ws_plugin__s2member_profile", $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ( (preg_match ("/^(select|selects)$/", $field["type"])) ? "width:100%;" : ( (preg_match ("/^(text|textarea)$/", $field["type"])) ? "width:99%;" : "")), ($tabindex = $tabindex + 10), "", $fields, $fields[$field_var], true);
|
197 |
+
echo '</label>' . "\n";
|
198 |
+
echo '</td>' . "\n";
|
199 |
+
echo '</tr>' . "\n";
|
200 |
+
}
|
201 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
202 |
+
}
|
203 |
+
}
|
204 |
+
/**/
|
205 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
206 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_after", get_defined_vars ());
|
207 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
208 |
+
}
|
209 |
+
/**/
|
210 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
211 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_custom_fields", get_defined_vars ());
|
212 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
213 |
+
}
|
214 |
+
}
|
215 |
+
/**/
|
216 |
+
if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_password", true, get_defined_vars ()))
|
217 |
+
{
|
218 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
219 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_before_password", get_defined_vars ());
|
220 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
221 |
+
/**/
|
222 |
+
echo '<tr>' . "\n";
|
223 |
+
echo '<td>' . "\n";
|
224 |
+
/**/
|
225 |
+
echo '<label title="Please type your Password twice to confirm.">' . "\n";
|
226 |
+
echo '<strong>New Password</strong> ( only if you want to change it )<br />' . "\n";
|
227 |
+
echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_profile_password" id="ws-plugin--s2member-profile-password" style="width:99%;" value="" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '"' . ( ($current_user->user_login === "demo") ? ' disabled="disabled"' : '') . ' />' . "\n";
|
228 |
+
echo '</label>' . "\n";
|
229 |
+
/**/
|
230 |
+
echo '<label title="Please type your Password twice to confirm.">' . "\n";
|
231 |
+
echo '<input type="password" maxlength="100" autocomplete="off" id="ws-plugin--s2member-profile-password-confirmation" style="width:99%;" value="" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '"' . ( ($current_user->user_login === "demo") ? ' disabled="disabled"' : '') . ' />' . "\n";
|
232 |
+
echo '</label>' . "\n";
|
233 |
+
/**/
|
234 |
+
echo '</td>' . "\n";
|
235 |
+
echo '</tr>' . "\n";
|
236 |
+
/**/
|
237 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
238 |
+
do_action ("ws_plugin__s2member_during_profile_during_fields_after_password", get_defined_vars ());
|
239 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
240 |
+
}
|
241 |
+
/**/
|
242 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
243 |
+
do_action ("ws_plugin__s2member_during_profile_after_fields", get_defined_vars ());
|
244 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
245 |
+
/**/
|
246 |
+
echo '<tr>' . "\n";
|
247 |
+
echo '<td>' . "\n";
|
248 |
+
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";
|
249 |
+
echo '<input type="hidden" name="ws_plugin__s2member_sc_profile_save" id="ws-plugin--s2member-sc-profile-save" value="1" />' . "\n";
|
250 |
+
echo '<input type="submit" value="Save Changes" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
251 |
+
echo '</td>' . "\n";
|
252 |
+
echo '</tr>' . "\n";
|
253 |
+
/**/
|
254 |
+
echo '</tbody>' . "\n";
|
255 |
+
echo '</table>' . "\n";
|
256 |
+
/**/
|
257 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
258 |
+
do_action ("ws_plugin__s2member_during_profile_after_table", get_defined_vars ());
|
259 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
260 |
+
/**/
|
261 |
+
echo '</form>' . "\n";
|
262 |
+
/**/
|
263 |
+
$code = ob_get_clean ();
|
264 |
+
}
|
265 |
+
/**/
|
266 |
+
return apply_filters ("ws_plugin__s2member_sc_profile", $code, get_defined_vars ());
|
267 |
+
}
|
268 |
+
}
|
269 |
+
}
|
270 |
+
?>
|
includes/classes/sc-profile.inc.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sc_profile"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sc_profile
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that handles the Shortcode for [s2Member-Profile /].
|
23 |
+
Attach to: add_shortcode("s2Member-Profile");
|
24 |
+
*/
|
25 |
+
public static function sc_profile ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
|
26 |
+
{
|
27 |
+
return c_ws_plugin__s2member_sc_profile_in::sc_profile ($attr, $content, $shortcode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
?>
|
includes/classes/security.inc.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_security"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_security
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function handles security/access routines.
|
23 |
+
~ s2Member's Security Gate.
|
24 |
+
Highly optimized.
|
25 |
+
Attach to: add_action("pre_get_posts");
|
26 |
+
*/
|
27 |
+
public static function security_gate_query (&$wp_query = FALSE)
|
28 |
+
{
|
29 |
+
do_action ("ws_plugin__s2member_before_security_gate_query", get_defined_vars ());
|
30 |
+
/**/
|
31 |
+
c_ws_plugin__s2member_querys::query_level_access ($wp_query); /* By reference. */
|
32 |
+
/**/
|
33 |
+
do_action ("ws_plugin__s2member_after_security_gate_query", get_defined_vars ());
|
34 |
+
/**/
|
35 |
+
return; /* Return for uniformity. */
|
36 |
+
}
|
37 |
+
/*
|
38 |
+
Function handles security/access routines.
|
39 |
+
~ s2Member's Security Gate.
|
40 |
+
Highly optimized.
|
41 |
+
Attach to: add_action("template_redirect");
|
42 |
+
*/
|
43 |
+
public static function security_gate () /* s2Member's Security Gate. */
|
44 |
+
{
|
45 |
+
do_action ("ws_plugin__s2member_before_security_gate", get_defined_vars ());
|
46 |
+
/*
|
47 |
+
Category Level Restrictions ( inclusively ).
|
48 |
+
- Including URI protections too.
|
49 |
+
*/
|
50 |
+
if (is_category ()) /* Categories. */
|
51 |
+
c_ws_plugin__s2member_catgs::check_catg_level_access ();
|
52 |
+
/*
|
53 |
+
Tag Level Restrictions ( inclusively ).
|
54 |
+
- Including URI protections too.
|
55 |
+
*/
|
56 |
+
else if (is_tag ()) /* Tags. */
|
57 |
+
c_ws_plugin__s2member_ptags::check_ptag_level_access ();
|
58 |
+
/*
|
59 |
+
Post Level Restrictions ( inclusively, even Custom Post Types ).
|
60 |
+
- Including Category, Tag, URI, Capability, and Specifics too.
|
61 |
+
*/
|
62 |
+
else if (is_single ()) /* Posts & Custom Types. */
|
63 |
+
c_ws_plugin__s2member_posts::check_post_level_access ();
|
64 |
+
/*
|
65 |
+
Page Level Restrictions ( inclusively ).
|
66 |
+
- Including Category, Tag, URI, Capability, and Specifics too.
|
67 |
+
*/
|
68 |
+
else if (is_page ()) /* Pages. */
|
69 |
+
c_ws_plugin__s2member_pages::check_page_level_access ();
|
70 |
+
/*
|
71 |
+
Else just apply URI Level Restrictions ( only URIs ).
|
72 |
+
*/
|
73 |
+
else /* This optimizes things nicely. */
|
74 |
+
c_ws_plugin__s2member_ruris::check_ruri_level_access ();
|
75 |
+
/*
|
76 |
+
Hook after Security Gate.
|
77 |
+
*/
|
78 |
+
do_action ("ws_plugin__s2member_after_security_gate", get_defined_vars ());
|
79 |
+
/**/
|
80 |
+
return; /* Return for uniformity. */
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
?>
|
includes/classes/sp-access.inc.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_sp_access"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_sp_access
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Generates Specific Post/Page Access links.
|
23 |
+
*/
|
24 |
+
public static function sp_access_link_gen ($sp_ids = FALSE, $hours = 72, $shrink = TRUE)
|
25 |
+
{
|
26 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
27 |
+
do_action ("ws_plugin__s2member_before_sp_access_link_gen", get_defined_vars ());
|
28 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
29 |
+
/**/
|
30 |
+
if (($sp_ids = preg_replace ("/[^0-9;,]/", "", $sp_ids)) && ($leading_id = preg_replace ("/^([0-9]+)(.*?)$/", "$1", $sp_ids)) && $hours)
|
31 |
+
{
|
32 |
+
$sp_access = c_ws_plugin__s2member_utils_encryption::encrypt ("sp_time_hours:.:|:.:" . $sp_ids . ":.:|:.:" . strtotime ("now") . ":.:|:.:" . $hours);
|
33 |
+
$sp_access_link = add_query_arg ("s2member_sp_access", urlencode ($sp_access), get_permalink ($leading_id));
|
34 |
+
/**/
|
35 |
+
if ($shrink && ($tinyurl = c_ws_plugin__s2member_utils_urls::remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($sp_access_link))))
|
36 |
+
return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $tinyurl . "#" . $_SERVER["HTTP_HOST"], get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
else /* Else use the long one; tinyURL will fail when/if their server is down periodically. */
|
39 |
+
return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $sp_access_link, get_defined_vars ());
|
40 |
+
}
|
41 |
+
/**/
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
/*
|
45 |
+
Generates Specific Post/Page Access links via ajax tools.
|
46 |
+
Attach to: add_action("wp_ajax_ws_plugin__s2member_sp_access_link_via_ajax");
|
47 |
+
*/
|
48 |
+
public static function sp_access_link_via_ajax ()
|
49 |
+
{
|
50 |
+
do_action ("ws_plugin__s2member_before_sp_access_link_via_ajax", get_defined_vars ());
|
51 |
+
/**/
|
52 |
+
if (current_user_can ("create_users")) /* Check priveledges as well. */
|
53 |
+
if (($nonce = $_POST["ws_plugin__s2member_sp_access_link_via_ajax"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-sp-access-link-via-ajax") && ($p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))))
|
54 |
+
echo apply_filters ("ws_plugin__s2member_sp_access_link_via_ajax", c_ws_plugin__s2member_sp_access::sp_access_link_gen ($p["s2member_sp_access_link_ids"], $p["s2member_sp_access_link_hours"]), get_defined_vars ());
|
55 |
+
/**/
|
56 |
+
exit (); /* Clean exit. */
|
57 |
+
}
|
58 |
+
/*
|
59 |
+
Handles Specific Post/Page Access authentication.
|
60 |
+
*/
|
61 |
+
public static function sp_access ($sp_id = FALSE, $read_only = FALSE)
|
62 |
+
{
|
63 |
+
do_action ("ws_plugin__s2member_before_sp_access", get_defined_vars ());
|
64 |
+
/**/
|
65 |
+
$excluded = apply_filters ("ws_plugin__s2member_sp_access_excluded", false, get_defined_vars ());
|
66 |
+
/**/
|
67 |
+
if ($excluded || current_user_can (apply_filters ("ws_plugin__s2member_sp_access_excluded_cap", "edit_posts", get_defined_vars ())))
|
68 |
+
return apply_filters ("ws_plugin__s2member_sp_access", true, get_defined_vars ());
|
69 |
+
/**/
|
70 |
+
else if ($sp_id && ( ($_GET["s2member_sp_access"] && is_array ($sp_access_values = (array)trim (stripslashes ($_GET["s2member_sp_access"])))) || (is_array ($sp_access_values = c_ws_plugin__s2member_sp_access::sp_access_session ()) && !empty ($sp_access_values))))
|
71 |
+
{
|
72 |
+
foreach ($sp_access_values as $sp_access_value) /* Supports multiple access values in a session. */
|
73 |
+
{
|
74 |
+
if (is_array ($sp_access = preg_split ("/\:\.\:\|\:\.\:/", c_ws_plugin__s2member_utils_encryption::decrypt ($sp_access_value))))
|
75 |
+
{
|
76 |
+
if (count ($sp_access) === 4 && $sp_access[0] === "sp_time_hours" && in_array ($sp_id, preg_split ("/[\r\n\t\s;,]+/", $sp_access[1])))
|
77 |
+
{
|
78 |
+
if ($sp_access[2] <= strtotime ("now") && ($sp_access[2] + ($sp_access[3] * 3600)) >= strtotime ("now"))
|
79 |
+
{
|
80 |
+
if (!$read_only && $_GET["s2member_sp_access"]) /* Store request in a session. */
|
81 |
+
c_ws_plugin__s2member_sp_access::sp_access_session ($_GET["s2member_sp_access"]);
|
82 |
+
/**/
|
83 |
+
if ($read_only || c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $sp_access_value))
|
84 |
+
return apply_filters ("ws_plugin__s2member_sp_access", true, get_defined_vars ());
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
/**/
|
90 |
+
if (!$read_only && $_GET["s2member_sp_access"]) /* If this is a Specific Post/Page Link, fail with expiration. */
|
91 |
+
{
|
92 |
+
echo '<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.';
|
93 |
+
/**/
|
94 |
+
exit (); /* $_GET["s2member_sp_access"] has expired. Or it is simply invalid. */
|
95 |
+
}
|
96 |
+
/**/
|
97 |
+
return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
|
98 |
+
}
|
99 |
+
/**/
|
100 |
+
else
|
101 |
+
return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
|
102 |
+
}
|
103 |
+
/*
|
104 |
+
Handles Specific Post/Page sessions, by writing access values into a cookie.
|
105 |
+
This function can be used to add a new value into the session, and/or to return the current set of values in the session.
|
106 |
+
*/
|
107 |
+
public static function sp_access_session ($add_sp_access_value = FALSE)
|
108 |
+
{
|
109 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
110 |
+
do_action ("ws_plugin__s2member_before_sp_access_session", get_defined_vars ());
|
111 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
112 |
+
/**/
|
113 |
+
$sp_access_values = ($_COOKIE["s2member_sp_access"]) ? preg_split ("/\:\.\:\|\:\.\:/", $_COOKIE["s2member_sp_access"]) : array ();
|
114 |
+
/**/
|
115 |
+
if ($add_sp_access_value && !in_array ($add_sp_access_value, $sp_access_values)) /* If it's not in the session already. */
|
116 |
+
{
|
117 |
+
$sp_access_values[] = $add_sp_access_value; /* Add an access value, and update the delimited session cookie. */
|
118 |
+
$sp_access_values = array_unique ($sp_access_values); /* Keep this array unique; disallow double-stacking. */
|
119 |
+
/**/
|
120 |
+
$cookie = implode (":.:|:.:", $sp_access_values); /* Implode the access values into a delimited string. */
|
121 |
+
$cookie = (strlen ($cookie) >= 4096) ? $add_sp_access_value : $cookie; /* Max cookie size is 4kbs. */
|
122 |
+
/**/
|
123 |
+
setcookie ("s2member_sp_access", $cookie, time () + 31556926, "/");
|
124 |
+
/**/
|
125 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
126 |
+
do_action ("ws_plugin__s2member_during_sp_access_session", get_defined_vars ());
|
127 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
128 |
+
}
|
129 |
+
/**/
|
130 |
+
return apply_filters ("ws_plugin__s2member_sp_access_session", $sp_access_values, get_defined_vars ());
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
?>
|
includes/classes/ssl.inc.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_ssl"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_ssl
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that forces SSL on specific Posts/Pages.
|
23 |
+
Attach to: add_action("template_redirect");
|
24 |
+
|
25 |
+
Triggered by Custom Field:
|
26 |
+
s2member_force_ssl = yes
|
27 |
+
( i.e. https://www.example.com/ )
|
28 |
+
|
29 |
+
Or with a specific port number:
|
30 |
+
s2member_force_ssl = 443 ( or whatever port you require )
|
31 |
+
( i.e. https://www.example.com:443/ )
|
32 |
+
*/
|
33 |
+
public static function check_force_ssl () /* Forces SSL. */
|
34 |
+
{
|
35 |
+
global $post; /* We need the global $post variable here. */
|
36 |
+
/**/
|
37 |
+
do_action ("ws_plugin__s2member_before_check_force_ssl", get_defined_vars ());
|
38 |
+
/**/
|
39 |
+
$force_ssl = apply_filters ("ws_plugin__s2member_check_force_ssl", false, get_defined_vars ());
|
40 |
+
/**/
|
41 |
+
if (($force_ssl || (is_singular () && is_object ($post) && ($__id = $post->ID))) && strtolower ($force_ssl) !== "no")
|
42 |
+
/**/
|
43 |
+
if (($force_ssl || ($force_ssl = get_post_meta ($__id, "s2member_force_ssl", true))) && strtolower ($force_ssl) !== "no")
|
44 |
+
{
|
45 |
+
if (!is_ssl ()) /* SSL must be enabled here. Redirect to the equivalent https:// scheme. */
|
46 |
+
{
|
47 |
+
$ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
|
48 |
+
$ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
|
49 |
+
$ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
|
50 |
+
/**/
|
51 |
+
wp_redirect ("https://" . $ssl_host_port . $_SERVER["REQUEST_URI"]);
|
52 |
+
exit (); /* ^ So let's redirect to the SSL enabled version. */
|
53 |
+
}
|
54 |
+
else /* Otherwise, we buffer all output, and switch all content over to https. */
|
55 |
+
{
|
56 |
+
add_filter ("redirect_canonical", "__return_false");
|
57 |
+
/**/
|
58 |
+
$ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
|
59 |
+
$ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
|
60 |
+
$ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
|
61 |
+
/**/
|
62 |
+
define ("_ws_plugin__s2member_force_ssl_host", $ssl_host);
|
63 |
+
define ("_ws_plugin__s2member_force_ssl_port", $ssl_port);
|
64 |
+
define ("_ws_plugin__s2member_force_ssl_host_port", $ssl_host_port);
|
65 |
+
/**/
|
66 |
+
/* Except these. We do NOT want to create a sitewide https conversion! */
|
67 |
+
add_filter ("home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
|
68 |
+
add_filter ("network_home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
|
69 |
+
add_filter ("site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
|
70 |
+
add_filter ("network_site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
|
71 |
+
/**/
|
72 |
+
function _ws_plugin__s2member_force_non_ssl_scheme ($url = FALSE, $path = FALSE, $scheme = FALSE)
|
73 |
+
{
|
74 |
+
return ($scheme) ? $url : preg_replace ("/^https\:\/\//i", "http://", $url);
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
function _ws_plugin__s2member_force_ssl_buffer ($buffer = FALSE)
|
78 |
+
{
|
79 |
+
$o_pcre = @ini_get ("pcre.backtrack_limit");
|
80 |
+
/**/
|
81 |
+
@ini_set ("pcre.backtrack_limit", 10000000);
|
82 |
+
/**/
|
83 |
+
$tags = "script|style|link|img|input|iframe|object|embed"; /* Specific tags. */
|
84 |
+
/**/
|
85 |
+
$tags = apply_filters ("_ws_plugin__s2member_force_ssl_buffer_tags", $tags, get_defined_vars ());
|
86 |
+
/**/
|
87 |
+
$buffer = preg_replace_callback ("/\<(" . $tags . ")[^\>]+\>/i", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
|
88 |
+
$buffer = preg_replace_callback ("/\<style[^\>]*\>(.+?)\<\/style\>/is", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
|
89 |
+
/**/
|
90 |
+
@ini_set ("pcre.backtrack_limit", $o_pcre);
|
91 |
+
/**/
|
92 |
+
return apply_filters ("_ws_plugin__s2member_force_ssl_buffer", $buffer, get_defined_vars ());
|
93 |
+
}
|
94 |
+
/**/
|
95 |
+
function _ws_plugin__s2member_force_ssl_buffer_callback ($m = FALSE)
|
96 |
+
{
|
97 |
+
$c = preg_replace ("/http\:\/\//i", "https://", $m[0]);
|
98 |
+
/**/
|
99 |
+
if (_ws_plugin__s2member_force_ssl_port && _ws_plugin__s2member_force_ssl_host && _ws_plugin__s2member_force_ssl_host_port) /* Do we ALSO need port conversions? */
|
100 |
+
$c = preg_replace ("/\/" . preg_quote (_ws_plugin__s2member_force_ssl_host, "/") . "(\:[0-9]+)?\//i", "/" . _ws_plugin__s2member_force_ssl_host_port . "/", $c);
|
101 |
+
/**/
|
102 |
+
return (strtolower ($m[1]) === "link" && preg_match ("/['\"]alternate['\"]/i", $m[0])) ? $m[0] : $c; /* Return string with conversions. */
|
103 |
+
}
|
104 |
+
/**/
|
105 |
+
ob_start ("_ws_plugin__s2member_force_ssl_buffer");
|
106 |
+
}
|
107 |
+
}
|
108 |
+
/**/
|
109 |
+
do_action ("ws_plugin__s2member_after_check_force_ssl", get_defined_vars ());
|
110 |
+
/**/
|
111 |
+
return; /* Return for uniformity. */
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
?>
|
includes/classes/systematics-sp.inc.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_systematics_sp"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_systematics_sp
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that determines whether a specific Page, is a Systematic Use Page.
|
23 |
+
*/
|
24 |
+
public static function is_systematic_use_specific_page ($page_id = FALSE, $uri = FALSE)
|
25 |
+
{
|
26 |
+
static $is_systematic; /* For optimization. */
|
27 |
+
/**/
|
28 |
+
if (isset ($is_systematic)) /* Already cached? This saves time. */
|
29 |
+
{
|
30 |
+
return $is_systematic; /* Filters will have already been applied. */
|
31 |
+
}
|
32 |
+
else if ($uri && preg_match ("/\/wp-admin\//", $uri)) /* In the admin area? - All admin pages are considered Systematic. */
|
33 |
+
{
|
34 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
35 |
+
}
|
36 |
+
else if ($uri && (preg_match ("/\/(wp-app|wp-signup|wp-register|wp-activate|wp-login|xmlrpc)\.php/", $uri) || (defined ("BP_VERSION") && preg_match ("/\/(" . preg_quote (BP_REGISTER_SLUG, "/") . "|" . preg_quote (BP_ACTIVATION_SLUG, "/") . ")/", $_SERVER["REQUEST_URI"]))))
|
37 |
+
{
|
38 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
39 |
+
}
|
40 |
+
else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
41 |
+
{
|
42 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
43 |
+
}
|
44 |
+
else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
|
45 |
+
{
|
46 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
47 |
+
}
|
48 |
+
else if ($uri && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ()) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $uri))
|
49 |
+
{
|
50 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
51 |
+
}
|
52 |
+
else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
|
53 |
+
{
|
54 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
55 |
+
}
|
56 |
+
else if ($uri && preg_match ("/^s2member/", parse_url ($uri, PHP_URL_QUERY)) && (parse_url ($uri, PHP_URL_PATH) === "/" || parse_url (rtrim ($uri, "/"), PHP_URL_PATH) === parse_url (rtrim (site_url (), "/"), PHP_URL_PATH)))
|
57 |
+
{
|
58 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
|
59 |
+
}
|
60 |
+
else /* Otherwise, we return false. */
|
61 |
+
{
|
62 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", false, get_defined_vars ()));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
?>
|
includes/classes/systematics.inc.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_systematics"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_systematics
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that determines whether we are on a Systematic Use Page.
|
23 |
+
*/
|
24 |
+
public static function is_systematic_use_page ()
|
25 |
+
{
|
26 |
+
static $is_systematic; /* For optimization. */
|
27 |
+
/**/
|
28 |
+
if (isset ($is_systematic)) /* Already cached? This saves time. */
|
29 |
+
{
|
30 |
+
return $is_systematic; /* Filters will have already been applied. */
|
31 |
+
}
|
32 |
+
else if (is_admin ()) /* In the admin area? - All administrational pages are considered Systematic. */
|
33 |
+
{
|
34 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
35 |
+
}
|
36 |
+
else if (preg_match ("/^CLI$/i", PHP_SAPI)) /* CLI = Command Line. Normally indicates a running cron job. */
|
37 |
+
{
|
38 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
39 |
+
}
|
40 |
+
else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"] && !preg_match ("/^localhost(\:[0-9]+)?$/i", $_SERVER["HTTP_HOST"]) && (!defined ("LOCALHOST") || !LOCALHOST))
|
41 |
+
{
|
42 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
43 |
+
}
|
44 |
+
else if (preg_match ("/\/(wp-app|wp-signup|wp-register|wp-activate|wp-login|xmlrpc)\.php/", $_SERVER["REQUEST_URI"]) || (defined ("BP_VERSION") && preg_match ("/\/(" . preg_quote (BP_REGISTER_SLUG, "/") . "|" . preg_quote (BP_ACTIVATION_SLUG, "/") . ")/", $_SERVER["REQUEST_URI"])))
|
45 |
+
{
|
46 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
47 |
+
}
|
48 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
|
49 |
+
{
|
50 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
51 |
+
}
|
52 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]))
|
53 |
+
{
|
54 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
55 |
+
}
|
56 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ()) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]))
|
57 |
+
{
|
58 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
59 |
+
}
|
60 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))
|
61 |
+
{
|
62 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
63 |
+
}
|
64 |
+
else if (preg_match ("/^s2member/", $_SERVER["QUERY_STRING"]) && (parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH) === "/" || parse_url (rtrim ($_SERVER["REQUEST_URI"], "/"), PHP_URL_PATH) === parse_url (rtrim (site_url (), "/"), PHP_URL_PATH)))
|
65 |
+
{
|
66 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
|
67 |
+
}
|
68 |
+
else /* Otherwise, we return false. */
|
69 |
+
{
|
70 |
+
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", false, get_defined_vars ()));
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
?>
|
includes/classes/tracking-codes.inc.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_tracking_codes"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_tracking_codes
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that displays Signup Tracking Codes.
|
23 |
+
These are stored inside s2Member's Transient Queue by the IPN processor.
|
24 |
+
|
25 |
+
Attach to: add_action("login_footer");
|
26 |
+
Attach to: add_action("wp_footer");
|
27 |
+
|
28 |
+
Tracking Codes are only displayed/processed one time.
|
29 |
+
s2Member will display Tracking Codes in (1) of these 3 locations:
|
30 |
+
1. If possible, on the Registration Form, after returning from your Payment Gateway.
|
31 |
+
2. Otherwise, if possible, on the Login Form ( in the footer ) after Registration is completed.
|
32 |
+
3. Otherwise, in the footer of your WordPress® theme, as soon as possible; or after the Customer's very first login.
|
33 |
+
*/
|
34 |
+
public static function display_signup_tracking_codes ()
|
35 |
+
{
|
36 |
+
do_action ("ws_plugin__s2member_before_display_signup_tracking_codes", get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
if (($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_id"])) || ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_signup_tracking"])))
|
39 |
+
{
|
40 |
+
if (($code = get_transient ($transient = "s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $subscr_id))))
|
41 |
+
{
|
42 |
+
delete_transient($transient); /* Only display this ONE time. Delete transient immediately. */
|
43 |
+
/**/
|
44 |
+
echo '<img src="' . esc_attr (site_url ("/?s2member_delete_signup_tracking_cookie=1")) . '" alt="." style="width:1px; height:1px; border:0;" />' . "\n";
|
45 |
+
/**/
|
46 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
47 |
+
do_action ("ws_plugin__s2member_during_display_signup_tracking_codes", get_defined_vars ());
|
48 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
49 |
+
/**/
|
50 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
|
51 |
+
{
|
52 |
+
echo $code . "\n"; /* No PHP here. */
|
53 |
+
}
|
54 |
+
else /* Otherwise, safe to allow PHP code. */
|
55 |
+
{
|
56 |
+
eval ("?>" . $code);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
/**/
|
61 |
+
do_action ("ws_plugin__s2member_after_display_signup_tracking_codes", get_defined_vars ());
|
62 |
+
}
|
63 |
+
/*
|
64 |
+
Function that displays Specific Post/Page Tracking Codes.
|
65 |
+
These are stored inside s2Member's Transient Queue,
|
66 |
+
by BOTH the IPN & Return-Data processors.
|
67 |
+
|
68 |
+
Attach to: add_action("wp_footer");
|
69 |
+
|
70 |
+
Specific Post/Page Tracking Codes are only displayed/processed one time.
|
71 |
+
s2Member will display Tracking Codes in the footer of your theme.
|
72 |
+
*/
|
73 |
+
public static function display_sp_tracking_codes ()
|
74 |
+
{
|
75 |
+
do_action ("ws_plugin__s2member_before_display_sp_tracking_codes", get_defined_vars ());
|
76 |
+
/**/
|
77 |
+
if (($txn_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_sp_tracking"])))
|
78 |
+
{
|
79 |
+
if (($code = get_transient ($transient = "s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $txn_id))))
|
80 |
+
{
|
81 |
+
delete_transient($transient); /* Only display this ONE time. Delete transient immediately. */
|
82 |
+
/**/
|
83 |
+
echo '<img src="' . esc_attr (site_url ("/?s2member_delete_sp_tracking_cookie=1")) . '" alt="." style="width:1px; height:1px; border:0;" />' . "\n";
|
84 |
+
/**/
|
85 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
86 |
+
do_action ("ws_plugin__s2member_during_display_sp_tracking_codes", get_defined_vars ());
|
87 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
88 |
+
/**/
|
89 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
|
90 |
+
{
|
91 |
+
echo $code . "\n"; /* No PHP here. */
|
92 |
+
}
|
93 |
+
else /* Otherwise, it's safe to allow PHP code. */
|
94 |
+
{
|
95 |
+
eval ("?>" . $code);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
/**/
|
100 |
+
do_action ("ws_plugin__s2member_after_display_sp_tracking_codes", get_defined_vars ());
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
?>
|
includes/classes/tracking-cookies.inc.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_tracking_cookies"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_tracking_cookies
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Deletes s2Member's temporary tracking cookie.
|
23 |
+
Attach to: add_action("init");
|
24 |
+
*/
|
25 |
+
public static function delete_signup_tracking_cookie ()
|
26 |
+
{
|
27 |
+
do_action ("ws_plugin__s2member_before_delete_signup_tracking_cookie", get_defined_vars ());
|
28 |
+
/**/
|
29 |
+
if ($_GET["s2member_delete_signup_tracking_cookie"]) /* Deletes cookie. */
|
30 |
+
{
|
31 |
+
setcookie ("s2member_signup_tracking", "", time () + 31556926, "/");
|
32 |
+
/**/
|
33 |
+
do_action ("ws_plugin__s2member_during_delete_signup_tracking_cookie", get_defined_vars ());
|
34 |
+
/**/
|
35 |
+
exit (); /* Clean exit. */
|
36 |
+
}
|
37 |
+
/**/
|
38 |
+
do_action ("ws_plugin__s2member_after_delete_signup_tracking_cookie", get_defined_vars ());
|
39 |
+
}
|
40 |
+
/*
|
41 |
+
Deletes s2Member's temporary tracking cookie.
|
42 |
+
Attach to: add_action("init");
|
43 |
+
*/
|
44 |
+
public static function delete_sp_tracking_cookie ()
|
45 |
+
{
|
46 |
+
do_action ("ws_plugin__s2member_before_delete_sp_tracking_cookie", get_defined_vars ());
|
47 |
+
/**/
|
48 |
+
if ($_GET["s2member_delete_sp_tracking_cookie"]) /* Deletes cookie. */
|
49 |
+
{
|
50 |
+
setcookie ("s2member_sp_tracking", "", time () + 31556926, "/");
|
51 |
+
/**/
|
52 |
+
do_action ("ws_plugin__s2member_during_delete_sp_tracking_cookie", get_defined_vars ());
|
53 |
+
/**/
|
54 |
+
exit (); /* Clean exit. */
|
55 |
+
}
|
56 |
+
/**/
|
57 |
+
do_action ("ws_plugin__s2member_after_delete_sp_tracking_cookie", get_defined_vars ());
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
?>
|
includes/classes/translations.inc.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_translations"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_translations
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Mangles internal translations.
|
23 |
+
Attach to: add_filter("gettext");
|
24 |
+
*/
|
25 |
+
public static function translation_mangler ($translated = FALSE, $original = FALSE, $domain = FALSE)
|
26 |
+
{
|
27 |
+
global $current_site, $current_blog; /* In support of Multisite Networking. */
|
28 |
+
static $translations = array (); /* This static array optimizes this routine. */
|
29 |
+
/**/
|
30 |
+
if (!isset ($translations["is_wp_login"]) || $translations["is_wp_login"])
|
31 |
+
{
|
32 |
+
if ($translations["is_wp_login"] || preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
|
33 |
+
{
|
34 |
+
$translations["is_wp_login"] = true; /* Yes, we are in this area. */
|
35 |
+
/**/
|
36 |
+
if ($translated === "Username" || $translated === "Password") /* Give Filters a chance here. */
|
37 |
+
{
|
38 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", $translated . " *", get_defined_vars ());
|
39 |
+
}
|
40 |
+
else if ($translated === "E-mail") /* Give Filters a chance here. */
|
41 |
+
{
|
42 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Email Address *", get_defined_vars ());
|
43 |
+
}
|
44 |
+
else if ($translated === "Registration complete. Please check your e-mail." && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
45 |
+
{
|
46 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Registration complete. Please log in.", get_defined_vars ());
|
47 |
+
}
|
48 |
+
}
|
49 |
+
else /* Otherwise, false. */
|
50 |
+
$translations["is_wp_login"] = false;
|
51 |
+
}
|
52 |
+
/**/
|
53 |
+
if (!isset ($translations["is_wp_activate"]) || $translations["is_wp_activate"])
|
54 |
+
{
|
55 |
+
if ($translations["is_wp_activate"] || (is_multisite () && preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])))
|
56 |
+
{
|
57 |
+
$translations["is_wp_activate"] = true; /* Yes, we are in this area. */
|
58 |
+
/**/
|
59 |
+
if (preg_match ("/\>View your site\</", $translated)) /* Change the way this link reads. */
|
60 |
+
{
|
61 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", preg_replace ("/\>View your site\</", ">Visit site<", $translated), get_defined_vars ());
|
62 |
+
}
|
63 |
+
}
|
64 |
+
else /* Otherwise, false. */
|
65 |
+
$translations["is_wp_activate"] = false;
|
66 |
+
}
|
67 |
+
/**/
|
68 |
+
if (!isset ($translations["is_wp_signup"]) || $translations["is_wp_signup"])
|
69 |
+
{
|
70 |
+
if ($translations["is_wp_signup"] || (is_multisite () && is_main_site () && preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"])))
|
71 |
+
{
|
72 |
+
$translations["is_wp_signup"] = true; /* Yes, we are in this area. */
|
73 |
+
/**/
|
74 |
+
if ($translated === "If you’re not going to use a great site domain, leave it for a new user. Now have at it!")
|
75 |
+
{
|
76 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "", get_defined_vars ());
|
77 |
+
}
|
78 |
+
else if ($translated === "Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!")
|
79 |
+
{
|
80 |
+
if (is_user_logged_in () && is_object ($current_user = wp_get_current_user ())) /* Must have a User obj. */
|
81 |
+
{
|
82 |
+
$blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
|
83 |
+
$current_user_blogs = (is_array ($blogs = get_blogs_of_user ($current_user->ID))) ? count ($blogs) - 1 : 0;
|
84 |
+
$current_user_blogs = ($current_user_blogs >= 0) ? $current_user_blogs : 0;
|
85 |
+
/**/
|
86 |
+
if ($current_user_blogs >= 1) /* So here they already have at least 1 Blog. This message works fine. */
|
87 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "By filling out the form below, you can <strong>add another site to your account</strong>." . ( ($blogs_allowed > 1) ? "<br />You may create up to " . esc_html ($blogs_allowed) . " site" . ( ($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "." : ""), get_defined_vars ());
|
88 |
+
/**/
|
89 |
+
else /* Otherwise, we need a different message. One that is NOT confusing to a new Customer. */
|
90 |
+
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "By filling out the form below, you can <strong>add a site to your account</strong>." . ( ($blogs_allowed > 1) ? "<br />You may create up to " . esc_html ($blogs_allowed) . " site" . ( ($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "." : ""), get_defined_vars ());
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
else /* Otherwise, false. */
|
95 |
+
$translations["is_wp_signup"] = false;
|
96 |
+
}
|
97 |
+
/**/
|
98 |
+
return $translated; /* No Filters / conserve resources. */
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
?>
|
includes/classes/user-access.inc.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_user_access"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_access
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function for determing the Access Role of a User/Member.
|
23 |
+
If $user is NOT passed in, check the current User/Member.
|
24 |
+
If $user IS passed in, this function will check a specific $user.
|
25 |
+
*/
|
26 |
+
public static function user_access_role ($user = FALSE)
|
27 |
+
{
|
28 |
+
$user = (func_num_args () && is_object ($user)) ? $user : false;
|
29 |
+
/**/
|
30 |
+
if ((func_num_args () && !$user) || (!$user && (! ($user = (is_user_logged_in ()) ? wp_get_current_user () : false) || !reset ($user->roles))))
|
31 |
+
{
|
32 |
+
return apply_filters ("ws_plugin__s2member_user_access_role", "", get_defined_vars ());
|
33 |
+
/* Return of "", means $user was passed in but is NOT an object; or nobody is logged in, or they have to Role. */
|
34 |
+
}
|
35 |
+
else /* Else we return the first role in their array of assigned WordPress Roles. */
|
36 |
+
return apply_filters ("ws_plugin__s2member_user_access_role", reset ($user->roles), get_defined_vars ());
|
37 |
+
}
|
38 |
+
/*
|
39 |
+
Function for determing the Custom Capabilities of a User/Member.
|
40 |
+
|
41 |
+
If $user is NOT passed in, check the current User/Member.
|
42 |
+
Returns an array of Custom Capabilities.
|
43 |
+
*/
|
44 |
+
public static function user_access_ccaps ($user = FALSE)
|
45 |
+
{
|
46 |
+
$user = (func_num_args () && is_object ($user)) ? $user : false;
|
47 |
+
/**/
|
48 |
+
if ((func_num_args () && !$user) || (!$user && ! ($user = (is_user_logged_in ()) ? wp_get_current_user () : false)))
|
49 |
+
{
|
50 |
+
return apply_filters ("ws_plugin__s2member_user_access_ccaps", array (), get_defined_vars ());
|
51 |
+
}
|
52 |
+
else /* Otherwise, we DO have the $user object available. */
|
53 |
+
{
|
54 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
55 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
56 |
+
$ccaps[] = preg_replace ("/^access_s2member_ccap_/", "", $cap);
|
57 |
+
/**/
|
58 |
+
return apply_filters ("ws_plugin__s2member_user_access_ccaps", (array)$ccaps, get_defined_vars ());
|
59 |
+
}
|
60 |
+
}
|
61 |
+
/*
|
62 |
+
Function for determing the Access Level of a User/Member.
|
63 |
+
|
64 |
+
If $user is NOT passed in, check the current User/Member.
|
65 |
+
Returns -1 thru 4, according to the User/Member's Access Level.
|
66 |
+
Negative (-1) if a User/Member is NOT logged in.
|
67 |
+
|
68 |
+
If $user IS passed in, this function will check a specific $user.
|
69 |
+
Returns -1 thru 4, according to the User/Member's Access Level.
|
70 |
+
Negative (-1) if $user is passed in, but NOT an object.
|
71 |
+
*/
|
72 |
+
public static function user_access_level ($user = FALSE)
|
73 |
+
{
|
74 |
+
$user = (func_num_args () && is_object ($user)) ? $user : false;
|
75 |
+
/**/
|
76 |
+
if ((func_num_args () && !$user) || (!$user && ! ( (is_user_logged_in ()) ? wp_get_current_user () : false)))
|
77 |
+
{
|
78 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", -1, get_defined_vars ());
|
79 |
+
/* Return of -1, means $user was passed in but is NOT an object; or nobody is logged in. */
|
80 |
+
}
|
81 |
+
else if (($user && $user->has_cap ("access_s2member_level4")) || (!$user && current_user_can ("access_s2member_level4")))
|
82 |
+
{
|
83 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 4, get_defined_vars ());
|
84 |
+
/* The $user has; or a Member is logged in with Level 4 Access. */
|
85 |
+
}
|
86 |
+
else if (($user && $user->has_cap ("access_s2member_level3")) || (!$user && current_user_can ("access_s2member_level3")))
|
87 |
+
{
|
88 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 3, get_defined_vars ());
|
89 |
+
/* The $user has; or a Member is logged in with Level 3 Access. */
|
90 |
+
}
|
91 |
+
else if (($user && $user->has_cap ("access_s2member_level2")) || (!$user && current_user_can ("access_s2member_level2")))
|
92 |
+
{
|
93 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 2, get_defined_vars ());
|
94 |
+
/* The $user has; or a Member is logged in with Level 2 Access. */
|
95 |
+
}
|
96 |
+
else if (($user && $user->has_cap ("access_s2member_level1")) || (!$user && current_user_can ("access_s2member_level1")))
|
97 |
+
{
|
98 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 1, get_defined_vars ());
|
99 |
+
/* The $user has; or a Member is logged in with Level 1 Access. */
|
100 |
+
}
|
101 |
+
else if (($user && $user->has_cap ("access_s2member_level0")) || (!$user && current_user_can ("access_s2member_level0")))
|
102 |
+
{
|
103 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 0, get_defined_vars ());
|
104 |
+
/* The $user has; or a Free Subscriber is logged in with Level 0 Access. */
|
105 |
+
}
|
106 |
+
else /* Else we assume this is a User ( a Free Subscriber with a level of 0. ). */
|
107 |
+
return apply_filters ("ws_plugin__s2member_user_access_level", 0, get_defined_vars ());
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
?>
|
includes/classes/user-deletions.inc.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_user_deletions"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_deletions
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function for handling user deletions.
|
23 |
+
Attach to: add_action("remove_user_from_blog");
|
24 |
+
*/
|
25 |
+
public static function handle_ms_user_deletions ($user_id = FALSE, $blog_id = FALSE, $s2says = FALSE)
|
26 |
+
{
|
27 |
+
static $processed = array (); /* No duplicate processing. */
|
28 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
29 |
+
/**/
|
30 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
31 |
+
do_action ("ws_plugin__s2member_before_handle_ms_user_deletions", get_defined_vars ());
|
32 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
33 |
+
/**/
|
34 |
+
if (is_multisite () && !$processed[$user_id]) /* Safeguard this routine against duplicate processing. */
|
35 |
+
{
|
36 |
+
if (($s2says || (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "users.php")) && ($processed[$user_id] = true))
|
37 |
+
/* Do NOT react on this globally. There are many routines that remove Users for different/minor reasons. */
|
38 |
+
{
|
39 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
40 |
+
do_action ("ws_plugin__s2member_during_handle_ms_user_deletions_before", get_defined_vars ());
|
41 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
42 |
+
/**/
|
43 |
+
c_ws_plugin__s2member_user_deletions::handle_user_deletions ($user_id); /* Hand this over. */
|
44 |
+
/**/
|
45 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
46 |
+
do_action ("ws_plugin__s2member_during_handle_ms_user_deletions_after", get_defined_vars ());
|
47 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
48 |
+
}
|
49 |
+
}
|
50 |
+
/**/
|
51 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
52 |
+
do_action ("ws_plugin__s2member_after_handle_ms_user_deletions", get_defined_vars ());
|
53 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
54 |
+
/**/
|
55 |
+
return; /* Return for uniformity. */
|
56 |
+
}
|
57 |
+
/*
|
58 |
+
Function for handling user deletions.
|
59 |
+
Attach to: add_action("delete_user");
|
60 |
+
Attach to: add_action("wpmu_delete_user");
|
61 |
+
|
62 |
+
This also handles Multisite removal hand-offs.
|
63 |
+
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions().
|
64 |
+
*/
|
65 |
+
public static function handle_user_deletions ($user_id = FALSE)
|
66 |
+
{
|
67 |
+
static $processed = array (); /* No duplicate processing. */
|
68 |
+
/**/
|
69 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
70 |
+
do_action ("ws_plugin__s2member_before_handle_user_deletions", get_defined_vars ());
|
71 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
72 |
+
/**/
|
73 |
+
if (!$processed[$user_id] && ($processed[$user_id] = true)) /* Safeguard this routine against duplicate processing. */
|
74 |
+
{
|
75 |
+
$custom = get_user_option ("s2member_custom", $user_id); /* An EOT Notification is triggered, EVEN if empty. */
|
76 |
+
$subscr_id = get_user_option ("s2member_subscr_id", $user_id); /* And also, EVEN if this is empty. */
|
77 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); /* Used in API Notifications. */
|
78 |
+
/**/
|
79 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
80 |
+
do_action ("ws_plugin__s2member_during_handle_user_before_deletions", get_defined_vars ());
|
81 |
+
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "user-removal-deletion");
|
82 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
83 |
+
/**/
|
84 |
+
delete_user_option ($user_id, "s2member_custom"); /* Now we can remove these User options ( for this Blog ). */
|
85 |
+
delete_user_option ($user_id, "s2member_subscr_id"); /* The `wpmu_delete_user` Hook also handles this. */
|
86 |
+
delete_user_option ($user_id, "s2member_subscr_gateway");
|
87 |
+
/**/
|
88 |
+
delete_user_option ($user_id, "s2member_ipn_signup_vars");
|
89 |
+
delete_user_option ($user_id, "s2member_paid_registration_times");
|
90 |
+
delete_user_option ($user_id, "s2member_last_payment_time");
|
91 |
+
delete_user_option ($user_id, "s2member_last_status_scan");
|
92 |
+
delete_user_option ($user_id, "s2member_auto_eot_time");
|
93 |
+
delete_user_option ($user_id, "s2member_notes");
|
94 |
+
/**/
|
95 |
+
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
96 |
+
delete_user_option ($user_id, "s2member_file_download_access_log");
|
97 |
+
/**/
|
98 |
+
if (is_object ($user = new WP_User ($user_id)) && $user->ID && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
99 |
+
{
|
100 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications on user deletion. */
|
101 |
+
/**/
|
102 |
+
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 ($subscr_id)), $url)))
|
103 |
+
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)))
|
104 |
+
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)))
|
105 |
+
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
106 |
+
if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
|
107 |
+
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
108 |
+
{
|
109 |
+
if (is_array ($fields) && !empty ($fields))
|
110 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
111 |
+
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
112 |
+
break;
|
113 |
+
/**/
|
114 |
+
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
115 |
+
c_ws_plugin__s2member_utils_urls::remote ($url);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
/**/
|
119 |
+
if (is_object ($user = new WP_User ($user_id)) && $user->ID && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
120 |
+
{
|
121 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); /* Release all Filters applied to wp_mail() From: headers. */
|
122 |
+
/**/
|
123 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
|
124 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
125 |
+
/**/
|
126 |
+
$msg .= "subscr_id: %%subscr_id%%\n";
|
127 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
128 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
129 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
130 |
+
$msg .= "user_email: %%user_email%%\n";
|
131 |
+
$msg .= "user_login: %%user_login%%\n";
|
132 |
+
$msg .= "user_id: %%user_id%%\n";
|
133 |
+
/**/
|
134 |
+
if (is_array ($fields) && !empty ($fields))
|
135 |
+
foreach ($fields as $var => $val)
|
136 |
+
$msg .= $var . ": %%" . $var . "%%\n";
|
137 |
+
/**/
|
138 |
+
$msg .= "cv0: %%cv0%%\n";
|
139 |
+
$msg .= "cv1: %%cv1%%\n";
|
140 |
+
$msg .= "cv2: %%cv2%%\n";
|
141 |
+
$msg .= "cv3: %%cv3%%\n";
|
142 |
+
$msg .= "cv4: %%cv4%%\n";
|
143 |
+
$msg .= "cv5: %%cv5%%\n";
|
144 |
+
$msg .= "cv6: %%cv6%%\n";
|
145 |
+
$msg .= "cv7: %%cv7%%\n";
|
146 |
+
$msg .= "cv8: %%cv8%%\n";
|
147 |
+
$msg .= "cv9: %%cv9%%";
|
148 |
+
/**/
|
149 |
+
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 ($subscr_id), $msg)))
|
150 |
+
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)))
|
151 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
152 |
+
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
153 |
+
if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
|
154 |
+
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
155 |
+
{
|
156 |
+
if (is_array ($fields) && !empty ($fields))
|
157 |
+
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
158 |
+
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
159 |
+
break;
|
160 |
+
/**/
|
161 |
+
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
162 |
+
foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
|
163 |
+
($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;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
/**/
|
167 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
168 |
+
do_action ("ws_plugin__s2member_during_handle_user_deletions", get_defined_vars ());
|
169 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
170 |
+
}
|
171 |
+
/**/
|
172 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
173 |
+
do_action ("ws_plugin__s2member_after_handle_user_deletions", get_defined_vars ());
|
174 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
175 |
+
/**/
|
176 |
+
return; /* Return for uniformity. */
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
?>
|
includes/classes/user-new-in.inc.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_user_new_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_new_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Callback that adds Custom Fields to `/wp-admin/user-new.php`.
|
23 |
+
We have to buffer output because `/user-new.php` has NO Hooks.
|
24 |
+
Attach to: ob_start("c_ws_plugin__s2member_user_new_in::_admin_user_new_fields");
|
25 |
+
*/
|
26 |
+
public static function _admin_user_new_fields ($buffer = FALSE)
|
27 |
+
{
|
28 |
+
global $pagenow; /* The current admin page file name. */
|
29 |
+
/**/
|
30 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
31 |
+
do_action ("_ws_plugin__s2member_before_admin_user_new_fields", get_defined_vars ());
|
32 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
33 |
+
/**/
|
34 |
+
if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php" && current_user_can ("create_users"))
|
35 |
+
{
|
36 |
+
$_POST = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
|
37 |
+
/**/
|
38 |
+
$unfs = '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
39 |
+
/**/
|
40 |
+
$unfs .= '<h3 style="position:relative;"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/large-icon.png" title="s2Member ( a Membership management system for WordPress® )" alt="" style="position:absolute; top:-15px; right:0; border:0;" />s2Member Configuration & Profile Fields' . ( (is_multisite ()) ? ' ( for this Blog )' : '') . '</h3>' . "\n";
|
41 |
+
/**/
|
42 |
+
$unfs .= '<table class="form-table">' . "\n";
|
43 |
+
/**/
|
44 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
45 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before", get_defined_vars ());
|
46 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
47 |
+
/**/
|
48 |
+
if (is_multisite ()) /* Multisite Networking is currently lacking these fields; we pop them in. */
|
49 |
+
{
|
50 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
51 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_first_name", get_defined_vars ());
|
52 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
53 |
+
/**/
|
54 |
+
$unfs .= '<tr>' . "\n";
|
55 |
+
$unfs .= '<th><label>First Name:</label></th>' . "\n";
|
56 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_first_name" id="ws-plugin--s2member-user-new-first-name" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_first_name"]) . '" class="regular-text" /></td>' . "\n";
|
57 |
+
$unfs .= '</tr>' . "\n";
|
58 |
+
/**/
|
59 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
60 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_first_name", get_defined_vars ());
|
61 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
62 |
+
/**/
|
63 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
64 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_last_name", get_defined_vars ());
|
65 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
66 |
+
/**/
|
67 |
+
$unfs .= '<tr>' . "\n";
|
68 |
+
$unfs .= '<th><label>Last Name:</label></th>' . "\n";
|
69 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_last_name" id="ws-plugin--s2member-user-new-last-name" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_last_name"]) . '" class="regular-text" /></td>' . "\n";
|
70 |
+
$unfs .= '</tr>' . "\n";
|
71 |
+
/**/
|
72 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
73 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_last_name", get_defined_vars ());
|
74 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
75 |
+
}
|
76 |
+
/**/
|
77 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
78 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_subscr_gateway", get_defined_vars ());
|
79 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
80 |
+
/**/
|
81 |
+
$unfs .= '<tr>' . "\n";
|
82 |
+
$unfs .= '<th><label>Paid Subscr. Gateway:</label> <a href="#" onclick="alert(\'A Payment Gateway code is associated with the Paid Subscr. ID below. A Paid Subscription ID ( or a Buy Now Transaction ID ) is only valid for paid Members. Also known as ( a Recurring Profile ID, a ClickBank® Receipt #, a Google® TID/SID ( with an s2 prefix ), an AliPay® Trade No. ). Under normal circumstances, this is filled automatically by s2Member. This field is ONLY here for Customer Service purposes; just in case you ever need to enter a Paid Subscr. Gateway/ID manually. This field will be empty for Free Subscribers, and/or anyone who is NOT paying you.\\n\\nThe value of Paid® Subscr. ID, can be a PayPal® Standard `Subscription ID`, or a PayPal® Pro `Recurring Profile ID`, or a PayPal® `Transaction ID`; depending on the type of sale. Your PayPal® account will supply this information. If you\\\'re using Google® Checkout, use the TID/SID value in the sale Description; it always starts with `s2-`. ClickBank® provides a Receipt #, ccBill® provides a Subscription ID, Authorize.Net® provides a Subscription ID, and AliPay® provides a Transaction ID. The general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
83 |
+
$unfs .= '<td><select name="ws_plugin__s2member_user_new_s2member_subscr_gateway" id="ws-plugin--s2member-user-new-s2member-subscr-gateway" style="width:27.5em;"><option value=""></option>' . "\n";
|
84 |
+
foreach (apply_filters ("ws_plugin__s2member_profile_s2member_subscr_gateways", array ("paypal" => "PayPal® ( code: paypal )"), get_defined_vars ()) as $gateway => $gateway_name)
|
85 |
+
$unfs .= '<option value="' . esc_attr ($gateway) . '"' . ( ($gateway === $_POST["ws_plugin__s2member_user_new_s2member_subscr_gateway"]) ? ' selected="selected"' : '') . '>' . esc_html ($gateway_name) . '</option>' . "\n";
|
86 |
+
$unfs .= '</select>' . "\n";
|
87 |
+
$unfs .= '</td>' . "\n";
|
88 |
+
$unfs .= '</tr>' . "\n";
|
89 |
+
/**/
|
90 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
91 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_subscr_gateway", get_defined_vars ());
|
92 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
93 |
+
/**/
|
94 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
95 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_subscr_id", get_defined_vars ());
|
96 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
97 |
+
/**/
|
98 |
+
$unfs .= '<tr>' . "\n";
|
99 |
+
$unfs .= '<th><label>Paid Subscr. ID:</label> <a href="#" onclick="alert(\'A Paid Subscription ID ( or a Buy Now Transaction ID ) is only valid for paid Members. Also known as ( a Recurring Profile ID, a ClickBank® Receipt #, a Google® TID/SID ( with an s2 prefix ), an AliPay® Trade No. ). Under normal circumstances, this is filled automatically by s2Member. This field is ONLY here for Customer Service purposes; just in case you ever need to enter a Paid Subscr. Gateway/ID manually. This field will be empty for Free Subscribers, and/or anyone who is NOT paying you.\\n\\nThe value of Paid® Subscr. ID, can be a PayPal® Standard `Subscription ID`, or a PayPal® Pro `Recurring Profile ID`, or a PayPal® `Transaction ID`; depending on the type of sale. Your PayPal® account will supply this information. If you\\\'re using Google® Checkout, use the TID/SID value in the sale Description; it always starts with `s2-`. ClickBank® provides a Receipt #, ccBill® provides a Subscription ID, Authorize.Net® provides a Subscription ID, and AliPay® provides a Transaction ID. The general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
100 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_s2member_subscr_id" id="ws-plugin--s2member-user-new-s2member-subscr-id" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_s2member_subscr_id"]) . '" class="regular-text" /></td>' . "\n";
|
101 |
+
$unfs .= '</tr>' . "\n";
|
102 |
+
/**/
|
103 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
104 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_subscr_id", get_defined_vars ());
|
105 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
106 |
+
/**/
|
107 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
108 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_custom", get_defined_vars ());
|
109 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
110 |
+
/**/
|
111 |
+
$unfs .= '<tr>' . "\n";
|
112 |
+
$unfs .= '<th><label>Custom Value:</label> <a href="#" onclick="alert(\'A Paid Subscription is always associated with a Custom String that is passed through the custom=\\\'\\\'' . c_ws_plugin__s2member_utils_strings::esc_sq (esc_attr ($_SERVER["HTTP_HOST"])) . '\\\'\\\' attribute of your Shortcode. This Custom Value, MUST always start with your domain name. However, you can also pipe delimit additional values after your domain, if you need to.\\n\\nFor example:\n' . c_ws_plugin__s2member_utils_strings::esc_sq (esc_attr ($_SERVER["HTTP_HOST"])) . '|cv1|cv2|cv3\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
113 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_s2member_custom" id="ws-plugin--s2member-user-new-s2member-custom" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_s2member_custom"]) . '" class="regular-text" /></td>' . "\n";
|
114 |
+
$unfs .= '</tr>' . "\n";
|
115 |
+
/**/
|
116 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
117 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_custom", get_defined_vars ());
|
118 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
119 |
+
/**/
|
120 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
|
121 |
+
/* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
|
122 |
+
{
|
123 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
124 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_ccaps", get_defined_vars ());
|
125 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
126 |
+
/**/
|
127 |
+
$unfs .= '<tr>' . "\n";
|
128 |
+
$unfs .= '<th><label>Custom Capabilities:</label> <a href="#" onclick="alert(\'Optional. This is VERY advanced. For full details, see:\\ns2Member -> API Scripting -> Custom Capabilities.' . ( (is_multisite ()) ? '\\n\\nCustom Capabilities are assigned on a per-Blog basis. So having a set of Custom Capabilities for one Blog, and having NO Custom Capabilities on another Blog - is very common. This is how permissions are designed to work.' : '') . '\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
129 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_s2member_ccaps" id="ws-plugin--s2member-user-new-s2member-ccaps" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_s2member_ccaps"]) . '" class="regular-text" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" /></td>' . "\n";
|
130 |
+
$unfs .= '</tr>' . "\n";
|
131 |
+
/**/
|
132 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
133 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_ccaps", get_defined_vars ());
|
134 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
135 |
+
}
|
136 |
+
/**/
|
137 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
138 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_auto_eot_time", get_defined_vars ());
|
139 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
140 |
+
/**/
|
141 |
+
$unfs .= '<tr>' . "\n";
|
142 |
+
$unfs .= '<th><label>Automatic EOT Time:</label> <a href="#" onclick="alert(\'EOT = End Of Term. ( i.e. Account Expiration / Termination. ).\\n\\nIf you leave this empty, s2Member will configure an EOT Time automatically, based on the paid Subscription associated with this account. In other words, if a paid Subscription expires, is cancelled, terminated, refunded, reversed, or charged back to you; s2Member will deal with the EOT automatically.\\n\\nThat being said, if you would rather take control over this, you can. If you type in a date manually, s2Member will obey the Auto-EOT Time that you\\\'ve given, no matter what. In other words, you can force certain Members to expire automatically, at a time that you specify. s2Member will obey.\\n\\nValid formats for Automatic EOT Time:\\n\\nmm/dd/yyyy\\nyyyy-mm-dd\\n+1 year\\n+2 weeks\\n+2 months\\n+10 minutes\\nnext thursday\\ntomorrow\\ntoday\\n\\n* anything compatible with PHP\\\'s strtotime() function.\'); return false;" tabindex="-1">[?]</a>' . (($auto_eot_time) ? '<br /><small>( based on server time )</small>' : '') . '</th>' . "\n";
|
143 |
+
$unfs .= '<td><input type="text" name="ws_plugin__s2member_user_new_s2member_auto_eot_time" id="ws-plugin--s2member-user-new-auto-eot-time" value="' . format_to_edit ($_POST["ws_plugin__s2member_user_new_s2member_auto_eot_time"]) . '" class="regular-text" /></td>' . "\n";
|
144 |
+
$unfs .= '</tr>' . "\n";
|
145 |
+
/**/
|
146 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
147 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_auto_eot_time", get_defined_vars ());
|
148 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
149 |
+
/**/
|
150 |
+
if (c_ws_plugin__s2member_list_servers::list_servers_integrated ()) /* Only if integrated with s2Member. */
|
151 |
+
{
|
152 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
153 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_opt_in", get_defined_vars ());
|
154 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
155 |
+
/**/
|
156 |
+
$unfs .= '<tr>' . "\n";
|
157 |
+
$unfs .= '<th><label>Process List Servers:</label> <a href="#" onclick="alert(\'You have at least one List Server integrated with s2Member. Would you like to process a confirmation request for this new User? If not, just leave the box un-checked.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
158 |
+
$unfs .= '<td><label><input type="checkbox" name="ws_plugin__s2member_user_new_opt_in" id="ws-plugin--s2member-user-new-opt-in" value="1"' . ( ($_POST["ws_plugin__s2member_user_new_opt_in"]) ? ' checked="checked"' : '') . ' /> Yes, send a mailing list confirmation email to this new User.</label></td>' . "\n";
|
159 |
+
$unfs .= '</tr>' . "\n";
|
160 |
+
/**/
|
161 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
162 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_opt_in", get_defined_vars ());
|
163 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
164 |
+
}
|
165 |
+
/**/
|
166 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) /* Only if configured. */
|
167 |
+
{
|
168 |
+
$unfs .= '<tr>' . "\n";
|
169 |
+
$unfs .= '<td colspan="2">' . "\n";
|
170 |
+
$unfs .= '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
171 |
+
$unfs .= '</td>' . "\n";
|
172 |
+
$unfs .= '</tr>' . "\n";
|
173 |
+
/**/
|
174 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
175 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_custom_fields", get_defined_vars ());
|
176 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
177 |
+
/**/
|
178 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
179 |
+
{
|
180 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
181 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_during_custom_fields_before", get_defined_vars ());
|
182 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
183 |
+
/**/
|
184 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
185 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
186 |
+
/**/
|
187 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
188 |
+
if (apply_filters ("_ws_plugin__s2member_during_admin_user_new_fields_during_custom_fields_display", true, get_defined_vars ()))
|
189 |
+
{
|
190 |
+
$unfs .= '<tr>' . "\n";
|
191 |
+
$unfs .= '<th><label>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ucwords (preg_replace ("/_/", " ", $field_var)) : $field["label"]) . ':</label></th>' . "\n";
|
192 |
+
$unfs .= '<td>' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_user_new_", "ws-plugin--s2member-user-new-", "", ( (preg_match ("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $_POST, $_POST["ws_plugin__s2member_user_new_" . $field_var]) . '</td>' . "\n";
|
193 |
+
$unfs .= '</tr>' . "\n";
|
194 |
+
}
|
195 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
196 |
+
/**/
|
197 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
198 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_during_custom_fields_after", get_defined_vars ());
|
199 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
200 |
+
}
|
201 |
+
/**/
|
202 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
203 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_custom_fields", get_defined_vars ());
|
204 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
205 |
+
/**/
|
206 |
+
$unfs .= '<tr>' . "\n";
|
207 |
+
$unfs .= '<td colspan="2">' . "\n";
|
208 |
+
$unfs .= '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
209 |
+
$unfs .= '</td>' . "\n";
|
210 |
+
$unfs .= '</tr>' . "\n";
|
211 |
+
}
|
212 |
+
/**/
|
213 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
214 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_before_notes", get_defined_vars ());
|
215 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
216 |
+
/**/
|
217 |
+
$unfs .= '<tr>' . "\n";
|
218 |
+
$unfs .= '<th><label>Administrative<br />Notations:</label> <a href="#" onclick="alert(\'This is for Administrative purposes. You can keep a list of Notations about this account. These Notations are private; Users/Members will never see these.\\n\\n*Note* The s2Member software may `append` Notes to this field occassionaly, under special circumstances. For example, when/if s2Member demotes a paid Member to a Free Subscriber, s2Member will leave a Note in this field.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
219 |
+
$unfs .= '<td><textarea name="ws_plugin__s2member_user_new_s2member_notes" id="ws-plugin--s2member-user-new-s2member-notes" rows="5" wrap="off" spellcheck="false" style="width:99%;">' . format_to_edit ($_POST["ws_plugin__s2member_user_new_s2member_notes"]) . '</textarea></td>' . "\n";
|
220 |
+
$unfs .= '</tr>' . "\n";
|
221 |
+
/**/
|
222 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
223 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after_notes", get_defined_vars ());
|
224 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
225 |
+
/**/
|
226 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
227 |
+
do_action ("_ws_plugin__s2member_during_admin_user_new_fields_after", get_defined_vars ());
|
228 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
229 |
+
/**/
|
230 |
+
$unfs .= '</table>' . "\n";
|
231 |
+
/**/
|
232 |
+
$unfs .= '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
233 |
+
/**/
|
234 |
+
if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
|
235 |
+
$buffer = preg_replace ("/(\<\/table\>)([\r\n\t\s ]*)(\<p class\=\"submit\"\>)([\r\n\t\s ]*)(\<input type\=\"submit\" name\=\"createuser\")/", "$1$2" . $unfs . "$3$4$5", $buffer);
|
236 |
+
/**/
|
237 |
+
else /* This is for versions prior to WordPress® v3.1. */
|
238 |
+
$buffer = preg_replace ("/(\<\/table\>)([\r\n\t\s ]*)(\<p class\=\"submit\"\>)([\r\n\t\s ]*)(\<input name\=\"adduser\")/", "$1$2" . $unfs . "$3$4$5", $buffer);
|
239 |
+
}
|
240 |
+
/**/
|
241 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
242 |
+
do_action ("_ws_plugin__s2member_after_admin_user_new_fields", get_defined_vars ());
|
243 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
244 |
+
/**/
|
245 |
+
return apply_filters ("_ws_plugin__s2member_admin_user_new_fields", $buffer, get_defined_vars ());
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
?>
|
includes/classes/user-new.inc.php
ADDED
@@ -0,0 +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_user_new"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_new
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that adds custom fields to `/wp-admin/user-new.php`.
|
23 |
+
We have to buffer output because `/user-new.php` has NO Hooks.
|
24 |
+
Attach to: add_action("admin_init");
|
25 |
+
*/
|
26 |
+
public static function admin_user_new_fields ()
|
27 |
+
{
|
28 |
+
global $pagenow; /* The current admin page file name. */
|
29 |
+
/**/
|
30 |
+
do_action ("ws_plugin__s2member_before_admin_user_new_fields", get_defined_vars ());
|
31 |
+
/**/
|
32 |
+
if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "user-new.php" && current_user_can ("create_users"))
|
33 |
+
{
|
34 |
+
ob_start ("c_ws_plugin__s2member_user_new_in::_admin_user_new_fields"); /* No Hooks, so we buffer. */
|
35 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_during_admin_user_new_fields", get_defined_vars ());
|
37 |
+
}
|
38 |
+
/**/
|
39 |
+
do_action ("ws_plugin__s2member_after_admin_user_new_fields", get_defined_vars ());
|
40 |
+
/**/
|
41 |
+
return; /* Return for uniformity. */
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
?>
|
includes/classes/user-notes.inc.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
+
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
+
|
6 |
+
Released under the terms of the GNU General Public License.
|
7 |
+
You should have received a copy of the GNU General Public License,
|
8 |
+
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_user_notes"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_notes
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Append a note onto a specific User/Member's account.
|
23 |
+
*/
|
24 |
+
public static function append_user_notes ($user_id = FALSE, $notes = FALSE)
|
25 |
+
{
|
26 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
27 |
+
do_action ("ws_plugin__s2member_before_append_user_notes", get_defined_vars ());
|
28 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
29 |
+
/**/
|
30 |
+
if ($user_id && $notes && is_string ($notes)) /* Must have these. */
|
31 |
+
{
|
32 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
33 |
+
do_action ("ws_plugin__s2member_during_append_user_notes", get_defined_vars ());
|
34 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
35 |
+
/**/
|
36 |
+
$notes = trim (get_user_option ("s2member_notes", $user_id) . "\n" . $notes);
|
37 |
+
/**/
|
38 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
39 |
+
}
|
40 |
+
/**/
|
41 |
+
return apply_filters ("ws_plugin__s2member_append_user_notes", $notes, get_defined_vars ());
|
42 |
+
}
|
43 |
+
/*
|
44 |
+
Clear specific notes from a User/Member's account; based on line-by-line regex.
|
45 |
+
*/
|
46 |
+
public static function clear_user_note_lines ($user_id = FALSE, $regex = FALSE)
|
47 |
+
{
|
48 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
49 |
+
do_action ("ws_plugin__s2member_before_clear_user_note_lines", get_defined_vars ());
|
50 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
51 |
+
/**/
|
52 |
+
if ($user_id && $regex && is_string ($regex) && ($lines = array ()))
|
53 |
+
{
|
54 |
+
/* Careful here to preserve empty lines. */
|
55 |
+
$notes = trim (get_user_option ("s2member_notes", $user_id));
|
56 |
+
foreach (preg_split ("/\n/", $notes) as $line)
|
57 |
+
if (!preg_match ($regex, $line))
|
58 |
+
$lines[] = $line;
|
59 |
+
/**/
|
60 |
+
$notes = trim (implode ("\n", $lines));
|
61 |
+
/**/
|
62 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
63 |
+
do_action ("ws_plugin__s2member_during_clear_user_note_lines", get_defined_vars ());
|
64 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
65 |
+
/**/
|
66 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
67 |
+
}
|
68 |
+
/**/
|
69 |
+
return apply_filters ("ws_plugin__s2member_clear_user_note_lines", $notes, get_defined_vars ());
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
?>
|
includes/classes/user-securities.inc.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_user_securities"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_user_securities
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Alters `map_meta_cap()` on a Multisite Blog Farm.
|
23 |
+
Attach to: add_filter("map_meta_cap");
|
24 |
+
*/
|
25 |
+
public static function ms_map_meta_cap ($caps = FALSE, $cap = FALSE, $user_id = FALSE)
|
26 |
+
{
|
27 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
28 |
+
do_action ("ws_plugin__s2member_before_ms_map_meta_cap", get_defined_vars ());
|
29 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
30 |
+
/**/
|
31 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_super_admin ())
|
32 |
+
{
|
33 |
+
if (in_array ($cap, array_keys ($map = array ("edit_user" => "edit_users", "edit_users" => "edit_users"))))
|
34 |
+
{
|
35 |
+
if (is_object ($user = new WP_User ($user_id)) && $user->has_cap ("administrator"))
|
36 |
+
$caps = array ($map[$cap]);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
/**/
|
40 |
+
return apply_filters ("ws_plugin__s2member_ms_map_meta_cap", $caps, get_defined_vars ());
|
41 |
+
}
|
42 |
+
/*
|
43 |
+
Alters this Filter inside `/wp-admin/user-edit.php`.
|
44 |
+
Attach to: add_filter("enable_edit_any_user_configuration");
|
45 |
+
*/
|
46 |
+
public static function ms_allow_edits ($allow = FALSE)
|
47 |
+
{
|
48 |
+
global $user_id; /* Available inside `/wp-admin/user-edit.php`. */
|
49 |
+
/**/
|
50 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
51 |
+
do_action ("ws_plugin__s2member_before_ms_allow_edits", get_defined_vars ());
|
52 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
53 |
+
/**/
|
54 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () /* Admins can edit their Users. */
|
55 |
+
&& (is_super_admin () || (current_user_can ("administrator") && $user_id && is_user_member_of_blog ($user_id))))
|
56 |
+
$allow = true; /* Yes, allow Administrators to edit User Profiles. */
|
57 |
+
/**/
|
58 |
+
return apply_filters ("ws_plugin__s2member_ms_allow_edits", $allow, get_defined_vars ());
|
59 |
+
}
|
60 |
+
/*
|
61 |
+
Hides Password fields for Demo Users; and deals with Password fields on Multisite Blog Farms.
|
62 |
+
|
63 |
+
Demo accounts ( where the Username MUST be "demo" ), will NOT be allowed to change their Password.
|
64 |
+
Any other restrictions you need to impose must be done through custom programming, using s2Member's Conditionals.
|
65 |
+
See `s2Member -> API Scripting`.
|
66 |
+
|
67 |
+
Attach to: add_filter("show_password_fields");
|
68 |
+
*/
|
69 |
+
public static function hide_password_fields ($show = TRUE, $user = FALSE)
|
70 |
+
{
|
71 |
+
global $current_user; /* Need the $current_user global var. */
|
72 |
+
/**/
|
73 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
74 |
+
do_action ("ws_plugin__s2member_before_hide_password_fields", get_defined_vars ());
|
75 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
76 |
+
/**/
|
77 |
+
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_super_admin () && is_object ($user) && is_object ($current_user) && $user->ID !== $current_user->ID)
|
78 |
+
$show = false;
|
79 |
+
/**/
|
80 |
+
else if (is_object ($user) && $user->user_login === "demo") /* Lock Password on Demo accounts. */
|
81 |
+
$show = false;
|
82 |
+
/**/
|
83 |
+
return apply_filters ("ws_plugin__s2member_hide_password_fields", $show, get_defined_vars ());
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
?>
|
includes/classes/users-list-in.inc.php
ADDED
@@ -0,0 +1,469 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_users_list_in"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_users_list_in
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function adds Custom Fields to the admin profile editing page.
|
23 |
+
|
24 |
+
Attach to: add_action("edit_user_profile");
|
25 |
+
Attach to: add_action("show_user_profile");
|
26 |
+
w/ the Contant available:
|
27 |
+
IS_PROFILE_PAGE
|
28 |
+
|
29 |
+
Conditionals here need to match those in the function below:
|
30 |
+
c_ws_plugin__s2member_users_list::users_list_update_cols()
|
31 |
+
*/
|
32 |
+
public static function users_list_edit_cols ($user = FALSE)
|
33 |
+
{
|
34 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
35 |
+
/**/
|
36 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
37 |
+
do_action ("ws_plugin__s2member_before_users_list_edit_cols", get_defined_vars ());
|
38 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
39 |
+
/**/
|
40 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
41 |
+
/**/
|
42 |
+
if ($user && $user->ID && $current_user && $current_user->ID) /* Validate both of these User objects beforehand. */
|
43 |
+
{
|
44 |
+
$level = c_ws_plugin__s2member_user_access::user_access_level ($user); /* This User's Access Level for s2Member; needed below. */
|
45 |
+
/**/
|
46 |
+
if (current_user_can ("edit_users") && (!is_multisite () || is_super_admin () || is_user_member_of_blog ($user->ID)))
|
47 |
+
{
|
48 |
+
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
49 |
+
/**/
|
50 |
+
echo '<h3 style="position:relative;"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/large-icon.png" title="s2Member ( a Membership management system for WordPress® )" alt="" style="position:absolute; top:-15px; right:0; border:0;" />s2Member Configuration & Profile Fields' . ( (is_multisite ()) ? ' ( for this Blog )' : '') . '</h3>' . "\n";
|
51 |
+
/**/
|
52 |
+
echo '<table class="form-table">' . "\n";
|
53 |
+
/**/
|
54 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
55 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before", get_defined_vars ());
|
56 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
57 |
+
/**/
|
58 |
+
if (is_multisite () && is_super_admin ()) /* MUST be a Super Admin. */
|
59 |
+
/* On a Multisite Network, the Super Administrator can ALWAYS edit this. */
|
60 |
+
{
|
61 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
62 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_originating_blog", get_defined_vars ());
|
63 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
64 |
+
/**/
|
65 |
+
echo '<tr>' . "\n";
|
66 |
+
echo '<th><label>Originating Blog ID#:</label> <a href="#" onclick="alert(\'On a Multisite Network, this is how s2Member keeps track of which Blog each User/Member originated from. So this ID#, is automatically associated with a Blog in your Network, matching the User\\\'s point of origin. ~ ONLY a Super Admin can modify this.\\n\\nOn a Multisite Blog Farm, the Originating Blog ID# for your own Customers, will ALWAYS be associated with your ( Main Site ). It is NOT likely that you\\\'ll need to modify this manually, but s2Member makes it available; just in case.\\n\\n*Tip* - If you add Users ( and/or Blogs ) with the `Super Admin` Network Administration panel inside WordPress®, then you WILL need to set everything manually. s2Member does NOT tamper with automation routines whenever YOU ( as a Super Administrator ) are working in that area.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
67 |
+
echo '<td><input type="text" name="ws_plugin__s2member_profile_s2member_originating_blog" id="ws-plugin--s2member-profile-s2member-originating-blog" value="' . format_to_edit (get_user_meta ($user->ID, "s2member_originating_blog", true)) . '" class="regular-text" /></td>' . "\n";
|
68 |
+
echo '</tr>' . "\n";
|
69 |
+
/**/
|
70 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
71 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_originating_blog", get_defined_vars ());
|
72 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
73 |
+
}
|
74 |
+
/**/
|
75 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
76 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_subscr_gateway", get_defined_vars ());
|
77 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
78 |
+
/**/
|
79 |
+
echo '<tr>' . "\n";
|
80 |
+
echo '<th><label>Paid Subscr. Gateway:</label> <a href="#" onclick="alert(\'A Payment Gateway code is associated with the Paid Subscr. ID below. A Paid Subscription ID ( or a Buy Now Transaction ID ) is only valid for paid Members. Also known as ( a Recurring Profile ID, a ClickBank® Receipt #, a Google® TID/SID ( with an s2 prefix ), an AliPay® Trade No. ). This will be filled automatically by s2Member.\\n\\nThis field will be empty for Free Subscribers, and/or anyone who is NOT paying you. This field is only editable for Customer Service purposes; just in case you ever need to update the Paid Subscr. Gateway/ID manually.\\n\\nThe value of Paid® Subscr. ID, can be a PayPal® Standard `Subscription ID`, or a PayPal® Pro `Recurring Profile ID`, or a PayPal® `Transaction ID`; depending on the type of sale. Your PayPal® account will supply this information. If you\\\'re using Google® Checkout, use the TID/SID value in the sale Description; it always starts with `s2-`. ClickBank® provides a Receipt #, ccBill® provides a Subscription ID, Authorize.Net® provides a Subscription ID, and AliPay® provides a Transaction ID. The general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
81 |
+
echo '<td><select name="ws_plugin__s2member_profile_s2member_subscr_gateway" id="ws-plugin--s2member-profile-s2member-subscr-gateway" style="width:27.5em;"><option value=""></option>' . "\n";
|
82 |
+
foreach (apply_filters ("ws_plugin__s2member_profile_s2member_subscr_gateways", array ("paypal" => "PayPal® ( code: paypal )"), get_defined_vars ()) as $gateway => $gateway_name)
|
83 |
+
echo '<option value="' . esc_attr ($gateway) . '"' . ( ($gateway === get_user_option ("s2member_subscr_gateway", $user->ID)) ? ' selected="selected"' : '') . '>' . esc_html ($gateway_name) . '</option>' . "\n";
|
84 |
+
echo '</select>' . "\n";
|
85 |
+
echo '</td>' . "\n";
|
86 |
+
echo '</tr>' . "\n";
|
87 |
+
/**/
|
88 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
89 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_subscr_gateway", get_defined_vars ());
|
90 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
91 |
+
/**/
|
92 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
93 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_subscr_id", get_defined_vars ());
|
94 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
95 |
+
/**/
|
96 |
+
echo '<tr>' . "\n";
|
97 |
+
echo '<th><label>Paid Subscr. ID:</label> <a href="#" onclick="alert(\'A Paid Subscription ID ( or a Buy Now Transaction ID ) is only valid for paid Members. Also known as ( a Recurring Profile ID, a ClickBank® Receipt #, a Google® TID/SID ( with an s2 prefix ), an AliPay® Trade No. ). This will be filled automatically by s2Member.\\n\\nThis field will be empty for Free Subscribers, and/or anyone who is NOT paying you. This field is only editable for Customer Service purposes; just in case you ever need to update the Paid Subscr. Gateway/ID manually.\\n\\nThe value of Paid® Subscr. ID, can be a PayPal® Standard `Subscription ID`, or a PayPal® Pro `Recurring Profile ID`, or a PayPal® `Transaction ID`; depending on the type of sale. Your PayPal® account will supply this information. If you\\\'re using Google® Checkout, use the TID/SID value in the sale Description; it always starts with `s2-`. ClickBank® provides a Receipt #, ccBill® provides a Subscription ID, Authorize.Net® provides a Subscription ID, and AliPay® provides a Transaction ID. The general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
98 |
+
echo '<td><input type="text" name="ws_plugin__s2member_profile_s2member_subscr_id" id="ws-plugin--s2member-profile-s2member-subscr-id" value="' . format_to_edit (get_user_option ("s2member_subscr_id", $user->ID)) . '" class="regular-text" /></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_users_list_edit_cols_after_subscr_id", get_defined_vars ());
|
103 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
104 |
+
/**/
|
105 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
106 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_custom", get_defined_vars ());
|
107 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
108 |
+
/**/
|
109 |
+
echo '<tr>' . "\n";
|
110 |
+
echo '<th><label>Custom Value:</label> <a href="#" onclick="alert(\'A Paid Subscription is always associated with a Custom String that is passed through the custom=\\\'\\\'' . c_ws_plugin__s2member_utils_strings::esc_sq (esc_attr ($_SERVER["HTTP_HOST"])) . '\\\'\\\' attribute of your Shortcode. This Custom Value, MUST always start with your domain name. However, you can also pipe delimit additional values after your domain, if you need to.\\n\\nFor example:\n' . c_ws_plugin__s2member_utils_strings::esc_sq (esc_attr ($_SERVER["HTTP_HOST"])) . '|cv1|cv2|cv3\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
111 |
+
echo '<td><input type="text" name="ws_plugin__s2member_profile_s2member_custom" id="ws-plugin--s2member-profile-s2member-custom" value="' . format_to_edit (get_user_option ("s2member_custom", $user->ID)) . '" class="regular-text" /></td>' . "\n";
|
112 |
+
echo '</tr>' . "\n";
|
113 |
+
/**/
|
114 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
115 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_custom", get_defined_vars ());
|
116 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
117 |
+
/**/
|
118 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
|
119 |
+
/* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
|
120 |
+
{
|
121 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
122 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
123 |
+
$ccaps[] = preg_replace ("/^access_s2member_ccap_/", "", $cap);
|
124 |
+
/**/
|
125 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
126 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_ccaps", get_defined_vars ());
|
127 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
128 |
+
/**/
|
129 |
+
echo '<tr>' . "\n";
|
130 |
+
echo '<th><label>Custom Capabilities:</label> <a href="#" onclick="alert(\'Optional. This is VERY advanced. For full details, see:\\ns2Member -> API Scripting -> Custom Capabilities.' . ( (is_multisite ()) ? '\\n\\nCustom Capabilities are assigned on a per-Blog basis. So having a set of Custom Capabilities for one Blog, and having NO Custom Capabilities on another Blog - is very common. This is how permissions are designed to work.' : '') . '\'); return false;" tabindex="-1">[?]</a>' . ( (is_multisite ()) ? '<br /><small>( for this Blog )</small>' : '') . '</th>' . "\n";
|
131 |
+
echo '<td><input type="text" name="ws_plugin__s2member_profile_s2member_ccaps" id="ws-plugin--s2member-profile-s2member-ccaps" value="' . format_to_edit (( (!empty ($ccaps)) ? implode (",", $ccaps) : "")) . '" class="regular-text" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" /></td>' . "\n";
|
132 |
+
echo '</tr>' . "\n";
|
133 |
+
/**/
|
134 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
135 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_ccaps", get_defined_vars ());
|
136 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
137 |
+
}
|
138 |
+
/**/
|
139 |
+
if (!$user->has_cap ("administrator")) /* Do NOT present these details for Administrator accounts. */
|
140 |
+
{
|
141 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
142 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_auto_eot_time", get_defined_vars ());
|
143 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
144 |
+
/**/
|
145 |
+
echo '<tr>' . "\n";
|
146 |
+
$auto_eot_time = get_user_option ("s2member_auto_eot_time", $user->ID);
|
147 |
+
$auto_eot_time = ($auto_eot_time) ? date ("D M j, Y g:i a T", $auto_eot_time) : "";
|
148 |
+
echo '<th><label>Automatic EOT Time:</label> <a href="#" onclick="alert(\'EOT = End Of Term. ( i.e. Account Expiration / Termination. ).\\n\\nIf you leave this empty, s2Member will configure an EOT Time automatically, based on the paid Subscription associated with this account. In other words, if a paid Subscription expires, is cancelled, terminated, refunded, reversed, or charged back to you; s2Member will deal with the EOT automatically.\\n\\nThat being said, if you would rather take control over this, you can. If you type in a date manually, s2Member will obey the Auto-EOT Time that you\\\'ve given, no matter what. In other words, you can force certain Members to expire automatically, at a time that you specify. s2Member will obey.\\n\\nValid formats for Automatic EOT Time:\\n\\nmm/dd/yyyy\\nyyyy-mm-dd\\n+1 year\\n+2 weeks\\n+2 months\\n+10 minutes\\nnext thursday\\ntomorrow\\ntoday\\n\\n* anything compatible with PHP\\\'s strtotime() function.\'); return false;" tabindex="-1">[?]</a>' . (($auto_eot_time) ? '<br /><small>( based on server time )</small>' : '') . '</th>' . "\n";
|
149 |
+
echo '<td><input type="text" name="ws_plugin__s2member_profile_s2member_auto_eot_time" id="ws-plugin--s2member-profile-s2member-auto-eot-time" value="' . format_to_edit ($auto_eot_time) . '" class="regular-text" /></td>' . "\n";
|
150 |
+
echo '</tr>' . "\n";
|
151 |
+
/**/
|
152 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
153 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_auto_eot_time", get_defined_vars ());
|
154 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
155 |
+
}
|
156 |
+
/**/
|
157 |
+
if (c_ws_plugin__s2member_list_servers::list_servers_integrated ()) /* Only if integrated with s2Member. */
|
158 |
+
{
|
159 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
160 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_opt_in", get_defined_vars ());
|
161 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
162 |
+
/**/
|
163 |
+
echo '<tr>' . "\n";
|
164 |
+
echo '<th><label>Process List Servers:</label> <a href="#" onclick="alert(\'You have at least one List Server integrated with s2Member. Would you like to process a confirmation request for this User? If not, just leave the box un-checked.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
165 |
+
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_profile_opt_in" id="ws-plugin--s2member-profile-opt-in" value="1" /> Yes, send a mailing list confirmation email to this User.</label></td>' . "\n";
|
166 |
+
echo '</tr>' . "\n";
|
167 |
+
/**/
|
168 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
169 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_opt_in", get_defined_vars ());
|
170 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
171 |
+
}
|
172 |
+
/**/
|
173 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
174 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_ip_restrictions", get_defined_vars ());
|
175 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
176 |
+
/**/
|
177 |
+
echo '<tr>' . "\n";
|
178 |
+
echo '<th><label>Reset IP Restrictions:</label> <a href="#" onclick="alert(\'A single Username is only valid for a certain number of unique IP addresses ( as configured in your s2Member -> General Options ). Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban ( preventing access ).\\n\\nIf you have spoken to a legitimate Customer that is receiving an error upon logging in ( ex: 503 / too many IP addresses ), you can remove this temporary ban by checking the box below. If the abusive behavior continues, s2Member will automatically re-instate IP Restrictions in the future. If you would like to gain further control over IP Restrictions, please check your General Options panel for s2Member.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
179 |
+
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_profile_ip_restrictions" id="ws-plugin--s2member-profile-ip-restrictions" value="1" /> Yes, delete/reset IP Restrictions associated with this Username.</label>' . ( (c_ws_plugin__s2member_ip_restrictions::specific_ip_restriction_breached_security (strtolower ($user->user_login))) ? '<br /><em>*Note* this User HAS breached security through existing IP Restrictions.</em>' : '<br /><em>*Note* this User is NOT currently banned by any of your IP Restrictions.</em>') . '</td>' . "\n";
|
180 |
+
echo '</tr>' . "\n";
|
181 |
+
/**/
|
182 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
183 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_ip_restrictions", get_defined_vars ());
|
184 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
185 |
+
/**/
|
186 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) /* Only if configured. */
|
187 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level))
|
188 |
+
{
|
189 |
+
echo '<tr>' . "\n";
|
190 |
+
echo '<td colspan="2">' . "\n";
|
191 |
+
echo '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
192 |
+
echo '</td>' . "\n";
|
193 |
+
echo '</tr>' . "\n";
|
194 |
+
/**/
|
195 |
+
$fields = get_user_option ("s2member_custom_fields", $user->ID); /* Existing fields. */
|
196 |
+
/**/
|
197 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
198 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_custom_fields", get_defined_vars ());
|
199 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
200 |
+
/**/
|
201 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
202 |
+
{
|
203 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
204 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_before", get_defined_vars ());
|
205 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
206 |
+
/**/
|
207 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
208 |
+
{
|
209 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
210 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
211 |
+
/**/
|
212 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
213 |
+
if (apply_filters ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_display", true, get_defined_vars ()))
|
214 |
+
{
|
215 |
+
echo '<tr>' . "\n";
|
216 |
+
echo '<th><label>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ucwords (preg_replace ("/_/", " ", $field_var)) : $field["label"]) . ':</label></th>' . "\n";
|
217 |
+
echo '<td>' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ( (preg_match ("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $fields, $fields[$field_var]) . '</td>' . "\n";
|
218 |
+
echo '</tr>' . "\n";
|
219 |
+
}
|
220 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
221 |
+
}
|
222 |
+
/**/
|
223 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
224 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_after", get_defined_vars ());
|
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_users_list_edit_cols_after_custom_fields", get_defined_vars ());
|
230 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
231 |
+
/**/
|
232 |
+
echo '<tr>' . "\n";
|
233 |
+
echo '<td colspan="2">' . "\n";
|
234 |
+
echo '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
235 |
+
echo '</td>' . "\n";
|
236 |
+
echo '</tr>' . "\n";
|
237 |
+
}
|
238 |
+
/**/
|
239 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
240 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_notes", get_defined_vars ());
|
241 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
242 |
+
/**/
|
243 |
+
echo '<tr>' . "\n";
|
244 |
+
echo '<th><label>Administrative<br />Notations:</label> <a href="#" onclick="alert(\'This is for Administrative purposes. You can keep a list of Notations about this account. These Notations are private; Users/Members will never see these.\\n\\n*Note* The s2Member software may `append` Notes to this field occassionaly, under special circumstances. For example, when/if s2Member demotes a paid Member to a Free Subscriber, s2Member will leave a Note in this field.\'); return false;" tabindex="-1">[?]</a></th>' . "\n";
|
245 |
+
echo '<td><textarea name="ws_plugin__s2member_profile_s2member_notes" id="ws-plugin--s2member-profile-s2member-notes" rows="5" wrap="off" spellcheck="false" style="width:99%;">' . format_to_edit (get_user_option ("s2member_notes", $user->ID)) . '</textarea></td>' . "\n";
|
246 |
+
echo '</tr>' . "\n";
|
247 |
+
/**/
|
248 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
249 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_notes", get_defined_vars ());
|
250 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
251 |
+
/**/
|
252 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
253 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after", get_defined_vars ());
|
254 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
255 |
+
/**/
|
256 |
+
echo '</table>' . "\n";
|
257 |
+
/**/
|
258 |
+
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
259 |
+
}
|
260 |
+
/**/
|
261 |
+
else if ($current_user->ID === $user->ID) /* Otherwise, a User can always edit their own Profile. */
|
262 |
+
{
|
263 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) /* Only if configured. */
|
264 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level))
|
265 |
+
{
|
266 |
+
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
267 |
+
/**/
|
268 |
+
echo '<h3>Additional Profile Fields' . ( (is_multisite ()) ? ' ( for this Blog )' : '') . '</h3>' . "\n";
|
269 |
+
/**/
|
270 |
+
echo '<table class="form-table">' . "\n";
|
271 |
+
/**/
|
272 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
273 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before", get_defined_vars ());
|
274 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
275 |
+
/**/
|
276 |
+
$fields = get_user_option ("s2member_custom_fields", $user->ID); /* Existing fields. */
|
277 |
+
/**/
|
278 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
279 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_before_custom_fields", get_defined_vars ());
|
280 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
281 |
+
/**/
|
282 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
283 |
+
{
|
284 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
285 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_before", get_defined_vars ());
|
286 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
287 |
+
/**/
|
288 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
289 |
+
{
|
290 |
+
if ($field["editable"] !== "no-invisible") /* Uneditable/invisible? */
|
291 |
+
{
|
292 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
293 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
294 |
+
/**/
|
295 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
296 |
+
if (apply_filters ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_display", true, get_defined_vars ()))
|
297 |
+
{
|
298 |
+
echo '<tr>' . "\n";
|
299 |
+
echo '<th><label>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ucwords (preg_replace ("/_/", " ", $field_var)) : $field["label"]) . ':</label></th>' . "\n";
|
300 |
+
echo '<td>' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ( (preg_match ("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $fields, $fields[$field_var], true) . '</td>' . "\n";
|
301 |
+
echo '</tr>' . "\n";
|
302 |
+
}
|
303 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
304 |
+
}
|
305 |
+
}
|
306 |
+
/**/
|
307 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
308 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_after", get_defined_vars ());
|
309 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
310 |
+
}
|
311 |
+
/**/
|
312 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
313 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after_custom_fields", get_defined_vars ());
|
314 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
315 |
+
/**/
|
316 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
317 |
+
do_action ("ws_plugin__s2member_during_users_list_edit_cols_after", get_defined_vars ());
|
318 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
319 |
+
/**/
|
320 |
+
echo '</table>' . "\n";
|
321 |
+
/**/
|
322 |
+
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
/**/
|
327 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
328 |
+
do_action ("ws_plugin__s2member_after_users_list_edit_cols", get_defined_vars ());
|
329 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
330 |
+
/**/
|
331 |
+
return; /* Return for uniformity. */
|
332 |
+
}
|
333 |
+
/*
|
334 |
+
Function that saves custom fields after an admin updates profile.
|
335 |
+
|
336 |
+
Attach to: add_action("edit_user_profile_update");
|
337 |
+
Attach to: add_action("personal_options_update");
|
338 |
+
w/ the Contant available:
|
339 |
+
IS_PROFILE_PAGE
|
340 |
+
|
341 |
+
Conditionals here need to match those in the function above:
|
342 |
+
c_ws_plugin__s2member_users_list::users_list_edit_cols()
|
343 |
+
*/
|
344 |
+
public static function users_list_update_cols ($user_id = FALSE)
|
345 |
+
{
|
346 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
347 |
+
/**/
|
348 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
349 |
+
do_action ("ws_plugin__s2member_before_users_list_update_cols", get_defined_vars ());
|
350 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
351 |
+
/**/
|
352 |
+
$user = new WP_User ($user_id); /* We need both. The $user and $current_user. */
|
353 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
354 |
+
/**/
|
355 |
+
if ($user && $user->ID && $current_user && $current_user->ID) /* Validate both of these User objects before we even begin. */
|
356 |
+
{
|
357 |
+
$level = c_ws_plugin__s2member_user_access::user_access_level ($user); /* This User's Access Level for s2Member. */
|
358 |
+
/**/
|
359 |
+
if (current_user_can ("edit_users") && (!is_multisite () || is_super_admin () || is_user_member_of_blog ($user->ID)))
|
360 |
+
{
|
361 |
+
if (is_array ($_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))) && !empty ($_p))
|
362 |
+
{
|
363 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_originating_blog"]) && is_multisite () && is_super_admin ())
|
364 |
+
update_user_meta ($user_id, "s2member_originating_blog", $_p["ws_plugin__s2member_profile_s2member_originating_blog"]);
|
365 |
+
/**/
|
366 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_custom"]))
|
367 |
+
update_user_option ($user_id, "s2member_custom", $_p["ws_plugin__s2member_profile_s2member_custom"]);
|
368 |
+
/**/
|
369 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_subscr_gateway"]))
|
370 |
+
update_user_option ($user_id, "s2member_subscr_gateway", $_p["ws_plugin__s2member_profile_s2member_subscr_gateway"]);
|
371 |
+
/**/
|
372 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_subscr_id"]))
|
373 |
+
update_user_option ($user_id, "s2member_subscr_id", $_p["ws_plugin__s2member_profile_s2member_subscr_id"]);
|
374 |
+
/**/
|
375 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_notes"]))
|
376 |
+
update_user_option ($user_id, "s2member_notes", $_p["ws_plugin__s2member_profile_s2member_notes"]);
|
377 |
+
/**/
|
378 |
+
$auto_eot_time = ($eot = $_p["ws_plugin__s2member_profile_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
379 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_auto_eot_time"])) /* Then check if set. */
|
380 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
381 |
+
/**/
|
382 |
+
if (isset ($_p["ws_plugin__s2member_profile_s2member_ccaps"]))
|
383 |
+
{
|
384 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
385 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
386 |
+
$user->remove_cap ($ccap = $cap);
|
387 |
+
/**/
|
388 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $_p["ws_plugin__s2member_profile_s2member_ccaps"]) as $ccap)
|
389 |
+
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
390 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
391 |
+
}
|
392 |
+
/**/
|
393 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
394 |
+
{
|
395 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
396 |
+
{
|
397 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
398 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
399 |
+
/**/
|
400 |
+
$fields[$field_var] = $_p["ws_plugin__s2member_profile_" . $field_var];
|
401 |
+
}
|
402 |
+
}
|
403 |
+
/**/
|
404 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
405 |
+
/**/
|
406 |
+
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
407 |
+
{
|
408 |
+
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
409 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
410 |
+
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
411 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
412 |
+
}
|
413 |
+
/**/
|
414 |
+
if ($_p["ws_plugin__s2member_profile_opt_in"]) /* Should we process List Servers for this User? */
|
415 |
+
c_ws_plugin__s2member_list_servers::process_list_servers (c_ws_plugin__s2member_user_access::user_access_role ($user), c_ws_plugin__s2member_user_access::user_access_level ($user), $user->user_email, $user->first_name, $user->last_name, "", true, $user_id);
|
416 |
+
/**/
|
417 |
+
if ($_p["ws_plugin__s2member_profile_ip_restrictions"]) /* Delete/reset IP Restrictions? */
|
418 |
+
c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions (strtolower ($user->user_login));
|
419 |
+
/**/
|
420 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
421 |
+
do_action ("ws_plugin__s2member_during_users_list_update_cols", get_defined_vars ());
|
422 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
423 |
+
}
|
424 |
+
}
|
425 |
+
/**/
|
426 |
+
else if ($current_user->ID === $user->ID) /* Otherwise, a User can always edit their own Profile. */
|
427 |
+
{
|
428 |
+
if (is_array ($_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))) && !empty ($_p))
|
429 |
+
{
|
430 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
431 |
+
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level))
|
432 |
+
{
|
433 |
+
$_existing_fields = get_user_option ("s2member_custom_fields", $user_id);
|
434 |
+
/**/
|
435 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
436 |
+
{
|
437 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
438 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
439 |
+
/**/
|
440 |
+
if (!in_array ($field["id"], $fields_applicable) || preg_match ("/^no/", $field["editable"]))
|
441 |
+
$fields[$field_var] = $_existing_fields[$field_var];
|
442 |
+
/**/
|
443 |
+
else if ($field["required"] === "yes" && empty ($_p["ws_plugin__s2member_profile_" . $field_var])/**/
|
444 |
+
&& $_p["ws_plugin__s2member_profile_" . $field_var] !== "0") /* Allow zeros. */
|
445 |
+
$fields[$field_var] = $_existing_fields[$field_var];
|
446 |
+
/**/
|
447 |
+
else /* Otherwise, we can use the newly updated value. */
|
448 |
+
$fields[$field_var] = $_p["ws_plugin__s2member_profile_" . $field_var];
|
449 |
+
}
|
450 |
+
/**/
|
451 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
452 |
+
}
|
453 |
+
/**/
|
454 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
455 |
+
do_action ("ws_plugin__s2member_during_users_list_update_cols", get_defined_vars ());
|
456 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
/**/
|
461 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
462 |
+
do_action ("ws_plugin__s2member_after_users_list_update_cols", get_defined_vars ());
|
463 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
464 |
+
/**/
|
465 |
+
return; /* Return for uniformity. */
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
?>
|
includes/classes/users-list.inc.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_users_list"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_users_list
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function adds Custom Fields to the admin profile editing page.
|
23 |
+
|
24 |
+
Attach to: add_action("edit_user_profile");
|
25 |
+
Attach to: add_action("show_user_profile");
|
26 |
+
w/ the Contant available:
|
27 |
+
IS_PROFILE_PAGE
|
28 |
+
|
29 |
+
Conditionals here need to match those in the function below:
|
30 |
+
c_ws_plugin__s2member_users_list::users_list_update_cols()
|
31 |
+
*/
|
32 |
+
public static function users_list_edit_cols ($user = FALSE)
|
33 |
+
{
|
34 |
+
return c_ws_plugin__s2member_users_list_in::users_list_edit_cols ($user);
|
35 |
+
}
|
36 |
+
/*
|
37 |
+
Function that saves custom fields after an admin updates profile.
|
38 |
+
|
39 |
+
Attach to: add_action("edit_user_profile_update");
|
40 |
+
Attach to: add_action("personal_options_update");
|
41 |
+
w/ the Contant available:
|
42 |
+
IS_PROFILE_PAGE
|
43 |
+
|
44 |
+
Conditionals here need to match those in the function above:
|
45 |
+
c_ws_plugin__s2member_users_list::users_list_edit_cols()
|
46 |
+
*/
|
47 |
+
public static function users_list_update_cols ($user_id = FALSE)
|
48 |
+
{
|
49 |
+
return c_ws_plugin__s2member_users_list_in::users_list_update_cols ($user_id);
|
50 |
+
}
|
51 |
+
/*
|
52 |
+
Function that modifies the search query.
|
53 |
+
Affects searches performed in the list of Users.
|
54 |
+
Attach to: add_action("pre_user_query");
|
55 |
+
*/
|
56 |
+
public static function users_list_query (&$query = FALSE)
|
57 |
+
{
|
58 |
+
global $wpdb; /* Need this global object reference. */
|
59 |
+
/**/
|
60 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
61 |
+
do_action ("ws_plugin__s2member_before_users_list_search", get_defined_vars ());
|
62 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
63 |
+
/**/
|
64 |
+
if (isset ($query->query_vars) && !c_ws_plugin__s2member_utils_conds::is_network_admin ()) /* NOT in Network admin panels. */
|
65 |
+
if (is_array ($qv = $query->query_vars) && ($s = trim ($qv["search"], "* \t\n\r\0\x0B")) && ($s = "%" . esc_sql (like_escape ($s)) . "%"))
|
66 |
+
{
|
67 |
+
$query->query_from = " FROM `" . $wpdb->users . "` INNER JOIN `" . $wpdb->usermeta . "` ON `" . $wpdb->users . "`.`ID` = `" . $wpdb->usermeta . "`.`user_id`";
|
68 |
+
/**/
|
69 |
+
$query->query_where = " WHERE '1' = '1' AND (" . apply_filters ("ws_plugin__s2member_before_users_list_search_where_or_before", "", get_defined_vars ());
|
70 |
+
$query->query_where .= " (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
71 |
+
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_custom' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
72 |
+
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_custom_fields' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
73 |
+
$query->query_where .= " OR `user_login` LIKE '" . $s . "' OR `user_nicename` LIKE '" . $s . "' OR `user_email` LIKE '" . $s . "' OR `user_url` LIKE '" . $s . "' OR `display_name` LIKE '" . $s . "'";
|
74 |
+
$query->query_where .= apply_filters ("ws_plugin__s2member_before_users_list_search_where_or_after", "", get_defined_vars ()) . ")"; /* Leaving room for additional searches here. */
|
75 |
+
$query->query_where .= " AND `" . $wpdb->users . "`.`ID` IN(SELECT DISTINCT(`user_id`) FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "capabilities'" ./**/
|
76 |
+
( ($qv["role"]) ? " AND `meta_value` LIKE '%" . esc_sql (like_escape ($qv["role"])) . "%'" : "") . ")";
|
77 |
+
/**/
|
78 |
+
$query->query_from = apply_filters ("ws_plugin__s2member_before_users_list_search_from", $query->query_from, get_defined_vars ());
|
79 |
+
$query->query_where = apply_filters ("ws_plugin__s2member_before_users_list_search_where", $query->query_where, get_defined_vars ());
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
83 |
+
do_action ("ws_plugin__s2member_after_users_list_search", get_defined_vars ());
|
84 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
85 |
+
/**/
|
86 |
+
return; /* Return for uniformity. */
|
87 |
+
}
|
88 |
+
/*
|
89 |
+
Function that modifies the search query.
|
90 |
+
Affects searches performed in the list of Users.
|
91 |
+
Attach to: add_action("pre_user_search");
|
92 |
+
|
93 |
+
This is left here ( for now ); providing backward compatibility.
|
94 |
+
WordPress® 3.1-RC uses `pre_user_query` ( as implemented above ).
|
95 |
+
This Hook will be removed in a future release of s2Member.
|
96 |
+
*/
|
97 |
+
public static function users_list_search (&$search = FALSE)
|
98 |
+
{
|
99 |
+
global $wpdb; /* Need this global object reference. */
|
100 |
+
/**/
|
101 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
102 |
+
do_action ("ws_plugin__s2member_before_users_list_search", get_defined_vars ());
|
103 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
104 |
+
/**/
|
105 |
+
if ($search->search_term && ($s = "%" . esc_sql (like_escape ($search->search_term)) . "%")) /* Only when executing an actual search query. */
|
106 |
+
{
|
107 |
+
$search->query_from = " FROM `" . $wpdb->users . "` INNER JOIN `" . $wpdb->usermeta . "` ON `" . $wpdb->users . "`.`ID` = `" . $wpdb->usermeta . "`.`user_id`";
|
108 |
+
/**/
|
109 |
+
$search->query_where = " WHERE '1' = '1' AND (" . apply_filters ("ws_plugin__s2member_before_users_list_search_where_or_before", "", get_defined_vars ());
|
110 |
+
$search->query_where .= " (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
111 |
+
$search->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_custom' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
112 |
+
$search->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->prefix . "s2member_custom_fields' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
|
113 |
+
$search->query_where .= " OR `user_login` LIKE '" . $s . "' OR `user_nicename` LIKE '" . $s . "' OR `user_email` LIKE '" . $s . "' OR `user_url` LIKE '" . $s . "' OR `display_name` LIKE '" . $s . "'";
|
114 |
+
$search->query_where .= apply_filters ("ws_plugin__s2member_before_users_list_search_where_or_after", "", get_defined_vars ()) . ")"; /* Leaving room for additional searches here. */
|
115 |
+
$search->query_where .= " AND `" . $wpdb->users . "`.`ID` IN(SELECT DISTINCT(`user_id`) FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "capabilities'" ./**/
|
116 |
+
(($search->role) ? " AND `meta_value` LIKE '%" . esc_sql (like_escape ($search->role)) . "%'" : "") . ")";
|
117 |
+
/**/
|
118 |
+
$search->query_from = apply_filters ("ws_plugin__s2member_before_users_list_search_from", $search->query_from, get_defined_vars ());
|
119 |
+
$search->query_where = apply_filters ("ws_plugin__s2member_before_users_list_search_where", $search->query_where, get_defined_vars ());
|
120 |
+
}
|
121 |
+
/**/
|
122 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
123 |
+
do_action ("ws_plugin__s2member_after_users_list_search", get_defined_vars ());
|
124 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
125 |
+
/**/
|
126 |
+
return; /* Return for uniformity. */
|
127 |
+
}
|
128 |
+
/*
|
129 |
+
Function that adds columns to the list of Users.
|
130 |
+
Attach to: add_filter ("manage_users_columns");
|
131 |
+
*/
|
132 |
+
public static function users_list_cols ($cols = FALSE)
|
133 |
+
{
|
134 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
135 |
+
do_action ("ws_plugin__s2member_before_users_list_cols", get_defined_vars ());
|
136 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
137 |
+
/**/
|
138 |
+
$cols["s2member_registration_time"] = "Registration Date"; /* Date they signed up. */
|
139 |
+
$cols["s2member_paid_registration_times"] = "Paid Registr. Date"; /* Payment Times. */
|
140 |
+
$cols["s2member_subscr_id"] = "Paid Subscr. ID"; /* Special field that is always applied. */
|
141 |
+
/**/
|
142 |
+
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
|
143 |
+
/* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
|
144 |
+
$cols["s2member_ccaps"] = "Custom Capabilities"; /* Custom Capabilities. */
|
145 |
+
/**/
|
146 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
147 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
148 |
+
{
|
149 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
150 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
151 |
+
/**/
|
152 |
+
$field_title = ucwords (preg_replace ("/_/", " ", $field_var));
|
153 |
+
$cols["s2member_custom_field_" . $field_var] = $field_title;
|
154 |
+
}
|
155 |
+
/**/
|
156 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
157 |
+
do_action ("ws_plugin__s2member_during_users_list_cols", get_defined_vars ());
|
158 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
159 |
+
/**/
|
160 |
+
return apply_filters ("ws_plugin__s2member_users_list_cols", $cols, get_defined_vars ());
|
161 |
+
}
|
162 |
+
/*
|
163 |
+
Function that displays column data in the row of details.
|
164 |
+
Attach to: add_filter ("manage_users_custom_column");
|
165 |
+
*/
|
166 |
+
public static function users_list_display_cols ($val = FALSE, $col = FALSE, $user_id = FALSE)
|
167 |
+
{
|
168 |
+
static $user, $last_user_id; /* Used internally for optimization. */
|
169 |
+
static $fields, $last_fields_id; /* Used for optimization. */
|
170 |
+
/**/
|
171 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
172 |
+
do_action ("ws_plugin__s2member_before_users_list_display_cols", get_defined_vars ());
|
173 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
174 |
+
/**/
|
175 |
+
$user = (is_object ($user) && $user_id === $last_user_id) ? $user : new WP_User ($user_id);
|
176 |
+
/**/
|
177 |
+
if ($col === "s2member_registration_time")
|
178 |
+
$val = ($v = $user->user_registered) ? esc_html (date ("D M jS, Y", strtotime ($v))) . '<br /><small>@ precisely ' . esc_html (date ("g:i a", strtotime ($v))) . '</small>' : "—";
|
179 |
+
/**/
|
180 |
+
else if ($col === "s2member_paid_registration_times")
|
181 |
+
{
|
182 |
+
$val = ""; /* Initialize $val before we begin. */
|
183 |
+
if (is_array ($v = get_user_option ("s2member_paid_registration_times", $user_id)))
|
184 |
+
foreach ($v as $level => $time) /* Go through each Paid Registration Time. */
|
185 |
+
{
|
186 |
+
if ($level === "level") /* First Payment Time, regardless of Level. */
|
187 |
+
$val .= (($val) ? "<br />" : "") . '<span title="' . esc_attr (date ("D M jS, Y", $time)) . ' @ precisely ' . esc_attr (date ("g:i a", $time)) . '">' . esc_html (date ("D M jS, Y", $time)) . '</span>';
|
188 |
+
else if (preg_match ("/^level([0-9]+)$/i", $level) && ($level = preg_replace ("/^level/", "", $level)))
|
189 |
+
$val .= (($val) ? "<br />" : "") . '<small><em>@Level ' . esc_html ($level) . ': <span title="' . esc_attr (date ("D M jS, Y", $time)) . ' @ precisely ' . esc_attr (date ("g:i a", $time)) . '">' . esc_html (date ("D M jS, Y", $time)) . '</span></em></small>';
|
190 |
+
}
|
191 |
+
}
|
192 |
+
/**/
|
193 |
+
else if ($col === "s2member_subscr_id")
|
194 |
+
$val = ($v = get_user_option ("s2member_subscr_id", $user_id)) ? esc_html ($v) : "—";
|
195 |
+
/**/
|
196 |
+
else if ($col === "s2member_ccaps") /* Custom Capabilities. */
|
197 |
+
{
|
198 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
199 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
200 |
+
$ccaps[] = preg_replace ("/^access_s2member_ccap_/", "", $cap);
|
201 |
+
/**/
|
202 |
+
$val = (!empty ($ccaps)) ? implode ("<br />", $ccaps) : "—";
|
203 |
+
}
|
204 |
+
/**/
|
205 |
+
else if (preg_match ("/^s2member_custom_field_/", $col))
|
206 |
+
{
|
207 |
+
if (!$last_fields_id || $last_fields_id !== $user_id)
|
208 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
209 |
+
/**/
|
210 |
+
$field_var = preg_replace ("/^s2member_custom_field_/", "", $col);
|
211 |
+
/**/
|
212 |
+
if (is_string ($fields[$field_var]) && preg_match ("/^http(s?)\:/i", $fields[$field_var]))
|
213 |
+
$val = '<a href="' . esc_attr ($fields[$field_var]) . '" target="_blank">' . esc_html (substr ($fields[$field_var], strpos ($fields[$field_var], ":") + 3, 25) . "...") . '</a>';
|
214 |
+
/**/
|
215 |
+
else if (is_array ($fields[$field_var]) && !empty ($fields[$field_var]))
|
216 |
+
$val = preg_replace ("/-\|br\|-/", "<br />", esc_html (implode ("-|br|-", $fields[$field_var])));
|
217 |
+
/**/
|
218 |
+
else if (is_string ($fields[$field_var]) && strlen ($fields[$field_var]))
|
219 |
+
$val = esc_html ($fields[$field_var]);
|
220 |
+
/**/
|
221 |
+
$last_fields_id = $user_id; /* Record this. */
|
222 |
+
}
|
223 |
+
/**/
|
224 |
+
$last_user_id = $user_id; /* Record this for internal optimizations. */
|
225 |
+
/**/
|
226 |
+
return apply_filters ("ws_plugin__s2member_users_list_display_cols", ( (strlen ($val)) ? $val : "—"), get_defined_vars ());
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
?>
|
includes/classes/utilities.inc.php
ADDED
@@ -0,0 +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_utilities"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utilities
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function evaluates PHP code, and returns the output afterward.
|
23 |
+
*/
|
24 |
+
public static function evl ($code = FALSE)
|
25 |
+
{
|
26 |
+
ob_start (); /* Output buffer. */
|
27 |
+
/**/
|
28 |
+
eval ("?>" . trim ($code));
|
29 |
+
/**/
|
30 |
+
return ob_get_clean ();
|
31 |
+
}
|
32 |
+
/*
|
33 |
+
Function that buffers ( gets ) function output.
|
34 |
+
*/
|
35 |
+
public static function get ($function = FALSE)
|
36 |
+
{
|
37 |
+
$args = func_get_args ();
|
38 |
+
$function = array_shift ($args);
|
39 |
+
/**/
|
40 |
+
if (is_string ($function) && $function)
|
41 |
+
{
|
42 |
+
ob_start ();
|
43 |
+
/**/
|
44 |
+
if (is_array ($args) && !empty ($args))
|
45 |
+
{
|
46 |
+
$return = call_user_func_array ($function, $args);
|
47 |
+
}
|
48 |
+
else /* There are no additional arguments to pass. */
|
49 |
+
{
|
50 |
+
$return = call_user_func ($function);
|
51 |
+
}
|
52 |
+
/**/
|
53 |
+
$echo = ob_get_clean ();
|
54 |
+
/**/
|
55 |
+
return (!strlen ($echo) && strlen ($return)) ? $return : $echo;
|
56 |
+
}
|
57 |
+
else /* Else return null. */
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
includes/classes/utils-arrays.inc.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_arrays"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_arrays
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that extends array_unique to
|
23 |
+
support multi-dimensional arrays.
|
24 |
+
*/
|
25 |
+
public static function array_unique ($array = FALSE)
|
26 |
+
{
|
27 |
+
if (!is_array ($array))
|
28 |
+
{
|
29 |
+
return array ($array);
|
30 |
+
}
|
31 |
+
else /* Serialized array_unique. */
|
32 |
+
{
|
33 |
+
foreach ($array as &$value)
|
34 |
+
{
|
35 |
+
$value = serialize ($value);
|
36 |
+
}
|
37 |
+
/**/
|
38 |
+
$array = array_unique ($array);
|
39 |
+
/**/
|
40 |
+
foreach ($array as &$value)
|
41 |
+
{
|
42 |
+
$value = unserialize ($value);
|
43 |
+
}
|
44 |
+
/**/
|
45 |
+
return $array;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
/*
|
49 |
+
Function that searches a multi-dimensional array
|
50 |
+
using a regular expression match against array values.
|
51 |
+
*/
|
52 |
+
public static function regex_in_array ($regex = FALSE, $array = FALSE)
|
53 |
+
{
|
54 |
+
if ($regex && is_array ($array))
|
55 |
+
{
|
56 |
+
foreach ($array as $value)
|
57 |
+
{
|
58 |
+
if (is_array ($value)) /* Recursive function call. */
|
59 |
+
{
|
60 |
+
if (c_ws_plugin__s2member_utils_arrays::regex_in_array ($regex, $value))
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
/**/
|
64 |
+
else if (is_string ($value)) /* Must be a string. */
|
65 |
+
{
|
66 |
+
if (@preg_match ($regex, $value))
|
67 |
+
return true;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
/**/
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
else /* False. */
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
?>
|
includes/classes/utils-captchas.inc.php
ADDED
@@ -0,0 +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_utils_captchas"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_captchas
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function verifies a reCaptcha code though a connection to Google®.
|
23 |
+
*/
|
24 |
+
public static function recaptcha_code_validates ($challenge = FALSE, $response = FALSE)
|
25 |
+
{
|
26 |
+
$post_vars = array ("privatekey" => $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["recaptcha"]["private_key"], "remoteip" => $_SERVER["REMOTE_ADDR"], "challenge" => $challenge, "response" => $response);
|
27 |
+
/**/
|
28 |
+
return preg_match ("/^true/i", trim (c_ws_plugin__s2member_utils_urls::remote ("http://www.google.com/recaptcha/api/verify", $post_vars)));
|
29 |
+
}
|
30 |
+
/*
|
31 |
+
Function that builds a reCaptcha <script></script> tag for display.
|
32 |
+
*/
|
33 |
+
public static function recaptcha_script_tag ($theme = FALSE, $tabindex = FALSE, $error = FALSE)
|
34 |
+
{
|
35 |
+
$theme = ($theme) ? $theme : "clean"; /* Defaults to the `clean` theme style. */
|
36 |
+
$tabindex = (strlen ($tabindex)) ? (int)$tabindex : -1; /* -1 default. */
|
37 |
+
/**/
|
38 |
+
$s = '<script type="text/javascript">' . "if(typeof RecaptchaOptions !== 'object'){ var RecaptchaOptions = {theme: '" . c_ws_plugin__s2member_utils_strings::esc_sq ($theme) . "', lang: '" . c_ws_plugin__s2member_utils_strings::esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["recaptcha"]["lang"]) . "', tabindex: " . $tabindex . " }; }" . '</script>' . "\n";
|
39 |
+
/**/
|
40 |
+
return $s . '<script type="text/javascript" src="' . esc_attr ('https://www.google.com/recaptcha/api/challenge?k=' . urlencode ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["recaptcha"]["public_key"])) . '' . (($error) ? '&error=' . urlencode ($error) : '') . '"></script>';
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
?>
|
includes/classes/utils-conds.inc.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_conds"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_conds
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Determines whether or not this is a User Admin panel.
|
23 |
+
*/
|
24 |
+
public static function is_user_admin ()
|
25 |
+
{
|
26 |
+
if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
|
27 |
+
return is_user_admin ();
|
28 |
+
/**/
|
29 |
+
return is_admin ();
|
30 |
+
}
|
31 |
+
/*
|
32 |
+
Determines whether or not this is a Blog Admin panel.
|
33 |
+
*/
|
34 |
+
public static function is_blog_admin ()
|
35 |
+
{
|
36 |
+
if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
|
37 |
+
return is_blog_admin ();
|
38 |
+
/**/
|
39 |
+
return is_admin ();
|
40 |
+
}
|
41 |
+
/*
|
42 |
+
Determines whether or not this is the Network Admin panel.
|
43 |
+
*/
|
44 |
+
public static function is_network_admin ()
|
45 |
+
{
|
46 |
+
if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
|
47 |
+
return is_network_admin ();
|
48 |
+
/**/
|
49 |
+
return is_admin ();
|
50 |
+
}
|
51 |
+
/*
|
52 |
+
Determines whether or not this is a Multisite Farm.
|
53 |
+
With s2Member, this option may also indicate a Multisite Blog Farm.
|
54 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup"
|
55 |
+
*/
|
56 |
+
public static function is_multisite_farm ()
|
57 |
+
{
|
58 |
+
return (is_multisite () && ( (is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup") || (defined ("MULTISITE_FARM") && MULTISITE_FARM)));
|
59 |
+
}
|
60 |
+
/*
|
61 |
+
Function checks if a post is in a child category.
|
62 |
+
*/
|
63 |
+
public static function in_descendant_category ($cats = FALSE, $post_id = FALSE)
|
64 |
+
{
|
65 |
+
foreach ((array)$cats as $cat)
|
66 |
+
{
|
67 |
+
$descendants = get_term_children ((int)$cat, "category");
|
68 |
+
if ($descendants && in_category ($descendants, $post_id))
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
/**/
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
?>
|
includes/classes/utils-css.inc.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
+
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
+
|
6 |
+
Released under the terms of the GNU General Public License.
|
7 |
+
You should have received a copy of the GNU General Public License,
|
8 |
+
along with this software. In the main directory, see: /licensing/
|
9 |
+
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Direct access denial.
|
13 |
+
*/
|
14 |
+
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
+
exit ("Do not access this file directly.");
|
16 |
+
/**/
|
17 |
+
if (!class_exists ("c_ws_plugin__s2member_utils_css"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_css
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Functions that handles CSS compression routines.
|
23 |
+
*/
|
24 |
+
public static function compress_css ($css = FALSE)
|
25 |
+
{
|
26 |
+
$c6 = "/(\:#| #)([A-Z0-9]{6})/i";
|
27 |
+
$css = preg_replace ("/\/\*(.*?)\*\//s", "", $css);
|
28 |
+
$css = preg_replace ("/[\r\n\t]+/", "", $css);
|
29 |
+
$css = preg_replace ("/ {2,}/", " ", $css);
|
30 |
+
$css = preg_replace ("/ , | ,|, /", ",", $css);
|
31 |
+
$css = preg_replace ("/ \> | \>|\> /", ">", $css);
|
32 |
+
$css = preg_replace ("/\[ /", "[", $css);
|
33 |
+
$css = preg_replace ("/ \]/", "]", $css);
|
34 |
+
$css = preg_replace ("/ \!\= | \!\=|\!\= /", "!=", $css);
|
35 |
+
$css = preg_replace ("/ \|\= | \|\=|\|\= /", "|=", $css);
|
36 |
+
$css = preg_replace ("/ \^\= | \^\=|\^\= /", "^=", $css);
|
37 |
+
$css = preg_replace ("/ \$\= | \$\=|\$\= /", "$=", $css);
|
38 |
+
$css = preg_replace ("/ \*\= | \*\=|\*\= /", "*=", $css);
|
39 |
+
$css = preg_replace ("/ ~\= | ~\=|~\= /", "~=", $css);
|
40 |
+
$css = preg_replace ("/ \= | \=|\= /", "=", $css);
|
41 |
+
$css = preg_replace ("/ \+ | \+|\+ /", "+", $css);
|
42 |
+
$css = preg_replace ("/ ~ | ~|~ /", "~", $css);
|
43 |
+
$css = preg_replace ("/ \{ | \{|\{ /", "{", $css);
|
44 |
+
$css = preg_replace ("/ \} | \}|\} /", "}", $css);
|
45 |
+
$css = preg_replace ("/ \: | \:|\: /", ":", $css);
|
46 |
+
$css = preg_replace ("/ ; | ;|; /", ";", $css);
|
47 |
+
$css = preg_replace ("/;\}/", "}", $css);
|
48 |
+
/**/
|
49 |
+
return preg_replace_callback ($c6, "c_ws_plugin__s2member_utils_css::compress_css_c3", $css);
|
50 |
+
}
|
51 |
+
/**/
|
52 |
+
public static function compress_css_c3 ($m = FALSE)
|
53 |
+
{
|
54 |
+
if ($m[2][0] === $m[2][1] && $m[2][2] === $m[2][3] && $m[2][4] === $m[2][5])
|
55 |
+
return $m[1] . $m[2][0] . $m[2][2] . $m[2][4];
|
56 |
+
return $m[0];
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
?>
|
includes/classes/utils-dirs.inc.php
ADDED
@@ -0,0 +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_utils_dirs"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_dirs
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Functions that formulates basename dirs from a full directory path.
|
23 |
+
- This takes Windows® \app_data sub-folders into consideration.
|
24 |
+
*/
|
25 |
+
public static function basename_dirs ($dir_path = FALSE)
|
26 |
+
{
|
27 |
+
$dir_path = rtrim ($dir_path, DIRECTORY_SEPARATOR);
|
28 |
+
/**/
|
29 |
+
$dir_path = preg_replace ("/(" . preg_quote (DIRECTORY_SEPARATOR, "/") . "|\/)app_data$/i", "", $dir_path, 1, $app_data);
|
30 |
+
/**/
|
31 |
+
return basename ($dir_path) . (($app_data) ? "/app_data" : "");
|
32 |
+
}
|
33 |
+
/*
|
34 |
+
Functions that strips a trailing \app_data sub-directory from the full path.
|
35 |
+
*/
|
36 |
+
public static function strip_dir_app_data ($dir_path = FALSE)
|
37 |
+
{
|
38 |
+
$dir_path = rtrim ($dir_path, DIRECTORY_SEPARATOR);
|
39 |
+
/**/
|
40 |
+
return preg_replace ("/(" . preg_quote (DIRECTORY_SEPARATOR, "/") . "|\/)app_data$/i", "", $dir_path, 1);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
?>
|
includes/classes/utils-encryption.inc.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_encryption"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_encryption
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
RIJNDAEL 256: two-way encryption/decryption, with a url-safe base64 wrapper.
|
23 |
+
Includes a built-in fallback on XOR encryption when mcrypt is not available.
|
24 |
+
*/
|
25 |
+
public static function encrypt ($string = FALSE, $key = FALSE)
|
26 |
+
{
|
27 |
+
$string = (is_string ($string)) ? $string : "";
|
28 |
+
/**/
|
29 |
+
$key = (!is_string ($key) || !strlen ($key)) ? /* For security. */
|
30 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] : $key;
|
31 |
+
$key = (!is_string ($key) || !strlen ($key)) ? wp_salt () : $key;
|
32 |
+
/**/
|
33 |
+
if (function_exists ("mcrypt_encrypt") && in_array ("rijndael-256", mcrypt_list_algorithms ()) && in_array ("cbc", mcrypt_list_modes ()))
|
34 |
+
{
|
35 |
+
$string = (strlen ($string)) ? "~r2|" . $string : "";
|
36 |
+
$key = substr ($key, 0, mcrypt_get_key_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
|
37 |
+
$iv = c_ws_plugin__s2member_utils_strings::random_str_gen (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), false);
|
38 |
+
$encrypted = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv);
|
39 |
+
$encrypted = (strlen ($encrypted)) ? "~r2:" . $iv . "|" . $encrypted : "";
|
40 |
+
/**/
|
41 |
+
return ($base64 = str_replace (array ("+", "/", "="), array ("-", "_", "~"), base64_encode ($encrypted)));
|
42 |
+
}
|
43 |
+
else /* Fallback on XOR encryption. */
|
44 |
+
return c_ws_plugin__s2member_utils_encryption::xencrypt ($string, $key);
|
45 |
+
}
|
46 |
+
/*
|
47 |
+
RIJNDAEL 256: two-way encryption/decryption, with a url-safe base64 wrapper.
|
48 |
+
Includes a built-in fallback on XOR encryption when mcrypt is not available.
|
49 |
+
*/
|
50 |
+
public static function decrypt ($base64 = FALSE, $key = FALSE)
|
51 |
+
{
|
52 |
+
$base64 = (is_string ($base64)) ? $base64 : "";
|
53 |
+
/**/
|
54 |
+
$key = (!is_string ($key) || !strlen ($key)) ? /* For security. */
|
55 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] : $key;
|
56 |
+
$key = (!is_string ($key) || !strlen ($key)) ? wp_salt () : $key;
|
57 |
+
/**/
|
58 |
+
$encrypted = base64_decode (str_replace (array ("-", "_", "~", "."), array ("+", "/", "=", "="), $base64));
|
59 |
+
/**/
|
60 |
+
if (function_exists ("mcrypt_decrypt") && in_array ("rijndael-256", mcrypt_list_algorithms ()) && in_array ("cbc", mcrypt_list_modes ())/**/
|
61 |
+
&& preg_match ("/^~r2\:(.+?)\|/", $encrypted, $v1)) /* Check validity. */
|
62 |
+
{
|
63 |
+
$encrypted = preg_replace ("/^~r2\:(.+?)\|/", "", $encrypted);
|
64 |
+
$key = substr ($key, 0, mcrypt_get_key_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
|
65 |
+
$decrypted = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_CBC, $v1[1]);
|
66 |
+
$decrypted = preg_replace ("/^~r2\|/", "", $decrypted, 1, $v2);
|
67 |
+
$decrypted = ($v2) ? $decrypted : ""; /* Check validity. */
|
68 |
+
$decrypted = rtrim ($decrypted, "\0\4"); /* Nulls/EOTs. */
|
69 |
+
/**/
|
70 |
+
return ($string = $decrypted);
|
71 |
+
}
|
72 |
+
else /* Fallback on XOR decryption. */
|
73 |
+
return c_ws_plugin__s2member_utils_encryption::xdecrypt ($base64, $key);
|
74 |
+
}
|
75 |
+
/*
|
76 |
+
XOR two-way encryption/decryption, with a base64 wrapper.
|
77 |
+
*/
|
78 |
+
public static function xencrypt ($string = FALSE, $key = FALSE)
|
79 |
+
{
|
80 |
+
$string = (is_string ($string)) ? $string : "";
|
81 |
+
/**/
|
82 |
+
$key = (!is_string ($key) || !strlen ($key)) ? /* For security. */
|
83 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] : $key;
|
84 |
+
$key = (!is_string ($key) || !strlen ($key)) ? wp_salt () : $key;
|
85 |
+
/**/
|
86 |
+
$string = (strlen ($string)) ? "~xe|" . $string : "";
|
87 |
+
/**/
|
88 |
+
for ($i = 1, $encrypted = ""; $i <= strlen ($string); $i++)
|
89 |
+
{
|
90 |
+
$char = substr ($string, $i - 1, 1);
|
91 |
+
$keychar = substr ($key, ($i % strlen ($key)) - 1, 1);
|
92 |
+
$encrypted .= chr (ord ($char) + ord ($keychar));
|
93 |
+
}
|
94 |
+
/**/
|
95 |
+
$encrypted = (strlen ($encrypted)) ? "~xe|" . $encrypted : "";
|
96 |
+
/**/
|
97 |
+
return ($base64 = str_replace (array ("+", "/", "="), array ("-", "_", "~"), base64_encode ($encrypted)));
|
98 |
+
}
|
99 |
+
/*
|
100 |
+
XOR two-way encryption/decryption, with a base64 wrapper.
|
101 |
+
*/
|
102 |
+
public static function xdecrypt ($base64 = FALSE, $key = FALSE)
|
103 |
+
{
|
104 |
+
$base64 = (is_string ($base64)) ? $base64 : "";
|
105 |
+
/**/
|
106 |
+
$key = (!is_string ($key) || !strlen ($key)) ? /* For security. */
|
107 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] : $key;
|
108 |
+
$key = (!is_string ($key) || !strlen ($key)) ? wp_salt () : $key;
|
109 |
+
/**/
|
110 |
+
$encrypted = base64_decode (str_replace (array ("-", "_", "~", "."), array ("+", "/", "=", "="), $base64));
|
111 |
+
/**/
|
112 |
+
$encrypted = preg_replace ("/^~xe\|/", "", $encrypted, 1, $v1);
|
113 |
+
$encrypted = ($v1) ? $encrypted : ""; /* Check validity. */
|
114 |
+
/**/
|
115 |
+
for ($i = 1, $decrypted = ""; $i <= strlen ($encrypted); $i++)
|
116 |
+
{
|
117 |
+
$char = substr ($encrypted, $i - 1, 1);
|
118 |
+
$keychar = substr ($key, ($i % strlen ($key)) - 1, 1);
|
119 |
+
$decrypted .= chr (ord ($char) - ord ($keychar));
|
120 |
+
}
|
121 |
+
/**/
|
122 |
+
$decrypted = preg_replace ("/^~xe\|/", "", $decrypted, 1, $v2);
|
123 |
+
$decrypted = ($v2) ? $decrypted : ""; /* Check validity. */
|
124 |
+
/**/
|
125 |
+
return ($string = $decrypted);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
?>
|
includes/classes/utils-forms.inc.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_forms"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_forms
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function converts a form with hidden inputs into a URL w/ query string.
|
23 |
+
*/
|
24 |
+
public static function form_whips_2_url ($form = FALSE)
|
25 |
+
{
|
26 |
+
if (preg_match ("/\<form(.+?)\>/is", $form, $form_attr_m)) /* Is this a form? */
|
27 |
+
{
|
28 |
+
if (preg_match ("/(\s)(action)( ?)(\=)( ?)(['\"])(.+?)(['\"])/is", $form_attr_m[1], $form_action_m))
|
29 |
+
{
|
30 |
+
if (($url = trim ($form_action_m[7]))) /* Set URL value dynamically. Now we add values. */
|
31 |
+
{
|
32 |
+
foreach ((array)c_ws_plugin__s2member_utils_forms::form_whips_2_array ($form) as $name => $value)
|
33 |
+
{
|
34 |
+
if (strlen ($name) && strlen ($value)) /* Check $name -> $value lengths. */
|
35 |
+
/**/
|
36 |
+
if (strlen ($value = (preg_match ("/^http(s)?\:\/\//i", $value)) ? rawurlencode ($value) : urlencode ($value)))
|
37 |
+
{
|
38 |
+
$url = add_query_arg ($name, $value, $url);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
/**/
|
42 |
+
return $url;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
/**/
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
/*
|
50 |
+
Function converts a form with hidden inputs into an associative array.
|
51 |
+
*/
|
52 |
+
public static function form_whips_2_array ($form = FALSE)
|
53 |
+
{
|
54 |
+
if (preg_match ("/\<form(.+?)\>/is", $form)) /* Is this a form? */
|
55 |
+
{
|
56 |
+
if (preg_match_all ("/(?<!\<\!--)\<input(.+?)\>/is", $form, $input_attr_ms, PREG_SET_ORDER))
|
57 |
+
{
|
58 |
+
foreach ($input_attr_ms as $input_attr_m) /* Go through each hidden input variable. */
|
59 |
+
{
|
60 |
+
if (preg_match ("/(\s)(type)( ?)(\=)( ?)(['\"])(hidden)(['\"])/is", $input_attr_m[1]))
|
61 |
+
{
|
62 |
+
if (preg_match ("/(\s)(name)( ?)(\=)( ?)(['\"])(.+?)(['\"])/is", $input_attr_m[1], $input_name_m))
|
63 |
+
{
|
64 |
+
if (preg_match ("/(\s)(value)( ?)(\=)( ?)(['\"])(.+?)(['\"])/is", $input_attr_m[1], $input_value_m))
|
65 |
+
{
|
66 |
+
$array[trim ($input_name_m[7])] = trim (wp_specialchars_decode ($input_value_m[7], ENT_QUOTES));
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
/**/
|
74 |
+
return (array)$array;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
?>
|
includes/classes/utils-gets.inc.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_gets"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_gets
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function retrieves a list of all Category IDs from the database.
|
23 |
+
*/
|
24 |
+
public static function get_all_category_ids ()
|
25 |
+
{
|
26 |
+
$ids = get_all_category_ids ();
|
27 |
+
/**/
|
28 |
+
return (array)$ids;
|
29 |
+
}
|
30 |
+
/*
|
31 |
+
Function retrieves a list of all child Category IDs from the database.
|
32 |
+
*/
|
33 |
+
public static function get_all_child_category_ids ($parent = FALSE)
|
34 |
+
{
|
35 |
+
if (is_numeric ($parent) && is_array ($categories = get_categories ("child_of=" . $parent)))
|
36 |
+
foreach ($categories as $child_category)
|
37 |
+
$child_ids[] = $child_category->term_id;
|
38 |
+
/**/
|
39 |
+
return (array)$child_ids;
|
40 |
+
}
|
41 |
+
/*
|
42 |
+
Function retrieves a list of all Tag IDs from the database.
|
43 |
+
*/
|
44 |
+
public static function get_all_tag_ids ()
|
45 |
+
{
|
46 |
+
global $wpdb; /* Need global DB obj. */
|
47 |
+
/**/
|
48 |
+
foreach ((array)get_tags () as $tag)
|
49 |
+
$ids[] = $tag->term_id;
|
50 |
+
/**/
|
51 |
+
return (array)$ids;
|
52 |
+
}
|
53 |
+
/*
|
54 |
+
Function retrieves a list of all Post IDs from the database.
|
55 |
+
- Includes Custom Post Types.
|
56 |
+
*/
|
57 |
+
public static function get_all_post_ids ()
|
58 |
+
{
|
59 |
+
global $wpdb; /* Need global DB obj. */
|
60 |
+
/**/
|
61 |
+
$ids = $wpdb->get_col ("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `post_type` NOT IN('page','attachment','revision')");
|
62 |
+
/**/
|
63 |
+
return (array)$ids;
|
64 |
+
}
|
65 |
+
/*
|
66 |
+
Function retrieves a list of all Page IDs from the database.
|
67 |
+
*/
|
68 |
+
public static function get_all_page_ids ()
|
69 |
+
{
|
70 |
+
global $wpdb; /* Need global DB obj. */
|
71 |
+
/**/
|
72 |
+
$ids = $wpdb->get_col ("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `post_type` = 'page'");
|
73 |
+
/**/
|
74 |
+
return (array)$ids;
|
75 |
+
}
|
76 |
+
/*
|
77 |
+
Function converts a comma-delimited list of:
|
78 |
+
Tag slugs/names/ids - into all IDs.
|
79 |
+
*/
|
80 |
+
public static function convert_tags_2_ids ($tags = FALSE)
|
81 |
+
{
|
82 |
+
foreach (preg_split ("/[\r\n\t;,]+/", $tags) as $tag)
|
83 |
+
{
|
84 |
+
if (($tag = trim ($tag)) && is_numeric ($tag))
|
85 |
+
{
|
86 |
+
$ids[] = $tag;
|
87 |
+
}
|
88 |
+
else if ($tag && is_string ($tag))
|
89 |
+
{
|
90 |
+
if (is_object ($term = get_term_by ("name", $tag, "post_tag")))
|
91 |
+
{
|
92 |
+
$ids[] = $term->term_id;
|
93 |
+
}
|
94 |
+
else if (is_object ($term = get_term_by ("slug", $tag, "post_tag")))
|
95 |
+
{
|
96 |
+
$ids[] = $term->term_id;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
/**/
|
101 |
+
return (array)$ids;
|
102 |
+
}
|
103 |
+
/*
|
104 |
+
Function retrieves a list of singular IDs from the database.
|
105 |
+
- Only returns Posts that require Custom Capabilities.
|
106 |
+
and ONLY those which are NOT satisfied by $user.
|
107 |
+
*/
|
108 |
+
public static function get_singular_ids_with_ccaps_req ($user = FALSE)
|
109 |
+
{
|
110 |
+
global $wpdb; /* Need global DB obj. */
|
111 |
+
/**/
|
112 |
+
if (is_array ($results = $wpdb->get_results ("SELECT `post_id`, `meta_value` FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` != ''")))
|
113 |
+
{
|
114 |
+
foreach ($results as $result) /* Now we need to check Custom Capabilities against $user. */
|
115 |
+
{
|
116 |
+
if (!$user) /* Optimization. Saves time when NOT even logged into the site. */
|
117 |
+
$ids[] = $result->post_id; /* There's no way to satisfy anything here. */
|
118 |
+
/**/
|
119 |
+
else if (is_array ($ccaps = @unserialize ($result->meta_value)))
|
120 |
+
/**/
|
121 |
+
foreach ($ccaps as $ccap) /* Test all Custom Capability requirements. */
|
122 |
+
if (strlen ($ccap)) /* Quick (empty) check here. */
|
123 |
+
if (!$user->has_cap ("access_s2member_ccap_" . $ccap))
|
124 |
+
{
|
125 |
+
$ids[] = $result->post_id;
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
return (array)$ids;
|
132 |
+
}
|
133 |
+
/*
|
134 |
+
Function retrieves a list of singular IDs from the database.
|
135 |
+
- Only returns Posts that require Specific Post/Page Access.
|
136 |
+
& ONLY those which are NOT satisfied by the current Visitor.
|
137 |
+
*/
|
138 |
+
public static function get_singular_ids_with_sp_req ()
|
139 |
+
{
|
140 |
+
global $wpdb; /* Need global DB obj. */
|
141 |
+
/**/
|
142 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && is_array ($sps = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
143 |
+
{
|
144 |
+
foreach ($sps as $sp) /* Now we need to check access against the current Visitor. */
|
145 |
+
{
|
146 |
+
if ($sp && !c_ws_plugin__s2member_sp_access::sp_access ($sp, "read-only"))
|
147 |
+
$ids[] = $sp;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
/**/
|
151 |
+
return (array)$ids;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
?>
|
includes/classes/utils-logs.inc.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_logs"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_logs
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Archive logs to prevent HUGE files from building up over time.
|
23 |
+
This routine is staggered to conserve resources.
|
24 |
+
This is called by all logging routines for s2Member.
|
25 |
+
*/
|
26 |
+
public static function archive_oversize_log_files ($stagger = TRUE)
|
27 |
+
{
|
28 |
+
if (!$stagger || is_float ($stagger = time () / 2)) /* Stagger this routine? */
|
29 |
+
{
|
30 |
+
if (is_dir ($dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]) && is_writable ($dir))
|
31 |
+
{
|
32 |
+
$max = apply_filters ("ws_plugin__s2member_oversize_log_file_bytes", 2097152, get_defined_vars ());
|
33 |
+
/**/
|
34 |
+
eval ('$log_files = scandir ($dir); shuffle($log_files); $counter = 1;');
|
35 |
+
/**/
|
36 |
+
foreach ($log_files as $file) /* Go through each log file. Up to 25 files at a time. */
|
37 |
+
{
|
38 |
+
if (preg_match ("/\.log$/i", $file) && !preg_match ("/-ARCHIVED-/i", $file) && is_file ($dir_file = $dir . "/" . $file))
|
39 |
+
{
|
40 |
+
if (filesize ($dir_file) > $max && is_writable ($dir_file)) /* The file must be writable. */
|
41 |
+
if ($log = preg_replace ("/\.log$/i", "", $dir_file)) /* Strip .log before renaming. */
|
42 |
+
rename ($dir_file, $log . "-ARCHIVED-" . date ("m-d-Y") . "-" . time () . ".log");
|
43 |
+
}
|
44 |
+
/**/
|
45 |
+
if (($counter = $counter + 1) > 25) /* Up to 25 files at a time. */
|
46 |
+
break; /* Stop for now. */
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
/**/
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
/*
|
54 |
+
Remove expired Transients inserted into the database by s2Member.
|
55 |
+
This routine is staggered to conserve resources.
|
56 |
+
- And only 5 Transients are deleted each time.
|
57 |
+
This is called by s2Member's Auto-EOT System; every 10 minutes.
|
58 |
+
*/
|
59 |
+
public static function cleanup_expired_s2m_transients ($stagger = TRUE)
|
60 |
+
{
|
61 |
+
global $wpdb; /* Will need this for database cleaning. */
|
62 |
+
/**/
|
63 |
+
if (!$stagger || is_float ($stagger = time () / 2)) /* Stagger this routine? */
|
64 |
+
{
|
65 |
+
if (is_array ($expired_s2m_transients = $wpdb->get_results ("SELECT * FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_timeout\_s2m\_%' AND `option_value` < '" . esc_sql (time ()) . "' LIMIT 5")) && !empty ($expired_s2m_transients))
|
66 |
+
{
|
67 |
+
foreach ($expired_s2m_transients as $expired_s2m_transient) /* Delete the _timeout, and also the Transient entry itself. */
|
68 |
+
if (($id = $expired_s2m_transient->option_id) && ($name = preg_replace ("/_timeout/i", "", $expired_s2m_transient->option_name, 1)))
|
69 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_id` = '" . esc_sql ($id) . "' OR `option_name` = '" . esc_sql ($name) . "'");
|
70 |
+
}
|
71 |
+
}
|
72 |
+
/**/
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
?>
|
includes/classes/utils-strings.inc.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_strings"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_strings
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function escapes double quotes.
|
23 |
+
*/
|
24 |
+
public static function esc_dq ($string = FALSE)
|
25 |
+
{
|
26 |
+
return preg_replace ('/"/', '\"', $string);
|
27 |
+
}
|
28 |
+
/*
|
29 |
+
Function escapes single quotes.
|
30 |
+
*/
|
31 |
+
public static function esc_sq ($string = FALSE)
|
32 |
+
{
|
33 |
+
return preg_replace ("/'/", "\'", $string);
|
34 |
+
}
|
35 |
+
/*
|
36 |
+
Function escapes dollars signs ( for regex patterns ).
|
37 |
+
*/
|
38 |
+
public static function esc_ds ($string = FALSE)
|
39 |
+
{
|
40 |
+
return preg_replace ('/\$/', '\\\$', $string);
|
41 |
+
}
|
42 |
+
/*
|
43 |
+
Function that sanitizes a string; by removing non-standard characters.
|
44 |
+
This allows all characters that appears on a standard computer keyboard.
|
45 |
+
*/
|
46 |
+
public static function keyboard_chars_only ($value = FALSE)
|
47 |
+
{
|
48 |
+
return preg_replace ("/[^0-9A-Z\r\n\t\s`\=\[\]\\\;',\.\/~\!@#\$%\^&\*\(\)_\+\|\}\{\:\"\?\>\<\-]/i", "", remove_accents ((string)$value));
|
49 |
+
}
|
50 |
+
/*
|
51 |
+
Function that trims deeply.
|
52 |
+
*/
|
53 |
+
public static function trim_deep ($value = FALSE)
|
54 |
+
{
|
55 |
+
return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_deep", $value) : trim ($value);
|
56 |
+
}
|
57 |
+
/*
|
58 |
+
Function that trims " entities deeply.
|
59 |
+
This is useful on Shortcode attributes mangled by a Visual Editor.
|
60 |
+
*/
|
61 |
+
public static function trim_quot_deep ($value = FALSE)
|
62 |
+
{
|
63 |
+
return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_quot_deep", $value) : preg_replace ("(^(")+|(")+$)", "", $value);
|
64 |
+
}
|
65 |
+
/*
|
66 |
+
Function that trims double quotes deeply ( i.e. " ).
|
67 |
+
This is useful on CSV data that is encapsulated by double quotes.
|
68 |
+
*/
|
69 |
+
public static function trim_dq_deep ($value = FALSE)
|
70 |
+
{
|
71 |
+
return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_dq_deep", $value) : trim ($value, "\" \t\n\r\0\x0B");
|
72 |
+
}
|
73 |
+
/*
|
74 |
+
Function generates a random string with letters/numbers/symbols.
|
75 |
+
*/
|
76 |
+
public static function random_str_gen ($length = 12, $special_chars = TRUE, $extra_special_chars = FALSE)
|
77 |
+
{
|
78 |
+
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
79 |
+
$chars .= ($extra_special_chars) ? "-_ []{}<>~`+=,.;:/?|" : "";
|
80 |
+
$chars .= ($special_chars) ? "!@#$%^&*()" : "";
|
81 |
+
/**/
|
82 |
+
for ($i = 0, $random_str = ""; $i < $length; $i++)
|
83 |
+
$random_str .= substr ($chars, mt_rand (0, strlen ($chars) - 1), 1);
|
84 |
+
/**/
|
85 |
+
return $random_str;
|
86 |
+
}
|
87 |
+
/*
|
88 |
+
Functions that highlights PHP, and also Shortcodes.
|
89 |
+
*/
|
90 |
+
public static function highlight_php ($str = FALSE)
|
91 |
+
{
|
92 |
+
$str = highlight_string ($str, true); /* Start with PHP syntax highlighting first. */
|
93 |
+
/**/
|
94 |
+
return preg_replace_callback ("/(\[)(\/?)(_*s2If|s2Get|s2Member-[A-z_0-9\-]+)(.*?)(\])/i", "c_ws_plugin__s2member_utils_strings::_highlight_php", $str);
|
95 |
+
}
|
96 |
+
/**/
|
97 |
+
public static function _highlight_php ($m = FALSE)
|
98 |
+
{
|
99 |
+
return '<span style="color:#164A61;">' . $m[0] . '</span>';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
?>
|
includes/classes/utils-time.inc.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_time"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_time
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that determines the difference between two timestamps. Returns the difference in a human readable format.
|
23 |
+
Supports: minutes, hours, days, weeks, months, and years. This is an improvement on WordPress® human_time_diff().
|
24 |
+
This returns an "approximate" time difference. Rounded to the nearest minute, hour, day, week, month, year.
|
25 |
+
*/
|
26 |
+
public static function approx_time_difference ($from = FALSE, $to = FALSE)
|
27 |
+
{
|
28 |
+
$from = (!$from) ? strtotime ("now") : (int)$from;
|
29 |
+
$to = (!$to) ? strtotime ("now") : (int)$to;
|
30 |
+
/**/
|
31 |
+
if (($difference = abs ($to - $from)) < 3600)
|
32 |
+
{
|
33 |
+
$m = (int)round ($difference / 60);
|
34 |
+
/**/
|
35 |
+
$since = ($m < 1) ? "less than a minute" : $since;
|
36 |
+
$since = ($m === 1) ? "1 minute" : $since;
|
37 |
+
$since = ($m > 1) ? $m . " minutes" : $since;
|
38 |
+
$since = ($m >= 60) ? "about 1 hour" : $since;
|
39 |
+
}
|
40 |
+
else if ($difference >= 3600 && $difference < 86400)
|
41 |
+
{
|
42 |
+
$h = (int)round ($difference / 3600);
|
43 |
+
/**/
|
44 |
+
$since = ($h === 1) ? "1 hour" : $since;
|
45 |
+
$since = ($h > 1) ? $h . " hours" : $since;
|
46 |
+
$since = ($h >= 24) ? "about 1 day" : $since;
|
47 |
+
}
|
48 |
+
else if ($difference >= 86400 && $difference < 604800)
|
49 |
+
{
|
50 |
+
$d = (int)round ($difference / 86400);
|
51 |
+
/**/
|
52 |
+
$since = ($d === 1) ? "1 day" : $since;
|
53 |
+
$since = ($d > 1) ? $d . " days" : $since;
|
54 |
+
$since = ($d >= 7) ? "about 1 week" : $since;
|
55 |
+
}
|
56 |
+
else if ($difference >= 604800 && $difference < 2592000)
|
57 |
+
{
|
58 |
+
$w = (int)round ($difference / 604800);
|
59 |
+
/**/
|
60 |
+
$since = ($w === 1) ? "1 week" : $since;
|
61 |
+
$since = ($w > 1) ? $w . " weeks" : $since;
|
62 |
+
$since = ($w >= 4) ? "about 1 month" : $since;
|
63 |
+
}
|
64 |
+
else if ($difference >= 2592000 && $difference < 31556926)
|
65 |
+
{
|
66 |
+
$m = (int)round ($difference / 2592000);
|
67 |
+
/**/
|
68 |
+
$since = ($m === 1) ? "1 month" : $since;
|
69 |
+
$since = ($m > 1) ? $m . " months" : $since;
|
70 |
+
$since = ($m >= 12) ? "about 1 year" : $since;
|
71 |
+
}
|
72 |
+
else if ($difference >= 31556926) /* Years. */
|
73 |
+
{
|
74 |
+
$y = (int)round ($difference / 31556926);
|
75 |
+
/**/
|
76 |
+
$since = ($y === 1) ? "1 year" : $since;
|
77 |
+
$since = ($y > 1) ? $y . " years" : $since;
|
78 |
+
}
|
79 |
+
/**/
|
80 |
+
return $since;
|
81 |
+
}
|
82 |
+
/*
|
83 |
+
Calculate Auto-EOT Time, based on last_payment_time, period1, and period3.
|
84 |
+
Used by s2Member's built-in Auto-EOT System, and also by its IPN routines.
|
85 |
+
last_payment_time can be forced w/ $lpt ( i.e. for delayed eots )
|
86 |
+
*/
|
87 |
+
public static function auto_eot_time ($user_id = FALSE, $period1 = FALSE, $period3 = FALSE, $eotper = FALSE, $lpt = FALSE)
|
88 |
+
{
|
89 |
+
if ($user_id && ($user = new WP_User ($user_id)) && $user->ID) /* Valid user_id? */
|
90 |
+
{
|
91 |
+
$registration_time = strtotime ($user->user_registered);
|
92 |
+
$last_payment_time = get_user_option ("s2member_last_payment_time", $user_id);
|
93 |
+
$last_payment_time = ((int)$lpt) ? (int)$lpt : (int)$last_payment_time;
|
94 |
+
/**/
|
95 |
+
if (! ($p1_time = 0) && ($period1 = trim (strtoupper ($period1))))
|
96 |
+
{
|
97 |
+
list ($num, $span) = preg_split ("/ /", $period1, 2);
|
98 |
+
/**/
|
99 |
+
$days = 0; /* Days start at 0. */
|
100 |
+
/**/
|
101 |
+
if (is_numeric ($num) && !is_numeric ($span))
|
102 |
+
{
|
103 |
+
$days = ($span === "D") ? 1 : $days;
|
104 |
+
$days = ($span === "W") ? 7 : $days;
|
105 |
+
$days = ($span === "M") ? 30 : $days;
|
106 |
+
$days = ($span === "Y") ? 365 : $days;
|
107 |
+
}
|
108 |
+
/**/
|
109 |
+
$p1_days = (int)$num * (int)$days;
|
110 |
+
$p1_time = $p1_days * 86400;
|
111 |
+
}
|
112 |
+
/**/
|
113 |
+
if (! ($p3_time = 0) && ($period3 = trim (strtoupper ($period3))))
|
114 |
+
{
|
115 |
+
list ($num, $span) = preg_split ("/ /", $period3, 2);
|
116 |
+
/**/
|
117 |
+
$days = 0; /* Days start at 0. */
|
118 |
+
/**/
|
119 |
+
if (is_numeric ($num) && !is_numeric ($span))
|
120 |
+
{
|
121 |
+
$days = ($span === "D") ? 1 : $days;
|
122 |
+
$days = ($span === "W") ? 7 : $days;
|
123 |
+
$days = ($span === "M") ? 30 : $days;
|
124 |
+
$days = ($span === "Y") ? 365 : $days;
|
125 |
+
}
|
126 |
+
/**/
|
127 |
+
$p3_days = (int)$num * (int)$days;
|
128 |
+
$p3_time = $p3_days * 86400;
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
if (!$last_payment_time) /* If there's been no payment yet.
|
132 |
+
After p1, if there was a p1. Otherwise, reg. time + 1 day grace. */
|
133 |
+
$auto_eot_time = $registration_time + $p1_time + 86400;
|
134 |
+
/**/
|
135 |
+
/* Else if p1, and last payment within p1, last + p1 + 1 day grace. */
|
136 |
+
else if ($p1_time && $last_payment_time <= $registration_time + $p1_time)
|
137 |
+
$auto_eot_time = $last_payment_time + $p1_time + 86400;
|
138 |
+
/**/
|
139 |
+
else /* Otherwise, after last payment + p3 + 1 day grace. */
|
140 |
+
$auto_eot_time = $last_payment_time + $p3_time + 86400;
|
141 |
+
}
|
142 |
+
/**/
|
143 |
+
else if ($eotper) /* Otherwise, if we have a specific EOT period; calculate from today. */
|
144 |
+
{
|
145 |
+
if (! ($eot_time = 0) && ($eotper = trim (strtoupper ($eotper))))
|
146 |
+
{
|
147 |
+
list ($num, $span) = preg_split ("/ /", $eotper, 2);
|
148 |
+
/**/
|
149 |
+
$days = 0; /* Days start at 0. */
|
150 |
+
/**/
|
151 |
+
if (is_numeric ($num) && !is_numeric ($span))
|
152 |
+
{
|
153 |
+
$days = ($span === "D") ? 1 : $days;
|
154 |
+
$days = ($span === "W") ? 7 : $days;
|
155 |
+
$days = ($span === "M") ? 30 : $days;
|
156 |
+
$days = ($span === "Y") ? 365 : $days;
|
157 |
+
}
|
158 |
+
/**/
|
159 |
+
$eot_days = (int)$num * (int)$days;
|
160 |
+
$eot_time = $eot_days * 86400;
|
161 |
+
}
|
162 |
+
/**/
|
163 |
+
$auto_eot_time = strtotime ("now") + $eot_time + 86400;
|
164 |
+
}
|
165 |
+
/**/
|
166 |
+
return ($auto_eot_time <= 0) ? strtotime ("now") : $auto_eot_time;
|
167 |
+
}
|
168 |
+
/*
|
169 |
+
Function converts a term [D,W,M,Y,L,Day,Week,Month,Year,Lifetime] into Daily, Weekly, Monthly, Yearly, Lifetime.
|
170 |
+
This function can also handle "Period Term" combinations. Where the Period will be stripped automatically before conversion.
|
171 |
+
|
172 |
+
For example, "1 D", would become, just "Daily". Another example, "3 Y" would become "Yearly"; and "1 L", would become "Lifetime".
|
173 |
+
Recurring examples: "2 W", becomes "Bi-Weekly", "3 M" becomes Quarterly, and "2 M" becomes "Bi-Monthly".
|
174 |
+
*/
|
175 |
+
public static function term_cycle ($term_or_period_term = FALSE, $directive = "recurring")
|
176 |
+
{
|
177 |
+
if ($directive === "recurring") /* recurring = Daily, Weekly, Bi-Weekly, Monthly, Bi-Monthly, Quarterly, Yearly, Lifetime. */
|
178 |
+
{
|
179 |
+
$paypal_term_cycles = array ("D" => "Daily", "W" => "Weekly", "M" => "Monthly", "Y" => "Yearly", "L" => "Lifetime", "DAY" => "Daily", "WEEK" => "Weekly", "MONTH" => "Monthly", "YEAR" => "Yearly", "Lifetime" => "Lifetime");
|
180 |
+
$term_cycle = $paypal_term_cycles[strtoupper (preg_replace ("/^(.+?) /", "", $term_or_period_term))];
|
181 |
+
$term_cycle = (strtoupper ($term_or_period_term) === "2 W") ? "Bi-Weekly" : $term_cycle;
|
182 |
+
$term_cycle = (strtoupper ($term_or_period_term) === "2 M") ? "Bi-Monthly" : $term_cycle;
|
183 |
+
$term_cycle = (strtoupper ($term_or_period_term) === "3 M") ? "Quarterly" : $term_cycle;
|
184 |
+
}
|
185 |
+
else if ($directive === "singular") /* singular = Day, Week, Month, Year, Lifetime. */
|
186 |
+
{
|
187 |
+
$paypal_term_cycles = array ("D" => "Day", "W" => "Week", "M" => "Month", "Y" => "Year", "L" => "Lifetime", "DAY" => "Day", "WEEK" => "Week", "MONTH" => "Month", "YEAR" => "Year", "Lifetime" => "Lifetime");
|
188 |
+
$term_cycle = $paypal_term_cycles[strtoupper (preg_replace ("/^(.+?) /", "", $term_or_period_term))];
|
189 |
+
}
|
190 |
+
else if ($directive === "plural") /* plural = Days, Weeks, Months, Years, Lifetimes. */
|
191 |
+
{
|
192 |
+
$paypal_term_cycles = array ("D" => "Days", "W" => "Weeks", "M" => "Months", "Y" => "Years", "L" => "Lifetimes", "DAY" => "Days", "WEEK" => "Weeks", "MONTH" => "Months", "YEAR" => "Years", "Lifetime" => "Lifetimes");
|
193 |
+
$term_cycle = $paypal_term_cycles[strtoupper (preg_replace ("/^(.+?) /", "", $term_or_period_term))];
|
194 |
+
}
|
195 |
+
/**/
|
196 |
+
return $term_cycle; /* Return converted value. */
|
197 |
+
}
|
198 |
+
/*
|
199 |
+
Function accepts a period, term, and recurring flag.
|
200 |
+
Returns a full term explanation.
|
201 |
+
Example: 2 months.
|
202 |
+
*/
|
203 |
+
public static function period_term ($period_term = FALSE, $recurring = FALSE)
|
204 |
+
{
|
205 |
+
list ($period, $term) = preg_split ("/ /", ($period_term = strtoupper ($period_term)), 2);
|
206 |
+
$recurring = (strtoupper ($recurring) === "BN") ? (int)0 : (int)$recurring;
|
207 |
+
/**/
|
208 |
+
$cycle_recurring = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "recurring");
|
209 |
+
$cycle_singular = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "singular");
|
210 |
+
$cycle_plural = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "plural");
|
211 |
+
/**/
|
212 |
+
if ($recurring && in_array ($period_term, array ("1 D", "1 W", "2 W", "1 M", "2 M", "3 M", "1 Y")))
|
213 |
+
$period_term = strtolower ($cycle_recurring); /* Results in an "ly" ending. */
|
214 |
+
/**/
|
215 |
+
else if ($recurring) /* Otherwise, it's recurring; but NOT an "ly" ending. */
|
216 |
+
$period_term = strtolower ("every " . $period . " " . $cycle_plural);
|
217 |
+
/**/
|
218 |
+
else if (strtoupper ($term) === "L") /* One-payment for lifetime access. */
|
219 |
+
$period_term = "lifetime"; /* Lifetime only. */
|
220 |
+
/**/
|
221 |
+
else /* Otherwise, this is NOT recurring. Results in X days/weeks/months/years/lifetime. */
|
222 |
+
$period_term = strtolower ($period . " " . ( ($period <> 1) ? $cycle_plural : $cycle_singular));
|
223 |
+
/**/
|
224 |
+
return $period_term; /* Return converted value. */
|
225 |
+
}
|
226 |
+
/*
|
227 |
+
Function accepts a billing amount, period, term, and recurring flag.
|
228 |
+
Returns a full billing term explanation.
|
229 |
+
Example: 1.00 for 2 months.
|
230 |
+
*/
|
231 |
+
public static function amount_period_term ($amount = FALSE, $period_term = FALSE, $recurring = FALSE)
|
232 |
+
{
|
233 |
+
list ($period, $term) = preg_split ("/ /", ($period_term = strtoupper ($period_term)), 2);
|
234 |
+
$recurring = (strtoupper ($recurring) === "BN") ? (int)0 : (int)$recurring;
|
235 |
+
/**/
|
236 |
+
$cycle_recurring = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "recurring");
|
237 |
+
$cycle_singular = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "singular");
|
238 |
+
$cycle_plural = c_ws_plugin__s2member_utils_time::term_cycle ($period_term, "plural");
|
239 |
+
/**/
|
240 |
+
if ($recurring && in_array ($period_term, array ("1 D", "1 W", "2 W", "1 M", "2 M", "3 M", "1 Y")))
|
241 |
+
$amount_period_term = number_format ($amount, 2, ".", "") . " / " . strtolower ($cycle_recurring);
|
242 |
+
/**/
|
243 |
+
else if ($recurring) /* Otherwise, it's recurring; but NOT an "ly" ending. */
|
244 |
+
$amount_period_term = number_format ($amount, 2, ".", "") . " " . strtolower ("every " . $period . " " . $cycle_plural);
|
245 |
+
/**/
|
246 |
+
else if (strtoupper ($term) === "L") /* One-payment for lifetime access. */
|
247 |
+
$amount_period_term = number_format ($amount, 2, ".", ""); /* Price only. */
|
248 |
+
/**/
|
249 |
+
else /* Otherwise, this is NOT recurring. Results in 0.00 for X days/weeks/months/years/lifetime. */
|
250 |
+
$amount_period_term = number_format ($amount, 2, ".", "") . " for " . strtolower ($period . " " . ( ($period <> 1) ? $cycle_plural : $cycle_singular));
|
251 |
+
/**/
|
252 |
+
return $amount_period_term; /* Return converted value. */
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
?>
|
includes/classes/utils-urls.inc.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_urls"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_urls
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function that builds a WordPress® signup URL /wp-signup.php.
|
23 |
+
*/
|
24 |
+
public static function wp_signup_url () /* With Filters. */
|
25 |
+
{
|
26 |
+
return apply_filters ("wp_signup_location", site_url ("/wp-signup.php"));
|
27 |
+
}
|
28 |
+
/*
|
29 |
+
Function that builds a WordPress® registration URL /wp-login.php?action=register.
|
30 |
+
*/
|
31 |
+
public static function wp_register_url ($redirect_to = FALSE)
|
32 |
+
{
|
33 |
+
return add_query_arg ("action", urlencode ("register"), wp_login_url ($redirect_to));
|
34 |
+
}
|
35 |
+
/*
|
36 |
+
Function that handles a remote request.
|
37 |
+
This extends wp_remote_request() through the `WP_Http` class.
|
38 |
+
*/
|
39 |
+
public static function remote ($url = FALSE, $post_vars = FALSE, $args = array ())
|
40 |
+
{
|
41 |
+
static $http_response_filtered = false; /* Filter once. */
|
42 |
+
/**/
|
43 |
+
$args = (!is_array ($args)) ? array (): $args;
|
44 |
+
/**/
|
45 |
+
if (!$http_response_filtered && ($http_response_filtered = true))
|
46 |
+
add_filter ("http_response", "c_ws_plugin__s2member_utils_urls::_remote_gz_variations");
|
47 |
+
/**/
|
48 |
+
if ($url) /* Obviously, we must have a URL to do anything. */
|
49 |
+
{
|
50 |
+
if (preg_match ("/^https/i", $url) && strtolower (substr (PHP_OS, 0, 3)) === "win")
|
51 |
+
add_filter ("use_curl_transport", "__return_false");
|
52 |
+
/**/
|
53 |
+
if ((is_array ($post_vars) || is_string ($post_vars)) && !empty ($post_vars))
|
54 |
+
{
|
55 |
+
$args["method"] = "POST";
|
56 |
+
$args["body"] = $post_vars;
|
57 |
+
}
|
58 |
+
/**/
|
59 |
+
$body = wp_remote_retrieve_body (wp_remote_request ($url, $args));
|
60 |
+
/**/
|
61 |
+
remove_filter ("use_curl_transport", "__return_false");
|
62 |
+
/**/
|
63 |
+
return $body; /* The body content received. */
|
64 |
+
}
|
65 |
+
/**/
|
66 |
+
return false; /* Else return false. */
|
67 |
+
}
|
68 |
+
/*
|
69 |
+
A sort of callback function that filters the WP_Http response for additional gzinflate variations.
|
70 |
+
Attach to: add_filter("http_response");
|
71 |
+
*/
|
72 |
+
public static function _remote_gz_variations ($response = array ())
|
73 |
+
{
|
74 |
+
if (!isset ($response["ws__gz_variations"]) && ($response["ws__gz_variations"] = 1))
|
75 |
+
{
|
76 |
+
if ($response["headers"]["content-encoding"])
|
77 |
+
if (substr ($response["body"], 0, 2) === "\x78\x9c")
|
78 |
+
if (($gz = @gzinflate (substr ($response["body"], 2))))
|
79 |
+
$response["body"] = $gz;
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
return $response; /* Return response. */
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
?>
|
includes/classes/utils-users.inc.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_utils_users"))
|
18 |
+
{
|
19 |
+
class c_ws_plugin__s2member_utils_users
|
20 |
+
{
|
21 |
+
/*
|
22 |
+
Function determines the total Users/Members in the database.
|
23 |
+
*/
|
24 |
+
public static function users_in_database ()
|
25 |
+
{
|
26 |
+
global $wpdb; /* Global database object reference. */
|
27 |
+
/**/
|
28 |
+
$q1 = mysql_query ("SELECT SQL_CALC_FOUND_ROWS `" . $wpdb->users . "`.`ID` FROM `" . $wpdb->users . "`, `" . $wpdb->usermeta . "` WHERE `" . $wpdb->users . "`.`ID` = `" . $wpdb->usermeta . "`.`user_id` AND `" . $wpdb->usermeta . "`.`meta_key` = '" . esc_sql ($wpdb->prefix . "capabilities") . "' LIMIT 1", $wpdb->dbh);
|
29 |
+
$q2 = mysql_query ("SELECT FOUND_ROWS()", $wpdb->dbh);
|
30 |
+
/**/
|
31 |
+
$users = (int)mysql_result ($q2, 0);
|
32 |
+
/**/
|
33 |
+
mysql_free_result($q2);
|
34 |
+
mysql_free_result($q1);
|
35 |
+
/**/
|
36 |
+
return $users;
|
37 |
+
}
|
38 |
+
/*
|
39 |
+
Retrieves a field value. Also supports Custom Fields.
|
40 |
+
*/
|
41 |
+
public static function get_user_field ($field_id = FALSE, $user_id = FALSE)
|
42 |
+
{
|
43 |
+
if (is_object ($user = ($user_id) ? new WP_User ($user_id) : wp_get_current_user ()) && ($user_id = $user->ID))
|
44 |
+
{
|
45 |
+
if (preg_match ("/^(first_name|First Name)$/i", $field_id))
|
46 |
+
return $user->first_name;
|
47 |
+
/**/
|
48 |
+
else if (preg_match ("/^(last_name|Last Name)$/i", $field_id))
|
49 |
+
return $user->last_name;
|
50 |
+
/**/
|
51 |
+
else if (preg_match ("/^(email|E-mail|Email Address|E-mail Address)$/i", $field_id))
|
52 |
+
return $user->user_email;
|
53 |
+
/**/
|
54 |
+
else if (isset ($user->$field_id))
|
55 |
+
return $user->$field_id;
|
56 |
+
/**/
|
57 |
+
else if (is_array ($fields = get_user_option ("s2member_custom_fields", $user_id)))
|
58 |
+
return $fields[preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field_id))];
|
59 |
+
}
|
60 |
+
/**/
|
61 |
+
return false; /* Otherwise, return false. */
|
62 |
+
}
|
63 |
+
/*
|
64 |
+
Get the custom value for an existing Member, referenced by a Subscr. ID.
|
65 |
+
A second lookup parameter can be provided as well ( optional ).
|
66 |
+
*/
|
67 |
+
public static function get_user_custom_with ($subscr_id = FALSE, $os0 = FALSE)
|
68 |
+
{
|
69 |
+
global $wpdb; /* Need global DB obj. */
|
70 |
+
/**/
|
71 |
+
if ($subscr_id && $os0) /* This case includes some additional routines that can use the $os0 value. */
|
72 |
+
{
|
73 |
+
if (($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND (`meta_value` = '" . $wpdb->escape ($subscr_id) . "' OR `meta_value` = '" . $wpdb->escape ($os0) . "') LIMIT 1"))/**/
|
74 |
+
|| ($q = $wpdb->get_row ("SELECT `ID` AS `user_id` FROM `" . $wpdb->users . "` WHERE `ID` = '" . $wpdb->escape ($os0) . "' LIMIT 1")))
|
75 |
+
if (($custom = get_user_option ("s2member_custom", $q->user_id)))
|
76 |
+
return $custom;
|
77 |
+
}
|
78 |
+
else if ($subscr_id) /* Otherwise, if all we have is a Subscr. ID value. */
|
79 |
+
{
|
80 |
+
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))
|
81 |
+
if (($custom = get_user_option ("s2member_custom", $q->user_id)))
|
82 |
+
return $custom;
|
83 |
+
}
|
84 |
+
/**/
|
85 |
+
return false; /* Otherwise, return false. */
|
86 |
+
}
|
87 |
+
/*
|
88 |
+
Get the user ID for an existing Member, referenced by a Subscr. ID.
|
89 |
+
A second lookup parameter can be provided as well ( optional ).
|
90 |
+
*/
|
91 |
+
public static function get_user_id_with ($subscr_id = FALSE, $os0 = FALSE)
|
92 |
+
{
|
93 |
+
global $wpdb; /* Need global DB obj. */
|
94 |
+
/**/
|
95 |
+
if ($subscr_id && $os0) /* This case includes some additional routines that can use the $os0 value. */
|
96 |
+
{
|
97 |
+
if (($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND (`meta_value` = '" . $wpdb->escape ($subscr_id) . "' OR `meta_value` = '" . $wpdb->escape ($os0) . "') LIMIT 1"))/**/
|
98 |
+
|| ($q = $wpdb->get_row ("SELECT `ID` AS `user_id` FROM `" . $wpdb->users . "` WHERE `ID` = '" . $wpdb->escape ($os0) . "' LIMIT 1")))
|
99 |
+
return $q->user_id;
|
100 |
+
}
|
101 |
+
else if ($subscr_id) /* Otherwise, if all we have is a Subscr. ID value. */
|
102 |
+
{
|
103 |
+
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))
|
104 |
+
return $q->user_id;
|
105 |
+
}
|
106 |
+
/**/
|
107 |
+
return false; /* Otherwise, return false. */
|
108 |
+
}
|
109 |
+
/*
|
110 |
+
Get the email value for an existing Member, referenced by a Subscr. ID.
|
111 |
+
A second lookup parameter can be provided as well ( optional ).
|
112 |
+
*/
|
113 |
+
public static function get_user_email_with ($subscr_id = FALSE, $os0 = FALSE)
|
114 |
+
{
|
115 |
+
global $wpdb; /* Need global DB obj. */
|
116 |
+
/**/
|
117 |
+
if ($subscr_id && $os0) /* This case includes some additional routines that can use the $os0 value. */
|
118 |
+
{
|
119 |
+
if (($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND (`meta_value` = '" . $wpdb->escape ($subscr_id) . "' OR `meta_value` = '" . $wpdb->escape ($os0) . "') LIMIT 1"))/**/
|
120 |
+
|| ($q = $wpdb->get_row ("SELECT `ID` AS `user_id` FROM `" . $wpdb->users . "` WHERE `ID` = '" . $wpdb->escape ($os0) . "' LIMIT 1")))
|
121 |
+
if (is_object ($user = new WP_User ($q->user_id)) && ($email = $user->user_email))
|
122 |
+
return $email;
|
123 |
+
}
|
124 |
+
else if ($subscr_id) /* Otherwise, if all we have is a Subscr. ID value. */
|
125 |
+
{
|
126 |
+
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))
|
127 |
+
if (is_object ($user = new WP_User ($q->user_id)) && ($email = $user->user_email))
|
128 |
+
return $email;
|
129 |
+
}
|
130 |
+
/**/
|
131 |
+
return false; /* Otherwise, return false. */
|
132 |
+
}
|
133 |
+
/*
|
134 |
+
Retrieves IPN signup vars & validates their Subscription ID.
|
135 |
+
- The $user_id can be passed in directly;
|
136 |
+
or a lookup can be performed with $subscr_id.
|
137 |
+
*/
|
138 |
+
public static function get_user_ipn_signup_vars ($user_id = FALSE, $subscr_id = FALSE)
|
139 |
+
{
|
140 |
+
if ($user_id || ($subscr_id && ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($subscr_id))) || (!$user_id && !$subscr_id && is_object ($user = wp_get_current_user ()) && ($user_id = $user->ID)))
|
141 |
+
{
|
142 |
+
if (($_subscr_id = get_user_option ("s2member_subscr_id", $user_id)) && (!$subscr_id || $subscr_id === $_subscr_id) && ($subscr_id = $_subscr_id))
|
143 |
+
if (is_array ($ipn_signup_vars = get_user_option ("s2member_ipn_signup_vars", $user_id)))
|
144 |
+
if ($ipn_signup_vars["subscr_id"] === $subscr_id)
|
145 |
+
return $ipn_signup_vars;
|
146 |
+
}
|
147 |
+
/**/
|
148 |
+
return false; /* Otherwise, return false. */
|
149 |
+
}
|
150 |
+
/*
|
151 |
+
Function determines whether or not a Username/Email is already in the database.
|
152 |
+
Returns the WordPress® User ID if they exist.
|
153 |
+
*/
|
154 |
+
public static function user_login_email_exists ($user_login = FALSE, $user_email = FALSE)
|
155 |
+
{
|
156 |
+
global $wpdb; /* Global database object reference. */
|
157 |
+
/**/
|
158 |
+
if ($user_login && $user_email) /* Only if we have both of these. */
|
159 |
+
if (($user_id = $wpdb->get_var ("SELECT `ID` FROM `" . $wpdb->users . "` WHERE `user_login` LIKE '" . esc_sql (like_escape ($user_login)) . "' AND `user_email` LIKE '" . esc_sql (like_escape ($user_email)) . "' LIMIT 1")))
|
160 |
+
return $user_id; /* Return the associated WordPress® ID. */
|
161 |
+
/**/
|
162 |
+
return false; /* Else return false. */
|
163 |
+
}
|
164 |
+
/*
|
165 |
+
Function determines whether or not a Username/Email is already in the database for this Blog.
|
166 |
+
Returns the WordPress® User ID if they exist.
|
167 |
+
*/
|
168 |
+
public static function ms_user_login_email_exists_but_not_on_blog ($user_login = FALSE, $user_email = FALSE, $blog_id = FALSE)
|
169 |
+
{
|
170 |
+
if ($user_login && $user_email) /* Only if we have both of these. */
|
171 |
+
if (is_multisite () && ($user_id = c_ws_plugin__s2member_utils_users::user_login_email_exists ($user_login, $user_email)) && !is_user_member_of_blog ($user_id, $blog_id))
|
172 |
+
return $user_id;
|
173 |
+
/**/
|
174 |
+
return false; /* Else return false. */
|
175 |
+
}
|
176 |
+
/*
|
177 |
+
Function determines whether or not a Username/Email is already in the database for this Blog.
|
178 |
+
Returns the WordPress® User ID if they exist.
|
179 |
+
This is an alias for: `c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog()`.
|
180 |
+
*/
|
181 |
+
public static function ms_user_login_email_can_join_blog ($user_login = FALSE, $user_email = FALSE, $blog_id = FALSE)
|
182 |
+
{
|
183 |
+
return c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email, $blog_id);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
?>
|
includes/codes.inc.php
CHANGED
@@ -17,12 +17,14 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
17 |
Add WordPress® Editor Shortcodes.
|
18 |
http://codex.wordpress.org/Shortcode_API
|
19 |
*/
|
20 |
-
add_shortcode ("s2Get", "
|
21 |
/**/
|
22 |
-
add_shortcode ("s2If", "
|
23 |
-
add_shortcode ("_s2If", "
|
24 |
-
add_shortcode ("__s2If", "
|
25 |
-
add_shortcode ("___s2If", "
|
26 |
/**/
|
27 |
-
add_shortcode ("s2Member-
|
|
|
|
|
28 |
?>
|
17 |
Add WordPress® Editor Shortcodes.
|
18 |
http://codex.wordpress.org/Shortcode_API
|
19 |
*/
|
20 |
+
add_shortcode ("s2Get", "c_ws_plugin__s2member_sc_gets::sc_get_details");
|
21 |
/**/
|
22 |
+
add_shortcode ("s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
|
23 |
+
add_shortcode ("_s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
|
24 |
+
add_shortcode ("__s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
|
25 |
+
add_shortcode ("___s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
|
26 |
/**/
|
27 |
+
add_shortcode ("s2Member-Profile", "c_ws_plugin__s2member_sc_profile::sc_profile");
|
28 |
+
/**/
|
29 |
+
add_shortcode ("s2Member-PayPal-Button", "c_ws_plugin__s2member_sc_paypal_button::sc_paypal_button");
|
30 |
?>
|
includes/funcs.inc.php
CHANGED
@@ -16,9 +16,10 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
16 |
/*
|
17 |
Include all of the functions that came with this plugin.
|
18 |
*/
|
19 |
-
if (is_dir (dirname (__FILE__) . "/functions"))
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
?>
|
16 |
/*
|
17 |
Include all of the functions that came with this plugin.
|
18 |
*/
|
19 |
+
if (is_dir ($ws_plugin__s2member_temp_dir = dirname (__FILE__) . "/functions"))
|
20 |
+
foreach (scandir ($ws_plugin__s2member_temp_dir) as $ws_plugin__s2member_temp_s)
|
21 |
+
if (preg_match ("/\.php$/", $ws_plugin__s2member_temp_s) && !preg_match ("/^index\.php$/i", $ws_plugin__s2member_temp_s))
|
22 |
+
include_once $ws_plugin__s2member_temp_dir . "/" . $ws_plugin__s2member_temp_s;
|
23 |
+
/**/
|
24 |
+
unset ($ws_plugin__s2member_temp_dir, $ws_plugin__s2member_temp_s);
|
25 |
?>
|
includes/functions/activate-deactivate.inc.php
DELETED
@@ -1,337 +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 |
-
Check existing installations that have not been re-activated.
|
18 |
-
Attach to: add_action("admin_init");
|
19 |
-
*/
|
20 |
-
if (!function_exists ("ws_plugin__s2member_check_activation"))
|
21 |
-
{
|
22 |
-
function ws_plugin__s2member_check_activation () /* Up-to-date? */
|
23 |
-
{
|
24 |
-
$v = get_option ("ws_plugin__s2member_activated_version");
|
25 |
-
/**/
|
26 |
-
if (!$v || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
|
27 |
-
{
|
28 |
-
ws_plugin__s2member_activate ();
|
29 |
-
}
|
30 |
-
/**/
|
31 |
-
else if (is_multisite () && is_main_site ())
|
32 |
-
{
|
33 |
-
$mms_v = get_option ("ws_plugin__s2member_activated_mms_version");
|
34 |
-
/**/
|
35 |
-
if (!$mms_v || !version_compare ($mms_v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
|
36 |
-
{
|
37 |
-
ws_plugin__s2member_activate ();
|
38 |
-
}
|
39 |
-
}
|
40 |
-
/**/
|
41 |
-
return; /* Return for uniformity. */
|
42 |
-
}
|
43 |
-
}
|
44 |
-
/*
|
45 |
-
Function for handling activation routines.
|
46 |
-
This function should match the array key for this plugin:
|
47 |
-
ws_plugin__$plugin_key_activate() is called by our themes.
|
48 |
-
|
49 |
-
We also initialize some option values here.
|
50 |
-
Initializing these options will force them to be
|
51 |
-
autoloaded into WordPress® instead of generating
|
52 |
-
extra queries before they are set.
|
53 |
-
*/
|
54 |
-
if (!function_exists ("ws_plugin__s2member_activate"))
|
55 |
-
{
|
56 |
-
function ws_plugin__s2member_activate ()
|
57 |
-
{
|
58 |
-
global $wpdb; /* To update points of origin on a Multisite Network. */
|
59 |
-
global $current_site, $current_blog; /* For Multisite support. */
|
60 |
-
/**/
|
61 |
-
do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
|
62 |
-
/**/
|
63 |
-
add_role ("subscriber", "Subscriber");
|
64 |
-
add_role ("s2member_level1", "s2Member Level 1");
|
65 |
-
add_role ("s2member_level2", "s2Member Level 2");
|
66 |
-
add_role ("s2member_level3", "s2Member Level 3");
|
67 |
-
add_role ("s2member_level4", "s2Member Level 4");
|
68 |
-
/**/
|
69 |
-
if ($role = &get_role ("subscriber"))
|
70 |
-
{
|
71 |
-
$role->add_cap ("read");
|
72 |
-
$role->add_cap ("access_s2member_level0");
|
73 |
-
}
|
74 |
-
/**/
|
75 |
-
if ($role = &get_role ("s2member_level1"))
|
76 |
-
{
|
77 |
-
$role->add_cap ("read");
|
78 |
-
$role->add_cap ("level_0");
|
79 |
-
$role->add_cap ("access_s2member_level0");
|
80 |
-
$role->add_cap ("access_s2member_level1");
|
81 |
-
}
|
82 |
-
/**/
|
83 |
-
if ($role = &get_role ("s2member_level2"))
|
84 |
-
{
|
85 |
-
$role->add_cap ("read");
|
86 |
-
$role->add_cap ("level_0");
|
87 |
-
$role->add_cap ("access_s2member_level0");
|
88 |
-
$role->add_cap ("access_s2member_level1");
|
89 |
-
$role->add_cap ("access_s2member_level2");
|
90 |
-
}
|
91 |
-
/**/
|
92 |
-
if ($role = &get_role ("s2member_level3"))
|
93 |
-
{
|
94 |
-
$role->add_cap ("read");
|
95 |
-
$role->add_cap ("level_0");
|
96 |
-
$role->add_cap ("access_s2member_level0");
|
97 |
-
$role->add_cap ("access_s2member_level1");
|
98 |
-
$role->add_cap ("access_s2member_level2");
|
99 |
-
$role->add_cap ("access_s2member_level3");
|
100 |
-
}
|
101 |
-
/**/
|
102 |
-
if ($role = &get_role ("s2member_level4"))
|
103 |
-
{
|
104 |
-
$role->add_cap ("read");
|
105 |
-
$role->add_cap ("level_0");
|
106 |
-
$role->add_cap ("access_s2member_level0");
|
107 |
-
$role->add_cap ("access_s2member_level1");
|
108 |
-
$role->add_cap ("access_s2member_level2");
|
109 |
-
$role->add_cap ("access_s2member_level3");
|
110 |
-
$role->add_cap ("access_s2member_level4");
|
111 |
-
}
|
112 |
-
/**/
|
113 |
-
if ($role = &get_role ("administrator"))
|
114 |
-
{
|
115 |
-
$role->add_cap ("access_s2member_level0");
|
116 |
-
$role->add_cap ("access_s2member_level1");
|
117 |
-
$role->add_cap ("access_s2member_level2");
|
118 |
-
$role->add_cap ("access_s2member_level3");
|
119 |
-
$role->add_cap ("access_s2member_level4");
|
120 |
-
}
|
121 |
-
/**/
|
122 |
-
if ($role = &get_role ("editor"))
|
123 |
-
{
|
124 |
-
$role->add_cap ("access_s2member_level0");
|
125 |
-
$role->add_cap ("access_s2member_level1");
|
126 |
-
$role->add_cap ("access_s2member_level2");
|
127 |
-
$role->add_cap ("access_s2member_level3");
|
128 |
-
$role->add_cap ("access_s2member_level4");
|
129 |
-
}
|
130 |
-
/**/
|
131 |
-
if ($role = &get_role ("author"))
|
132 |
-
{
|
133 |
-
$role->add_cap ("access_s2member_level0");
|
134 |
-
$role->add_cap ("access_s2member_level1");
|
135 |
-
$role->add_cap ("access_s2member_level2");
|
136 |
-
$role->add_cap ("access_s2member_level3");
|
137 |
-
$role->add_cap ("access_s2member_level4");
|
138 |
-
}
|
139 |
-
/**/
|
140 |
-
if ($role = &get_role ("contributor"))
|
141 |
-
{
|
142 |
-
$role->add_cap ("access_s2member_level0");
|
143 |
-
$role->add_cap ("access_s2member_level1");
|
144 |
-
$role->add_cap ("access_s2member_level2");
|
145 |
-
$role->add_cap ("access_s2member_level3");
|
146 |
-
$role->add_cap ("access_s2member_level4");
|
147 |
-
}
|
148 |
-
/**/
|
149 |
-
if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
150 |
-
if (is_writable (dirname ($files_dir)))
|
151 |
-
mkdir ($files_dir, 0777);
|
152 |
-
/**/
|
153 |
-
if (is_dir ($files_dir) && is_writable ($files_dir))
|
154 |
-
if (!file_exists ($htaccess = $files_dir . "/.htaccess"))
|
155 |
-
file_put_contents ($htaccess, "deny from all");
|
156 |
-
/**/
|
157 |
-
if (!is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
158 |
-
if (is_writable (dirname ($logs_dir)))
|
159 |
-
mkdir ($logs_dir, 0777);
|
160 |
-
/**/
|
161 |
-
if (is_dir ($logs_dir) && is_writable ($logs_dir))
|
162 |
-
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
|
163 |
-
file_put_contents ($htaccess, "deny from all");
|
164 |
-
/**/
|
165 |
-
(!is_array (get_option ("ws_plugin__s2member_cache"))) ? update_option ("ws_plugin__s2member_cache", array ()) : null;
|
166 |
-
(!is_array (get_option ("ws_plugin__s2member_notices"))) ? update_option ("ws_plugin__s2member_notices", array ()) : null;
|
167 |
-
(!is_array (get_option ("ws_plugin__s2member_options"))) ? update_option ("ws_plugin__s2member_options", array ()) : null;
|
168 |
-
(!is_numeric (get_option ("ws_plugin__s2member_configured"))) ? update_option ("ws_plugin__s2member_configured", "0") : null;
|
169 |
-
/**/
|
170 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) /* If already configured, we are re-activating. */
|
171 |
-
{
|
172 |
-
$v = get_option ("ws_plugin__s2member_activated_version");
|
173 |
-
/**/
|
174 |
-
if (!$v || !version_compare ($v, "3.2", ">=")) /* Needs to be upgraded? */
|
175 |
-
/* Version 3.2 is where `meta_key` names were changed. They're prefixed now. */
|
176 |
-
{
|
177 |
-
$like = "`meta_key` LIKE 's2member\_%' AND `meta_key` NOT LIKE '%s2member\_originating\_blog%'";
|
178 |
-
$wpdb->query ("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
|
179 |
-
}
|
180 |
-
/**/
|
181 |
-
if (!$v || !version_compare ($v, "3.2.5", ">=")) /* Needs to be upgraded? */
|
182 |
-
/* Version 3.2.5 is where transient names were changed. They're prefixed now. */
|
183 |
-
{
|
184 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_%'");
|
185 |
-
}
|
186 |
-
/**/
|
187 |
-
if (!$v || !version_compare ($v, "3.2.6", ">=")) /* Needs to be upgraded? */
|
188 |
-
/* Version 3.2.6 fixed `s2member_ccaps_req` being stored empty and/or w/ one empty element in the array. */
|
189 |
-
{
|
190 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
|
191 |
-
}
|
192 |
-
/**/
|
193 |
-
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
|
194 |
-
$notice .= 'You now have version ' . WS_PLUGIN__S2MEMBER_VERSION . '. Your existing configuration remains.';
|
195 |
-
/**/
|
196 |
-
if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) /* No Changelog on a Multisite Farm. */
|
197 |
-
$notice .= '<br />Have fun, <a href="admin.php?page=ws-plugin--s2member-info#rm-changelog">read the Changelog</a>, and make some money! :-)';
|
198 |
-
/**/
|
199 |
-
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
|
200 |
-
}
|
201 |
-
else /* Otherwise, (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide. */
|
202 |
-
{
|
203 |
-
$notice = '<strong>s2Member</strong> v' . WS_PLUGIN__S2MEMBER_VERSION . ' has been <strong>activated</strong>. Nice work!<br />';
|
204 |
-
$notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-start">read the Quick Start Guide</a>, and make some money! :-)';
|
205 |
-
/**/
|
206 |
-
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
|
207 |
-
}
|
208 |
-
/**/
|
209 |
-
update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION); /* Mark version. */
|
210 |
-
/**/
|
211 |
-
if (is_multisite () && is_main_site ()) /* Network activation routines. A few quick adjustments. */
|
212 |
-
{
|
213 |
-
foreach ((array) ($users = $wpdb->get_results ("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user)
|
214 |
-
{
|
215 |
-
/* Here we convert everyone already in the system; without a point of origin.
|
216 |
-
This will set their point of origin to the Main Site ( Dashboard Blog ). */
|
217 |
-
if (! ($originating_blog = get_user_meta ($user->ID, "s2member_originating_blog", true)))
|
218 |
-
update_user_meta ($user->ID, "s2member_originating_blog", $current_site->blog_id);
|
219 |
-
}
|
220 |
-
/**/
|
221 |
-
$notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . WS_PLUGIN__S2MEMBER_VERSION . '.<br />';
|
222 |
-
$notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
|
223 |
-
$notice .= 'In the Dashboard for your Main Site, see:<br /><code>s2Member -> Multisite ( Config )</code>.';
|
224 |
-
/**/
|
225 |
-
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
|
226 |
-
/**/
|
227 |
-
update_option ("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
|
228 |
-
}
|
229 |
-
/**/
|
230 |
-
do_action ("ws_plugin__s2member_after_activation", get_defined_vars ());
|
231 |
-
/**/
|
232 |
-
return; /* Return for uniformity. */
|
233 |
-
}
|
234 |
-
}
|
235 |
-
/*
|
236 |
-
Function for handling de-activation cleanup routines.
|
237 |
-
This function should match the array key for this plugin:
|
238 |
-
ws_plugin__$plugin_key_deactivate() is called by our themes.
|
239 |
-
*/
|
240 |
-
if (!function_exists ("ws_plugin__s2member_deactivate"))
|
241 |
-
{
|
242 |
-
function ws_plugin__s2member_deactivate ()
|
243 |
-
{
|
244 |
-
global $wpdb; /* May need this for database cleaning. */
|
245 |
-
global $current_site, $current_blog; /* For Multisite support. */
|
246 |
-
/**/
|
247 |
-
do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
|
248 |
-
/**/
|
249 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
|
250 |
-
{
|
251 |
-
remove_role ("s2member_level1");
|
252 |
-
remove_role ("s2member_level2");
|
253 |
-
remove_role ("s2member_level3");
|
254 |
-
remove_role ("s2member_level4");
|
255 |
-
/**/
|
256 |
-
if ($role = &get_role ("subscriber"))
|
257 |
-
{
|
258 |
-
$role->remove_cap ("access_s2member_level0");
|
259 |
-
}
|
260 |
-
/**/
|
261 |
-
if ($role = &get_role ("administrator"))
|
262 |
-
{
|
263 |
-
$role->remove_cap ("access_s2member_level0");
|
264 |
-
$role->remove_cap ("access_s2member_level1");
|
265 |
-
$role->remove_cap ("access_s2member_level2");
|
266 |
-
$role->remove_cap ("access_s2member_level3");
|
267 |
-
$role->remove_cap ("access_s2member_level4");
|
268 |
-
}
|
269 |
-
/**/
|
270 |
-
if ($role = &get_role ("editor"))
|
271 |
-
{
|
272 |
-
$role->remove_cap ("access_s2member_level0");
|
273 |
-
$role->remove_cap ("access_s2member_level1");
|
274 |
-
$role->remove_cap ("access_s2member_level2");
|
275 |
-
$role->remove_cap ("access_s2member_level3");
|
276 |
-
$role->remove_cap ("access_s2member_level4");
|
277 |
-
}
|
278 |
-
/**/
|
279 |
-
if ($role = &get_role ("author"))
|
280 |
-
{
|
281 |
-
$role->remove_cap ("access_s2member_level0");
|
282 |
-
$role->remove_cap ("access_s2member_level1");
|
283 |
-
$role->remove_cap ("access_s2member_level2");
|
284 |
-
$role->remove_cap ("access_s2member_level3");
|
285 |
-
$role->remove_cap ("access_s2member_level4");
|
286 |
-
}
|
287 |
-
/**/
|
288 |
-
if ($role = &get_role ("contributor"))
|
289 |
-
{
|
290 |
-
$role->remove_cap ("access_s2member_level0");
|
291 |
-
$role->remove_cap ("access_s2member_level1");
|
292 |
-
$role->remove_cap ("access_s2member_level2");
|
293 |
-
$role->remove_cap ("access_s2member_level3");
|
294 |
-
$role->remove_cap ("access_s2member_level4");
|
295 |
-
}
|
296 |
-
/**/
|
297 |
-
if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
298 |
-
{
|
299 |
-
if (file_exists ($htaccess = $files_dir . "/.htaccess"))
|
300 |
-
if (is_writable ($htaccess))
|
301 |
-
unlink($htaccess);
|
302 |
-
/**/
|
303 |
-
@rmdir($files_dir);
|
304 |
-
}
|
305 |
-
/**/
|
306 |
-
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
307 |
-
{
|
308 |
-
foreach (scandir ($logs_dir) as $log_file)
|
309 |
-
if (is_file ($log_file = $logs_dir . "/" . $log_file))
|
310 |
-
if (is_writable ($log_file))
|
311 |
-
unlink($log_file);
|
312 |
-
/**/
|
313 |
-
@rmdir($logs_dir);
|
314 |
-
}
|
315 |
-
/**/
|
316 |
-
delete_option ("ws_plugin__s2member_cache");
|
317 |
-
delete_option ("ws_plugin__s2member_notices");
|
318 |
-
delete_option ("ws_plugin__s2member_options");
|
319 |
-
delete_option ("ws_plugin__s2member_configured");
|
320 |
-
delete_option ("ws_plugin__s2member_activated_version");
|
321 |
-
delete_option ("ws_plugin__s2member_activated_mms_version");
|
322 |
-
/**/
|
323 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%s2member\_%'");
|
324 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_s2m\_%'");
|
325 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_timeout\_s2m\_%'");
|
326 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` LIKE '%s2member\_%'");
|
327 |
-
$wpdb->query ("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key` LIKE '%s2member\_%'");
|
328 |
-
/**/
|
329 |
-
do_action ("ws_plugin__s2member_during_deactivation", get_defined_vars ());
|
330 |
-
}
|
331 |
-
/**/
|
332 |
-
do_action ("ws_plugin__s2member_after_deactivation", get_defined_vars ());
|
333 |
-
/**/
|
334 |
-
return; /* Return for uniformity. */
|
335 |
-
}
|
336 |
-
}
|
337 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/admin-lockout.inc.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
-
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
-
|
6 |
-
Released under the terms of the GNU General Public License.
|
7 |
-
You should have received a copy of the GNU General Public License,
|
8 |
-
along with this software. In the main directory, see: /licensing/
|
9 |
-
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Direct access denial.
|
13 |
-
*/
|
14 |
-
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Function for handling admin lockouts.
|
18 |
-
Attach to: add_action("admin_init");
|
19 |
-
*/
|
20 |
-
if (!function_exists ("ws_plugin__s2member_admin_lockout"))
|
21 |
-
{
|
22 |
-
function ws_plugin__s2member_admin_lockout () /* Prevents admin access. */
|
23 |
-
{
|
24 |
-
do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
|
25 |
-
/**/
|
26 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] && (!defined ("DOING_AJAX") || !DOING_AJAX) && !current_user_can ("edit_posts"))
|
27 |
-
if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance. */
|
28 |
-
{
|
29 |
-
if ($special_redirection_url = ws_plugin__s2member_login_redirection_url ())
|
30 |
-
wp_redirect($special_redirection_url); /* Special Redirection. */
|
31 |
-
/**/
|
32 |
-
else /* Else we use the Login Welcome Page configured for s2Member. */
|
33 |
-
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
34 |
-
/**/
|
35 |
-
exit (); /* Clean exit. */
|
36 |
-
}
|
37 |
-
/**/
|
38 |
-
do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
|
39 |
-
/**/
|
40 |
-
return; /* Return for uniformity. */
|
41 |
-
}
|
42 |
-
}
|
43 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/admin-notices.inc.php
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
-
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
-
|
6 |
-
Released under the terms of the GNU General Public License.
|
7 |
-
You should have received a copy of the GNU General Public License,
|
8 |
-
along with this software. In the main directory, see: /licensing/
|
9 |
-
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Direct access denial.
|
13 |
-
*/
|
14 |
-
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Function displays an admin notice immediately.
|
18 |
-
*/
|
19 |
-
if (!function_exists ("ws_plugin__s2member_display_admin_notice"))
|
20 |
-
{
|
21 |
-
function ws_plugin__s2member_display_admin_notice ($notice = FALSE, $error = FALSE)
|
22 |
-
{
|
23 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
24 |
-
do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
|
25 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
26 |
-
/**/
|
27 |
-
if ($notice && $error) /* Special format for errors. */
|
28 |
-
{
|
29 |
-
echo '<div class="error fade"><p>' . $notice . '</p></div>';
|
30 |
-
}
|
31 |
-
else if ($notice) /* Otherwise, we just send it as an update notice. */
|
32 |
-
{
|
33 |
-
echo '<div class="updated fade"><p>' . $notice . '</p></div>';
|
34 |
-
}
|
35 |
-
/**/
|
36 |
-
do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
|
37 |
-
/**/
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
/*
|
42 |
-
Function that enqueues admin notices.
|
43 |
-
*/
|
44 |
-
if (!function_exists ("ws_plugin__s2member_enqueue_admin_notice"))
|
45 |
-
{
|
46 |
-
function ws_plugin__s2member_enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE)
|
47 |
-
{
|
48 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
49 |
-
do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
|
50 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
51 |
-
/**/
|
52 |
-
if ($notice && is_string ($notice)) /* If we have a valid string. */
|
53 |
-
{
|
54 |
-
$notices = (array)get_option ("ws_plugin__s2member_notices");
|
55 |
-
/**/
|
56 |
-
array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time));
|
57 |
-
/**/
|
58 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
59 |
-
do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
|
60 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
61 |
-
/**/
|
62 |
-
update_option ("ws_plugin__s2member_notices", ws_plugin__s2member_array_unique ($notices));
|
63 |
-
}
|
64 |
-
/**/
|
65 |
-
do_action ("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
|
66 |
-
/**/
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
/*
|
71 |
-
Function that displays admin notices.
|
72 |
-
Attach to: add_action("admin_notices");
|
73 |
-
*/
|
74 |
-
if (!function_exists ("ws_plugin__s2member_admin_notices"))
|
75 |
-
{
|
76 |
-
function ws_plugin__s2member_admin_notices ()
|
77 |
-
{
|
78 |
-
global $pagenow; /* This holds the current page filename. */
|
79 |
-
/**/
|
80 |
-
do_action ("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
|
81 |
-
/**/
|
82 |
-
if (is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
|
83 |
-
{
|
84 |
-
foreach ($notices as $key => $notice) /* Check time on each notice. */
|
85 |
-
{
|
86 |
-
if (empty ($notice["on_pages"]) || $pagenow === $notice["on_pages"] || in_array ($pagenow, (array)$notice["on_pages"]) || $_GET["page"] === $notice["on_pages"] || in_array ($_GET["page"], (array)$notice["on_pages"]))
|
87 |
-
{
|
88 |
-
if (strtotime ("now") >= $notice["time"]) /* Time to show it? */
|
89 |
-
{
|
90 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
91 |
-
do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
|
92 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
93 |
-
/**/
|
94 |
-
unset ($notices[$key]); /* Clear this notice & display it. */
|
95 |
-
/**/
|
96 |
-
ws_plugin__s2member_display_admin_notice ($notice["notice"], $notice["error"]);
|
97 |
-
/**/
|
98 |
-
do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
/**/
|
103 |
-
$notices = array_merge ($notices); /* Re-index. */
|
104 |
-
/**/
|
105 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
106 |
-
do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
|
107 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
108 |
-
/**/
|
109 |
-
update_option ("ws_plugin__s2member_notices", $notices);
|
110 |
-
}
|
111 |
-
/**/
|
112 |
-
do_action ("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
|
113 |
-
/**/
|
114 |
-
return;
|
115 |
-
}
|
116 |
-
}
|
117 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/api-functions.inc.php
CHANGED
@@ -134,19 +134,19 @@ if (!function_exists ("is_protected_by_s2member"))
|
|
134 |
$__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
|
135 |
$__type = ($__type) ? strtolower ($__type) : "singular";
|
136 |
/**/
|
137 |
-
if ($__type === "category" && ($array =
|
138 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
139 |
/**/
|
140 |
-
else if ($__type === "tag" && ($array =
|
141 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
142 |
/**/
|
143 |
-
else if (($__type === "post" || $__type === "singular") && ($array =
|
144 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
145 |
/**/
|
146 |
-
else if (($__type === "page" || $__type === "singular") && ($array =
|
147 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
148 |
/**/
|
149 |
-
else if ($__type === "uri" && ($array =
|
150 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
151 |
/**/
|
152 |
return false;
|
@@ -169,19 +169,19 @@ if (!function_exists ("is_permitted_by_s2member"))
|
|
169 |
$__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
|
170 |
$__type = ($__type) ? strtolower ($__type) : "singular";
|
171 |
/**/
|
172 |
-
if ($__type === "category" &&
|
173 |
return false;
|
174 |
/**/
|
175 |
-
else if ($__type === "tag" &&
|
176 |
return false;
|
177 |
/**/
|
178 |
-
else if (($__type === "post" || $__type === "singular") &&
|
179 |
return false;
|
180 |
/**/
|
181 |
-
else if (($__type === "page" || $__type === "singular") &&
|
182 |
return false;
|
183 |
/**/
|
184 |
-
else if ($__type === "uri" &&
|
185 |
return false;
|
186 |
/**/
|
187 |
return true;
|
@@ -199,7 +199,7 @@ if (!function_exists ("is_category_protected_by_s2member"))
|
|
199 |
{
|
200 |
function is_category_protected_by_s2member ($cat_id = FALSE, $check_user = FALSE)
|
201 |
{
|
202 |
-
if ($cat_id && ($array =
|
203 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
204 |
/**/
|
205 |
return false;
|
@@ -216,7 +216,7 @@ if (!function_exists ("is_category_permitted_by_s2member"))
|
|
216 |
{
|
217 |
function is_category_permitted_by_s2member ($cat_id = FALSE)
|
218 |
{
|
219 |
-
if ($cat_id &&
|
220 |
return false;
|
221 |
/**/
|
222 |
return true;
|
@@ -234,7 +234,7 @@ if (!function_exists ("is_tag_protected_by_s2member"))
|
|
234 |
{
|
235 |
function is_tag_protected_by_s2member ($tag_id_slug_or_name = FALSE, $check_user = FALSE)
|
236 |
{
|
237 |
-
if ($tag_id_slug_or_name && ($array =
|
238 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
239 |
/**/
|
240 |
return false;
|
@@ -251,7 +251,7 @@ if (!function_exists ("is_tag_permitted_by_s2member"))
|
|
251 |
{
|
252 |
function is_tag_permitted_by_s2member ($tag_id_slug_or_name = FALSE)
|
253 |
{
|
254 |
-
if ($tag_id_slug_or_name &&
|
255 |
return false;
|
256 |
/**/
|
257 |
return true;
|
@@ -269,7 +269,7 @@ if (!function_exists ("is_post_protected_by_s2member"))
|
|
269 |
{
|
270 |
function is_post_protected_by_s2member ($post_id = FALSE, $check_user = FALSE)
|
271 |
{
|
272 |
-
if ($post_id && ($array =
|
273 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
274 |
/**/
|
275 |
return false;
|
@@ -286,7 +286,7 @@ if (!function_exists ("is_post_permitted_by_s2member"))
|
|
286 |
{
|
287 |
function is_post_permitted_by_s2member ($post_id = FALSE)
|
288 |
{
|
289 |
-
if ($post_id &&
|
290 |
return false;
|
291 |
/**/
|
292 |
return true;
|
@@ -304,7 +304,7 @@ if (!function_exists ("is_page_protected_by_s2member"))
|
|
304 |
{
|
305 |
function is_page_protected_by_s2member ($page_id = FALSE, $check_user = FALSE)
|
306 |
{
|
307 |
-
if ($page_id && ($array =
|
308 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
309 |
/**/
|
310 |
return false;
|
@@ -321,7 +321,7 @@ if (!function_exists ("is_page_permitted_by_s2member"))
|
|
321 |
{
|
322 |
function is_page_permitted_by_s2member ($page_id = FALSE)
|
323 |
{
|
324 |
-
if ($page_id &&
|
325 |
return false;
|
326 |
/**/
|
327 |
return true;
|
@@ -350,7 +350,7 @@ if (!function_exists ("is_uri_protected_by_s2member"))
|
|
350 |
{
|
351 |
function is_uri_protected_by_s2member ($uri_or_full_url = FALSE, $check_user = FALSE)
|
352 |
{
|
353 |
-
if ($uri_or_full_url && ($array =
|
354 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
355 |
/**/
|
356 |
return false;
|
@@ -378,7 +378,7 @@ if (!function_exists ("is_uri_permitted_by_s2member"))
|
|
378 |
{
|
379 |
function is_uri_permitted_by_s2member ($uri_or_full_url = FALSE)
|
380 |
{
|
381 |
-
if ($uri_or_full_url &&
|
382 |
return false;
|
383 |
/**/
|
384 |
return true;
|
@@ -394,8 +394,8 @@ if (!function_exists ("attach_s2member_query_filters"))
|
|
394 |
{
|
395 |
function attach_s2member_query_filters ()
|
396 |
{
|
397 |
-
remove_action ("pre_get_posts", "
|
398 |
-
add_action ("pre_get_posts", "
|
399 |
}
|
400 |
}
|
401 |
/*
|
@@ -407,8 +407,8 @@ if (!function_exists ("detach_s2member_query_filters"))
|
|
407 |
{
|
408 |
function detach_s2member_query_filters ()
|
409 |
{
|
410 |
-
remove_action ("pre_get_posts", "
|
411 |
-
add_action ("pre_get_posts", "
|
412 |
}
|
413 |
}
|
414 |
/*
|
@@ -426,7 +426,7 @@ if (!function_exists ("s2member_file_download_key"))
|
|
426 |
{
|
427 |
function s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
|
428 |
{
|
429 |
-
return
|
430 |
}
|
431 |
}
|
432 |
/*
|
@@ -437,7 +437,7 @@ if (!function_exists ("s2member_registration_time"))
|
|
437 |
{
|
438 |
function s2member_registration_time ($user_id = FALSE)
|
439 |
{
|
440 |
-
return
|
441 |
}
|
442 |
}
|
443 |
/*
|
@@ -461,7 +461,7 @@ if (!function_exists ("s2member_paid_registration_time"))
|
|
461 |
{
|
462 |
function s2member_paid_registration_time ($level = FALSE, $user_id = FALSE)
|
463 |
{
|
464 |
-
return
|
465 |
}
|
466 |
}
|
467 |
/*
|
@@ -473,7 +473,7 @@ if (!function_exists ("get_user_field"))
|
|
473 |
{
|
474 |
function get_user_field ($field_id = FALSE, $user_id = FALSE)
|
475 |
{
|
476 |
-
return
|
477 |
}
|
478 |
}
|
479 |
?>
|
134 |
$__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
|
135 |
$__type = ($__type) ? strtolower ($__type) : "singular";
|
136 |
/**/
|
137 |
+
if ($__type === "category" && ($array = c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access ($__id, $check_user)))
|
138 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
139 |
/**/
|
140 |
+
else if ($__type === "tag" && ($array = c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access ($__id, $check_user)))
|
141 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
142 |
/**/
|
143 |
+
else if (($__type === "post" || $__type === "singular") && ($array = c_ws_plugin__s2member_posts_sp::check_specific_post_level_access ($__id, $check_user)))
|
144 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
145 |
/**/
|
146 |
+
else if (($__type === "page" || $__type === "singular") && ($array = c_ws_plugin__s2member_pages_sp::check_specific_page_level_access ($__id, $check_user)))
|
147 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
148 |
/**/
|
149 |
+
else if ($__type === "uri" && ($array = c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access ($__id, $check_user)))
|
150 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
151 |
/**/
|
152 |
return false;
|
169 |
$__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
|
170 |
$__type = ($__type) ? strtolower ($__type) : "singular";
|
171 |
/**/
|
172 |
+
if ($__type === "category" && c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access ($__id, true))
|
173 |
return false;
|
174 |
/**/
|
175 |
+
else if ($__type === "tag" && c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access ($__id, true))
|
176 |
return false;
|
177 |
/**/
|
178 |
+
else if (($__type === "post" || $__type === "singular") && c_ws_plugin__s2member_posts_sp::check_specific_post_level_access ($__id, true))
|
179 |
return false;
|
180 |
/**/
|
181 |
+
else if (($__type === "page" || $__type === "singular") && c_ws_plugin__s2member_pages_sp::check_specific_page_level_access ($__id, true))
|
182 |
return false;
|
183 |
/**/
|
184 |
+
else if ($__type === "uri" && c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access ($__id, true))
|
185 |
return false;
|
186 |
/**/
|
187 |
return true;
|
199 |
{
|
200 |
function is_category_protected_by_s2member ($cat_id = FALSE, $check_user = FALSE)
|
201 |
{
|
202 |
+
if ($cat_id && ($array = c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access ($cat_id, $check_user)))
|
203 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
204 |
/**/
|
205 |
return false;
|
216 |
{
|
217 |
function is_category_permitted_by_s2member ($cat_id = FALSE)
|
218 |
{
|
219 |
+
if ($cat_id && c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access ($cat_id, true))
|
220 |
return false;
|
221 |
/**/
|
222 |
return true;
|
234 |
{
|
235 |
function is_tag_protected_by_s2member ($tag_id_slug_or_name = FALSE, $check_user = FALSE)
|
236 |
{
|
237 |
+
if ($tag_id_slug_or_name && ($array = c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access ($tag_id_slug_or_name, $check_user)))
|
238 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
239 |
/**/
|
240 |
return false;
|
251 |
{
|
252 |
function is_tag_permitted_by_s2member ($tag_id_slug_or_name = FALSE)
|
253 |
{
|
254 |
+
if ($tag_id_slug_or_name && c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access ($tag_id_slug_or_name, true))
|
255 |
return false;
|
256 |
/**/
|
257 |
return true;
|
269 |
{
|
270 |
function is_post_protected_by_s2member ($post_id = FALSE, $check_user = FALSE)
|
271 |
{
|
272 |
+
if ($post_id && ($array = c_ws_plugin__s2member_posts_sp::check_specific_post_level_access ($post_id, $check_user)))
|
273 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
274 |
/**/
|
275 |
return false;
|
286 |
{
|
287 |
function is_post_permitted_by_s2member ($post_id = FALSE)
|
288 |
{
|
289 |
+
if ($post_id && c_ws_plugin__s2member_posts_sp::check_specific_post_level_access ($post_id, true))
|
290 |
return false;
|
291 |
/**/
|
292 |
return true;
|
304 |
{
|
305 |
function is_page_protected_by_s2member ($page_id = FALSE, $check_user = FALSE)
|
306 |
{
|
307 |
+
if ($page_id && ($array = c_ws_plugin__s2member_pages_sp::check_specific_page_level_access ($page_id, $check_user)))
|
308 |
return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
|
309 |
/**/
|
310 |
return false;
|
321 |
{
|
322 |
function is_page_permitted_by_s2member ($page_id = FALSE)
|
323 |
{
|
324 |
+
if ($page_id && c_ws_plugin__s2member_pages_sp::check_specific_page_level_access ($page_id, true))
|
325 |
return false;
|
326 |
/**/
|
327 |
return true;
|
350 |
{
|
351 |
function is_uri_protected_by_s2member ($uri_or_full_url = FALSE, $check_user = FALSE)
|
352 |
{
|
353 |
+
if ($uri_or_full_url && ($array = c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access ($uri_or_full_url, $check_user)))
|
354 |
return $array; /* A non-empty array with ["s2member_level_req"]. */
|
355 |
/**/
|
356 |
return false;
|
378 |
{
|
379 |
function is_uri_permitted_by_s2member ($uri_or_full_url = FALSE)
|
380 |
{
|
381 |
+
if ($uri_or_full_url && c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access ($uri_or_full_url, true))
|
382 |
return false;
|
383 |
/**/
|
384 |
return true;
|
394 |
{
|
395 |
function attach_s2member_query_filters ()
|
396 |
{
|
397 |
+
remove_action ("pre_get_posts", "c_ws_plugin__s2member_security::security_gate_query", 20);
|
398 |
+
add_action ("pre_get_posts", "c_ws_plugin__s2member_querys::force_query_level_access", 20);
|
399 |
}
|
400 |
}
|
401 |
/*
|
407 |
{
|
408 |
function detach_s2member_query_filters ()
|
409 |
{
|
410 |
+
remove_action ("pre_get_posts", "c_ws_plugin__s2member_querys::force_query_level_access", 20);
|
411 |
+
add_action ("pre_get_posts", "c_ws_plugin__s2member_security::security_gate_query", 20);
|
412 |
}
|
413 |
}
|
414 |
/*
|
426 |
{
|
427 |
function s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
|
428 |
{
|
429 |
+
return c_ws_plugin__s2member_files::file_download_key ($file, $cache_compatible);
|
430 |
}
|
431 |
}
|
432 |
/*
|
437 |
{
|
438 |
function s2member_registration_time ($user_id = FALSE)
|
439 |
{
|
440 |
+
return c_ws_plugin__s2member_registration_times::registration_time ($user_id);
|
441 |
}
|
442 |
}
|
443 |
/*
|
461 |
{
|
462 |
function s2member_paid_registration_time ($level = FALSE, $user_id = FALSE)
|
463 |
{
|
464 |
+
return c_ws_plugin__s2member_registration_times::paid_registration_time ($level, $user_id);
|
465 |
}
|
466 |
}
|
467 |
/*
|
473 |
{
|
474 |
function get_user_field ($field_id = FALSE, $user_id = FALSE)
|
475 |
{
|
476 |
+
return c_ws_plugin__s2member_utils_users::get_user_field ($field_id, $user_id);
|
477 |
}
|
478 |
}
|
479 |
?>
|
includes/functions/auto-eots.inc.php
DELETED
@@ -1,259 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
-
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
-
|
6 |
-
Released under the terms of the GNU General Public License.
|
7 |
-
You should have received a copy of the GNU General Public License,
|
8 |
-
along with this software. In the main directory, see: /licensing/
|
9 |
-
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Direct access denial.
|
13 |
-
*/
|
14 |
-
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Function processed by WP-Cron. This handles Auto-EOTs.
|
18 |
-
|
19 |
-
If you have a HUGE userbase, increase the max EOTS per process.
|
20 |
-
~ But NOTE, this runs $per_process ( per Blog ) on a Multisite Network.
|
21 |
-
To increase, use: add_filter ("ws_plugin__s2member_auto_eot_system_per_process");
|
22 |
-
|
23 |
-
s2Member v3.2 ( VERY IMPORTANT ).
|
24 |
-
AND `meta_value` != ''
|
25 |
-
Because update_user_option() may NOT always delete the key.
|
26 |
-
*/
|
27 |
-
if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
|
28 |
-
{
|
29 |
-
function ws_plugin__s2member_auto_eot_system ($per_process = 10)
|
30 |
-
{
|
31 |
-
global $wpdb; /* Need global DB obj. */
|
32 |
-
global $current_site, $current_blog; /* Multisite. */
|
33 |
-
/**/
|
34 |
-
include_once ABSPATH . "wp-admin/includes/admin.php";
|
35 |
-
/**/
|
36 |
-
do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
|
37 |
-
/**/
|
38 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* Enabled? */
|
39 |
-
{
|
40 |
-
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
|
41 |
-
/**/
|
42 |
-
if (is_array ($eots = $wpdb->get_results ("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . $wpdb->escape (strtotime ("now")) . "' LIMIT " . $per_process)))
|
43 |
-
{
|
44 |
-
foreach ($eots as $eot) /* Go through the array of EOTS. We need to (demote|delete) each of them. */
|
45 |
-
{
|
46 |
-
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
47 |
-
{
|
48 |
-
delete_user_option ($user_id, "s2member_auto_eot_time"); /* ALWAYS delete this. */
|
49 |
-
/**/
|
50 |
-
if (!$user->has_cap ("administrator")) /* Do NOT process Administrator accounts. */
|
51 |
-
{
|
52 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
53 |
-
{
|
54 |
-
$custom = get_user_option ("s2member_custom", $user_id);
|
55 |
-
$subscr_id = get_user_option ("s2member_subscr_id", $user_id);
|
56 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
57 |
-
/**/
|
58 |
-
$demotion_role = ws_plugin__s2member_force_demotion_role ("subscriber");
|
59 |
-
$user->set_role ($demotion_role); /* Defaults to Free Subscriber. */
|
60 |
-
/**/
|
61 |
-
foreach ($user->allcaps as $cap => $cap_enabled)
|
62 |
-
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
63 |
-
$user->remove_cap ($ccap = $cap);
|
64 |
-
/**/
|
65 |
-
delete_user_option ($user_id, "s2member_custom");
|
66 |
-
delete_user_option ($user_id, "s2member_subscr_id");
|
67 |
-
/**/
|
68 |
-
if (!apply_filters ("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars ()))
|
69 |
-
delete_user_option ($user_id, "s2member_paid_registration_times");
|
70 |
-
/**/
|
71 |
-
delete_user_option ($user_id, "s2member_last_payment_time");
|
72 |
-
delete_user_option ($user_id, "s2member_auto_eot_time");
|
73 |
-
/**/
|
74 |
-
delete_user_option ($user_id, "s2member_file_download_access_arc");
|
75 |
-
delete_user_option ($user_id, "s2member_file_download_access_log");
|
76 |
-
/**/
|
77 |
-
ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
78 |
-
/**/
|
79 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
80 |
-
{
|
81 |
-
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
|
82 |
-
/**/
|
83 |
-
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($subscr_id)), $url)))
|
84 |
-
if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
|
85 |
-
if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
|
86 |
-
if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
|
87 |
-
if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_login)), $url)))
|
88 |
-
if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
|
89 |
-
{
|
90 |
-
if (is_array ($fields) && !empty ($fields))
|
91 |
-
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
92 |
-
if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", ws_plugin__s2member_esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
93 |
-
break;
|
94 |
-
/**/
|
95 |
-
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
96 |
-
ws_plugin__s2member_remote ($url);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
/**/
|
100 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
101 |
-
{
|
102 |
-
ws_plugin__s2member_email_config_release (); /* Release all Filters applied to wp_mail() From: headers. */
|
103 |
-
/**/
|
104 |
-
$msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
|
105 |
-
$msg .= "\n\n"; /* Spacing in the message body. */
|
106 |
-
/**/
|
107 |
-
$msg .= "subscr_id: %%subscr_id%%\n";
|
108 |
-
$msg .= "user_first_name: %%user_first_name%%\n";
|
109 |
-
$msg .= "user_last_name: %%user_last_name%%\n";
|
110 |
-
$msg .= "user_full_name: %%user_full_name%%\n";
|
111 |
-
$msg .= "user_email: %%user_email%%\n";
|
112 |
-
$msg .= "user_login: %%user_login%%\n";
|
113 |
-
$msg .= "user_id: %%user_id%%\n";
|
114 |
-
/**/
|
115 |
-
if (is_array ($fields) && !empty ($fields))
|
116 |
-
foreach ($fields as $var => $val)
|
117 |
-
$msg .= $var . ": %%" . $var . "%%\n";
|
118 |
-
/**/
|
119 |
-
$msg .= "cv0: %%cv0%%\n";
|
120 |
-
$msg .= "cv1: %%cv1%%\n";
|
121 |
-
$msg .= "cv2: %%cv2%%\n";
|
122 |
-
$msg .= "cv3: %%cv3%%\n";
|
123 |
-
$msg .= "cv4: %%cv4%%\n";
|
124 |
-
$msg .= "cv5: %%cv5%%\n";
|
125 |
-
$msg .= "cv6: %%cv6%%\n";
|
126 |
-
$msg .= "cv7: %%cv7%%\n";
|
127 |
-
$msg .= "cv8: %%cv8%%\n";
|
128 |
-
$msg .= "cv9: %%cv9%%";
|
129 |
-
/**/
|
130 |
-
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($subscr_id), $msg)))
|
131 |
-
if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($user->last_name), $msg)))
|
132 |
-
if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
133 |
-
if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($user->user_email), $msg)))
|
134 |
-
if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($user->user_login), $msg)))
|
135 |
-
if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
|
136 |
-
{
|
137 |
-
if (is_array ($fields) && !empty ($fields))
|
138 |
-
foreach ($fields as $var => $val) /* Custom Registration Fields. */
|
139 |
-
if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", ws_plugin__s2member_esc_ds (maybe_serialize ($val)), $msg)))
|
140 |
-
break;
|
141 |
-
/**/
|
142 |
-
if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
143 |
-
foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
|
144 |
-
($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;
|
145 |
-
}
|
146 |
-
}
|
147 |
-
/**/
|
148 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
149 |
-
do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
|
150 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
151 |
-
}
|
152 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
153 |
-
{
|
154 |
-
if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
|
155 |
-
{
|
156 |
-
remove_user_from_blog ($user_id, $current_blog->blog_id);
|
157 |
-
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
158 |
-
ws_plugin__s2member_handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
|
159 |
-
}
|
160 |
-
/**/
|
161 |
-
else /* Otherwise, we can actually delete them. */
|
162 |
-
/* This will automatically trigger `eot_del_notification_urls` as well. */
|
163 |
-
wp_delete_user ($user_id); /* `ws_plugin__s2member_handle_user_deletions()` */
|
164 |
-
/**/
|
165 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
166 |
-
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
167 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
168 |
-
}
|
169 |
-
/**/
|
170 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
171 |
-
do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
|
172 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
}
|
178 |
-
/**/
|
179 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
180 |
-
do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
|
181 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
182 |
-
/**/
|
183 |
-
return;
|
184 |
-
}
|
185 |
-
}
|
186 |
-
/*
|
187 |
-
This function allows the Auto-EOT Sytem to be
|
188 |
-
processed through a server-side Cron Job.
|
189 |
-
Attach to: add_action("init");
|
190 |
-
*/
|
191 |
-
if (!function_exists ("ws_plugin__s2member_auto_eot_system_via_cron"))
|
192 |
-
{
|
193 |
-
function ws_plugin__s2member_auto_eot_system_via_cron ()
|
194 |
-
{
|
195 |
-
do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
|
196 |
-
/**/
|
197 |
-
if ($_GET["s2member_auto_eot_system_via_cron"]) /* Being called through HTTP? */
|
198 |
-
{
|
199 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
200 |
-
{
|
201 |
-
ws_plugin__s2member_auto_eot_system ();
|
202 |
-
/**/
|
203 |
-
do_action ("ws_plugin__s2member_during_auto_eot_system_via_cron", get_defined_vars ());
|
204 |
-
}
|
205 |
-
/**/
|
206 |
-
exit ();
|
207 |
-
}
|
208 |
-
/**/
|
209 |
-
do_action ("ws_plugin__s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
210 |
-
}
|
211 |
-
}
|
212 |
-
/*
|
213 |
-
Adds a scheduled task for s2Member's Auto-EOT System.
|
214 |
-
*/
|
215 |
-
if (!function_exists ("ws_plugin__s2member_add_auto_eot_system"))
|
216 |
-
{
|
217 |
-
function ws_plugin__s2member_add_auto_eot_system ()
|
218 |
-
{
|
219 |
-
do_action ("ws_plugin__s2member_before_add_auto_eot_system", get_defined_vars ());
|
220 |
-
/**/
|
221 |
-
if (!ws_plugin__s2member_delete_auto_eot_system ())
|
222 |
-
{
|
223 |
-
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
224 |
-
}
|
225 |
-
else if (function_exists ("wp_cron")) /* Otherwise, we can schedule. */
|
226 |
-
{
|
227 |
-
wp_schedule_event (time (), "every10m", "ws_plugin__s2member_auto_eot_system__schedule");
|
228 |
-
/**/
|
229 |
-
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", true, get_defined_vars ());
|
230 |
-
}
|
231 |
-
else /* Otherwise, it would appear that WP-Cron is not available. */
|
232 |
-
{
|
233 |
-
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
234 |
-
}
|
235 |
-
}
|
236 |
-
}
|
237 |
-
/*
|
238 |
-
Delete scheduled tasks for s2Member's Auto-EOT System.
|
239 |
-
*/
|
240 |
-
if (!function_exists ("ws_plugin__s2member_delete_auto_eot_system"))
|
241 |
-
{
|
242 |
-
function ws_plugin__s2member_delete_auto_eot_system ()
|
243 |
-
{
|
244 |
-
do_action ("ws_plugin__s2member_before_delete_auto_eot_system", get_defined_vars ());
|
245 |
-
/**/
|
246 |
-
if (function_exists ("wp_cron"))
|
247 |
-
{
|
248 |
-
wp_clear_scheduled_hook ("s2member_auto_eot_system"); /* This is for backward compatibility. */
|
249 |
-
wp_clear_scheduled_hook ("ws_plugin__s2member_auto_eot_system__schedule"); /* Since v3.0.3. */
|
250 |
-
/**/
|
251 |
-
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
|
252 |
-
}
|
253 |
-
else /* Otherwise, it would appear that WP-Cron is not available. */
|
254 |
-
{
|
255 |
-
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
|
256 |
-
}
|
257 |
-
}
|
258 |
-
}
|
259 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/catg-level-access.inc.php
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
-
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
-
|
6 |
-
Released under the terms of the GNU General Public License.
|
7 |
-
You should have received a copy of the GNU General Public License,
|
8 |
-
along with this software. In the main directory, see: /licensing/
|
9 |
-
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Direct access denial.
|
13 |
-
*/
|
14 |
-
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Function for handling Category Level Access permissions.
|
18 |
-
Attach to: add_action("template_redirect");
|
19 |
-
|
20 |
-
Don't call this function directly, use one of these API functions:
|
21 |
-
|
22 |
-
Is it protected by s2Member at all?
|
23 |
-
- is_category_protected_by_s2member($cat_id);
|
24 |
-
- is_protected_by_s2member($cat_id, "category");
|
25 |
-
|
26 |
-
Is the current User permitted/authorized?
|
27 |
-
- is_category_permitted_by_s2member($cat_id);
|
28 |
-
- is_permitted_by_s2member($cat_id, "category");
|
29 |
-
|
30 |
-
see: `/s2member/includes/functions/api-functions.inc.php`.
|
31 |
-
*/
|
32 |
-
if (!function_exists ("ws_plugin__s2member_check_catg_level_access"))
|
33 |
-
{
|
34 |
-
function ws_plugin__s2member_check_catg_level_access ()
|
35 |
-
{
|
36 |
-
global $post; /* get_the_ID() is NOT available outside The Loop. */
|
37 |
-
/**/
|
38 |
-
do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
|
39 |
-
/**/
|
40 |
-
$excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
41 |
-
/**/
|
42 |
-
if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
43 |
-
{
|
44 |
-
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
45 |
-
/**/
|
46 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
|
47 |
-
{
|
48 |
-
wp_redirect (add_query_arg (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 ()));
|
49 |
-
exit ();
|
50 |
-
}
|
51 |
-
else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
|
52 |
-
{
|
53 |
-
for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
|
54 |
-
{
|
55 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
56 |
-
{
|
57 |
-
wp_redirect (add_query_arg (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 ()));
|
58 |
-
exit ();
|
59 |
-
}
|
60 |
-
/**/
|
61 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
62 |
-
{
|
63 |
-
wp_redirect (add_query_arg (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 ()));
|
64 |
-
exit ();
|
65 |
-
}
|
66 |
-
/**/
|
67 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
|
68 |
-
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
|
69 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
70 |
-
{
|
71 |
-
wp_redirect (add_query_arg (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 ()));
|
72 |
-
exit ();
|
73 |
-
}
|
74 |
-
}
|
75 |
-
/**/
|
76 |
-
for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
|
77 |
-
{
|
78 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
|
79 |
-
foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
|
80 |
-
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
|
81 |
-
{
|
82 |
-
wp_redirect (add_query_arg (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 ()));
|
83 |
-
exit ();
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
/**/
|
88 |
-
do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
|
89 |
-
}
|
90 |
-
/**/
|
91 |
-
do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
|
92 |
-
/**/
|
93 |
-
return; /* For uniformity. */
|
94 |
-
}
|
95 |
-
}
|
96 |
-
/*
|
97 |
-
Function checks Category Level Access permissions- for a specific Category.
|
98 |
-
|
99 |
-
Don't call this function directly, use one of these API functions:
|
100 |
-
|
101 |
-
Is it protected by s2Member at all?
|
102 |
-
- is_category_protected_by_s2member($cat_id);
|
103 |
-
- is_protected_by_s2member($cat_id, "category");
|
104 |
-
|
105 |
-
Is the current User permitted/authorized?
|
106 |
-
- is_category_permitted_by_s2member($cat_id);
|
107 |
-
- is_permitted_by_s2member($cat_id, "category");
|
108 |
-
|
109 |
-
see: `/s2member/includes/functions/api-functions.inc.php`.
|
110 |
-
*/
|
111 |
-
if (!function_exists ("ws_plugin__s2member_check_specific_catg_level_access"))
|
112 |
-
{
|
113 |
-
function ws_plugin__s2member_check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
|
114 |
-
{
|
115 |
-
do_action ("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars ());
|
116 |
-
/**/
|
117 |
-
$excluded = apply_filters ("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars ());
|
118 |
-
/**/
|
119 |
-
if (!$excluded && $cat_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
|
120 |
-
{
|
121 |
-
$cat_link = get_category_link ($cat_id); /* Determine link to this Category. */
|
122 |
-
$cat_path = parse_url ($cat_link, PHP_URL_PATH); /* Parse req path. */
|
123 |
-
$cat_query = parse_url ($cat_link, PHP_URL_QUERY); /* Parse query. */
|
124 |
-
$cat_uri = ($cat_query) ? $cat_path . "?" . $cat_query : $cat_path;
|
125 |
-
/**/
|
126 |
-
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
|
127 |
-
/**/
|
128 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
|
129 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
130 |
-
/**/
|
131 |
-
else if (!ws_plugin__s2member_is_systematic_use_specific_page (null, $cat_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
|
132 |
-
{
|
133 |
-
for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
|
134 |
-
{
|
135 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
|
136 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
|
137 |
-
/**/
|
138 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
|
139 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
|
140 |
-
/**/
|
141 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
|
142 |
-
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
|
143 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
|
144 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
|
145 |
-
}
|
146 |
-
/**/
|
147 |
-
for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
|
148 |
-
{
|
149 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
|
150 |
-
foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
|
151 |
-
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
|
152 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
|
153 |
-
}
|
154 |
-
}
|
155 |
-
/**/
|
156 |
-
do_action ("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars ());
|
157 |
-
}
|
158 |
-
/**/
|
159 |
-
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars ());
|
160 |
-
}
|
161 |
-
}
|
162 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/class-autoloader.inc.php
ADDED
@@ -0,0 +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 |
+
The __autoload function for s2Member classes.
|
18 |
+
This highly optimizes s2Member. Giving it a much smaller footprint.
|
19 |
+
See: http://www.php.net/manual/en/function.spl-autoload-register.php
|
20 |
+
*/
|
21 |
+
if (!function_exists ("ws_plugin__s2member_classes")) /* Already exists? */
|
22 |
+
{
|
23 |
+
function ws_plugin__s2member_classes ($class = FALSE) /* Build dynamic __autoload function. */
|
24 |
+
{
|
25 |
+
static $c; /* Holds the classes directory location ( location is optimized with a static var ). */
|
26 |
+
static $class_dirs; /* All possible class directory locations ( optimized with a static var ). */
|
27 |
+
/**/
|
28 |
+
$c = (!isset ($c)) ? dirname (dirname (__FILE__)) . "/classes" : $c; /* Configures location of classes. */
|
29 |
+
/**/
|
30 |
+
$class_dirs = (!isset ($class_dirs)) ? array_merge (array ($c), _ws_plugin__s2member_classes_glob_dirs_r ($c)) : $class_dirs;
|
31 |
+
/**/
|
32 |
+
if (strpos ($class, "c_ws_plugin__s2member_") === 0 && strpos ($class, "c_ws_plugin__s2member_pro_") === false)
|
33 |
+
{
|
34 |
+
$class = str_replace ("_", "-", str_replace ("c_ws_plugin__s2member_", "", $class));
|
35 |
+
/**/
|
36 |
+
foreach ($class_dirs as $class_dir) /* Start looking for the class. */
|
37 |
+
{
|
38 |
+
if ($class_dir === $c || strpos ($class, basename ($class_dir)) === 0)
|
39 |
+
if (file_exists ($class_dir . "/" . $class . ".inc.php"))
|
40 |
+
{
|
41 |
+
include_once $class_dir . "/" . $class . ".inc.php";
|
42 |
+
/**/
|
43 |
+
break; /* Now stop looking. */
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
function _ws_plugin__s2member_classes_glob_dirs_r ($starting_dir = FALSE, $pattern = "*")
|
49 |
+
{
|
50 |
+
foreach (($dirs = glob ($starting_dir . "/" . $pattern, GLOB_ONLYDIR)) as $dir)
|
51 |
+
$dirs = array_merge ($dirs, _ws_plugin__s2member_classes_glob_dirs_r ($dir, $pattern));
|
52 |
+
/**/
|
53 |
+
return $dirs; /* Return array of all directories. */
|
54 |
+
}
|
55 |
+
/**/
|
56 |
+
spl_autoload_register ("ws_plugin__s2member_classes"); /* Register __autoload. */
|
57 |
+
}
|
58 |
+
?>
|
includes/functions/config-user-registration.inc.php
DELETED
@@ -1,654 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
-
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
-
|
6 |
-
Released under the terms of the GNU General Public License.
|
7 |
-
You should have received a copy of the GNU General Public License,
|
8 |
-
along with this software. In the main directory, see: /licensing/
|
9 |
-
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Direct access denial.
|
13 |
-
*/
|
14 |
-
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Function that adds hidden fields to POST vars on signup.
|
18 |
-
Attach to: add_filter("signup_hidden_fields");
|
19 |
-
|
20 |
-
This can ONLY be fired through wp-signup.php on the front-side.
|
21 |
-
Or through `/register` via BuddyPress.
|
22 |
-
*/
|
23 |
-
if (!function_exists ("ws_plugin__s2member_ms_process_signup_hidden_fields"))
|
24 |
-
{
|
25 |
-
function ws_plugin__s2member_ms_process_signup_hidden_fields ()
|
26 |
-
{
|
27 |
-
do_action ("ws_plugin__s2member_before_ms_process_signup_hidden_fields", get_defined_vars ());
|
28 |
-
/**/
|
29 |
-
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking, on a Blog Farm. */
|
30 |
-
if (ws_plugin__s2member_is_multisite_farm () && is_main_site () && ( (preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && $_POST["stage"] === "validate-user-signup") || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_REGISTER_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]))))
|
31 |
-
{
|
32 |
-
foreach ((array)ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
33 |
-
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
34 |
-
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
35 |
-
echo '<input type="hidden" name="' . esc_attr ($key) . '" value="' . esc_attr (maybe_serialize ($value)) . '" />' . "\n";
|
36 |
-
/**/
|
37 |
-
do_action ("ws_plugin__s2member_during_ms_process_signup_hidden_fields", get_defined_vars ());
|
38 |
-
}
|
39 |
-
/**/
|
40 |
-
do_action ("ws_plugin__s2member_after_ms_process_signup_hidden_fields", get_defined_vars ());
|
41 |
-
}
|
42 |
-
}
|
43 |
-
/*
|
44 |
-
Function that adds customs fields to $meta on signup.
|
45 |
-
Attach to: add_filter("add_signup_meta");
|
46 |
-
Attach to: add_filter("bp_signup_usermeta");
|
47 |
-
|
48 |
-
This can be fired through wp-signup.php on the front-side,
|
49 |
-
or possibly through user-new.php in the admin.
|
50 |
-
*/
|
51 |
-
if (!function_exists ("ws_plugin__s2member_ms_process_signup_meta"))
|
52 |
-
{
|
53 |
-
function ws_plugin__s2member_ms_process_signup_meta ($meta = FALSE)
|
54 |
-
{
|
55 |
-
global $pagenow; /* Need this to detect the current admin page. */
|
56 |
-
/**/
|
57 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
58 |
-
do_action ("ws_plugin__s2member_before_ms_process_signup_meta", get_defined_vars ());
|
59 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
60 |
-
/**/
|
61 |
-
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. Either in the admin, or on a Blog Farm through wp-signup.php. */
|
62 |
-
if ((is_admin () && $pagenow === "user-new.php") || (ws_plugin__s2member_is_multisite_farm () && is_main_site () && ( (preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && preg_match ("/^validate-(user|blog)-signup$/", $_POST["stage"])) || (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_REGISTER_SLUG, "/") . "/", $_SERVER["REQUEST_URI"])))))
|
63 |
-
{
|
64 |
-
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in notifications. */
|
65 |
-
/**/
|
66 |
-
foreach ((array)ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
67 |
-
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
68 |
-
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
69 |
-
$meta["s2member_ms_signup_meta"][$key] = maybe_unserialize ($value);
|
70 |
-
}
|
71 |
-
/**/
|
72 |
-
return apply_filters ("ws_plugin__s2member_ms_process_signup_meta", $meta, get_defined_vars ());
|
73 |
-
}
|
74 |
-
}
|
75 |
-
/*
|
76 |
-
Function for configuring new users.
|
77 |
-
Attach to: add_action("wpmu_activate_user");
|
78 |
-
|
79 |
-
This does NOT fire for a Super Admin managing Network Users.
|
80 |
-
Which is good. A Super Admin will NOT trigger this event.
|
81 |
-
~ They fire wpmu_create_user(), bypassing activation.
|
82 |
-
- through ms-edit.php.
|
83 |
-
|
84 |
-
However, a Super Admin CAN trigger this event by adding a new User through the Users -> Add New menu.
|
85 |
-
~ If they choose to bypass activation; an activation IS fired immediately. Otherwise, it's delayed.
|
86 |
-
- via user-new.php.
|
87 |
-
|
88 |
-
So this function may get fired inside the admin panel ( `user-new.php` ).
|
89 |
-
Or also during an actual activation; through `wp-activate.php`.
|
90 |
-
Or also during an actual activation; through `/activate` via BuddyPress.
|
91 |
-
*/
|
92 |
-
if (!function_exists ("ws_plugin__s2member_configure_user_on_ms_user_activation"))
|
93 |
-
{
|
94 |
-
function ws_plugin__s2member_configure_user_on_ms_user_activation ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
95 |
-
{
|
96 |
-
global $pagenow; /* Need this to detect the current admin page. */
|
97 |
-
/**/
|
98 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
99 |
-
do_action ("ws_plugin__s2member_before_configure_user_on_ms_user_activation", get_defined_vars ());
|
100 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
101 |
-
/**/
|
102 |
-
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
103 |
-
if ((is_admin () && $pagenow === "user-new.php") || (!is_admin () && preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (!is_admin () && defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"])))
|
104 |
-
{
|
105 |
-
ws_plugin__s2member_configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
106 |
-
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
107 |
-
}
|
108 |
-
/**/
|
109 |
-
do_action ("ws_plugin__s2member_after_configure_user_on_ms_user_activation", get_defined_vars ());
|
110 |
-
/**/
|
111 |
-
return; /* Return for uniformity. */
|
112 |
-
}
|
113 |
-
}
|
114 |
-
/*
|
115 |
-
Function for configuring new users.
|
116 |
-
Attach to: add_action("wpmu_activate_blog");
|
117 |
-
|
118 |
-
This does NOT fire for a Super Admin managing Network Blogs.
|
119 |
-
~ Actually they do; BUT it's blocked by the routine below.
|
120 |
-
Which is good. A Super Admin should NOT trigger this event.
|
121 |
-
|
122 |
-
This function should ONLY be fired through `wp-activate.php`.
|
123 |
-
Or also through `/activate` via BuddyPress.
|
124 |
-
*/
|
125 |
-
if (!function_exists ("ws_plugin__s2member_configure_user_on_ms_blog_activation"))
|
126 |
-
{
|
127 |
-
function ws_plugin__s2member_configure_user_on_ms_blog_activation ($blog_id = FALSE, $user_id = FALSE, $password = FALSE, $title = FALSE, $meta = FALSE)
|
128 |
-
{
|
129 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
130 |
-
do_action ("ws_plugin__s2member_before_configure_user_on_ms_blog_activation", get_defined_vars ());
|
131 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
132 |
-
/**/
|
133 |
-
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
134 |
-
if ((!is_admin () && preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (!is_admin () && defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"])))
|
135 |
-
{
|
136 |
-
ws_plugin__s2member_configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
137 |
-
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
138 |
-
}
|
139 |
-
/**/
|
140 |
-
do_action ("ws_plugin__s2member_after_configure_user_on_ms_blog_activation", get_defined_vars ());
|
141 |
-
/**/
|
142 |
-
return; /* Return for uniformity. */
|
143 |
-
}
|
144 |
-
}
|
145 |
-
/*
|
146 |
-
Function for configuring new users.
|
147 |
-
Attach to: add_action("user_register");
|
148 |
-
|
149 |
-
This also receives Multisite events.
|
150 |
-
Attach to: add_action("wpmu_activate_user");
|
151 |
-
Attach to: add_action("wpmu_activate_blog");
|
152 |
-
|
153 |
-
The Hook `user_register` is also fired by calling:
|
154 |
-
wpmu_create_user()
|
155 |
-
|
156 |
-
This function also receives simulated events from s2Member Pro.
|
157 |
-
*/
|
158 |
-
if (!function_exists ("ws_plugin__s2member_configure_user_registration"))
|
159 |
-
{
|
160 |
-
function ws_plugin__s2member_configure_user_registration ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
161 |
-
{
|
162 |
-
global $wpdb; /* Global database object may be required for this routine. */
|
163 |
-
global $pagenow; /* Need this to detect the current admin page. */
|
164 |
-
global $current_site, $current_blog; /* Multisite Networking. */
|
165 |
-
static $email_config, $processed; /* No duplicate processing. */
|
166 |
-
/**/
|
167 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
168 |
-
do_action ("ws_plugin__s2member_before_configure_user_registration", get_defined_vars ());
|
169 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
170 |
-
/**/
|
171 |
-
/* With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_user|blog`. */
|
172 |
-
if (!$email_config && ($email_config = true)) /* Anytime this routine is fired; we config email; no exceptions. */
|
173 |
-
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
|
174 |
-
/**/
|
175 |
-
if (!$processed /* Process only once. Safeguard this routine against duplicate processing via plugins ( or even WordPress® itself ). */
|
176 |
-
&& (is_array ($_POST = ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST))) || is_array (ws_plugin__s2member_trim_deep (stripslashes_deep ($meta))))/**/
|
177 |
-
/**/
|
178 |
-
/* These negative matches are designed to prevent this routine from running under certain conditions; where we need to wait for `wpmu_activate_user|blog` instead. */
|
179 |
-
&& ! (is_admin () && is_multisite () && $pagenow === "user-new.php" && isset ($_POST["noconfirmation"]) && is_super_admin () && func_num_args () !== 3)/**/
|
180 |
-
&& ! (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"]) && func_num_args () !== 3) /* If activating; we MUST have a $meta arg to proceed. */
|
181 |
-
&& ! (defined ("BP_VERSION") && preg_match ("/\/" . preg_quote (BP_ACTIVATION_SLUG, "/") . "/", $_SERVER["REQUEST_URI"]) && func_num_args () !== 3)
|
182 |
-
/* The $meta argument is ONLY passed in by hand-offs from `wpmu_activate_user|blog`. So this is how we check for these events. */
|
183 |
-
/**/
|
184 |
-
&& $user_id && is_object ($user = new WP_User ($user_id)) && $user->ID && ($processed = true)) /* Process only once. */
|
185 |
-
{
|
186 |
-
foreach ((array)$_POST as $key => $value) /* Scan $_POST vars; adding `custom_reg_field` uniformity keys. */
|
187 |
-
if (preg_match ("/^ws_plugin__s2member_user_new_/", $key)) /* Looking for `user_new` keys here. */
|
188 |
-
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
189 |
-
$_POST[$key] = $value; /* Add these keys for uniformity. */
|
190 |
-
unset ($key, $value); /* Prevents bleeding vars into Hooks/Filters. */
|
191 |
-
/**/
|
192 |
-
if (!is_admin () && ($_POST["ws_plugin__s2member_custom_reg_field_s2member_custom"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_ccaps"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_notes"]))
|
193 |
-
exit ("s2Member security violation. You attempted to POST variables that will NOT be trusted!");
|
194 |
-
/**/
|
195 |
-
$_pm = array_merge ((array)$_POST, (array)$meta); /* Merge these two data sources together now; ALWAYS after the security routine above ^. */
|
196 |
-
/**/
|
197 |
-
if (!is_admin () /* Only run this particular routine whenever a Member [1-4] is registering themselves with cookies. */
|
198 |
-
&& ($subscr_id = ws_plugin__s2member_decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = ws_plugin__s2member_decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"])))/**/
|
199 |
-
&& (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1")))
|
200 |
-
/* ^ This is for security ^ It checks the database to make sure the User/Member has not already registered in the past, with the same Paid Subscr. ID. */
|
201 |
-
{ /*
|
202 |
-
This routine could be processed through `wp-login.php?action=register`, `wp-activate.php`, or `/activate` via BuddyPress`.
|
203 |
-
This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
|
204 |
-
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
205 |
-
*/
|
206 |
-
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
207 |
-
/**/
|
208 |
-
list ($level, $ccaps, $eotper) = preg_split ("/\:/", $level, 3);
|
209 |
-
$role = "s2member_level" . $level; /* Level 1-4. */
|
210 |
-
/**/
|
211 |
-
$email = $user->user_email;
|
212 |
-
$login = $user->user_login;
|
213 |
-
$ip = $_SERVER["REMOTE_ADDR"];
|
214 |
-
$cv = preg_split ("/\|/", $custom);
|
215 |
-
/**/
|
216 |
-
if ($eotper) /* If a specific EOT Period has been attached; calculate that now. */
|
217 |
-
$auto_eot_time = ws_plugin__s2member_paypal_auto_eot_time ("", "", "", $eotper);
|
218 |
-
/**/
|
219 |
-
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
220 |
-
/**/
|
221 |
-
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
222 |
-
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
223 |
-
/**/
|
224 |
-
if (! ($fname = $user->first_name))
|
225 |
-
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
226 |
-
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
227 |
-
/**/
|
228 |
-
if (!$fname) /* Also try BuddyPress. */
|
229 |
-
if ($_pm["field_1"]) /* BuddyPress. */
|
230 |
-
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
231 |
-
/**/
|
232 |
-
if (! ($lname = $user->last_name))
|
233 |
-
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
234 |
-
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
235 |
-
/**/
|
236 |
-
if (!$lname) /* Also try BuddyPress. */
|
237 |
-
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
238 |
-
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
239 |
-
/**/
|
240 |
-
$name = trim ($fname . " " . $lname); /* Both names. */
|
241 |
-
/**/
|
242 |
-
if (! ($pass = $password)) /* Try s2Member's generator. */
|
243 |
-
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
244 |
-
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
245 |
-
/**/
|
246 |
-
if (!$pass) /* Also try BuddyPress password. */
|
247 |
-
if ($_pm["signup_password"]) /* BuddyPress. */
|
248 |
-
$pass = $_pm["signup_password"];
|
249 |
-
/**/
|
250 |
-
if ($pass) /* No password nag. Update this globally. */
|
251 |
-
{
|
252 |
-
delete_user_setting ("default_password_nag"); /* setcookie() */
|
253 |
-
update_user_option ($user_id, "default_password_nag", false, true);
|
254 |
-
}
|
255 |
-
/**/
|
256 |
-
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
257 |
-
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
258 |
-
update_user_option ($user_id, "s2member_custom", $custom);
|
259 |
-
update_user_option ($user_id, "s2member_notes", $notes);
|
260 |
-
/**/
|
261 |
-
if (!$user->first_name && $fname)
|
262 |
-
update_user_meta ($user_id, "first_name", $fname) ./**/
|
263 |
-
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
264 |
-
/**/
|
265 |
-
if (!$user->last_name && $lname)
|
266 |
-
update_user_meta ($user_id, "last_name", $lname);
|
267 |
-
/**/
|
268 |
-
if (is_multisite ()) /* Originating Blog ID#, and adjust Main Site permissions. */
|
269 |
-
{
|
270 |
-
(!is_main_site ()) ? remove_user_from_blog ($user_id, $current_site->blog_id) : null;
|
271 |
-
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
272 |
-
}
|
273 |
-
/**/
|
274 |
-
$user->set_role ($role); /* s2Member. */
|
275 |
-
/**/
|
276 |
-
if ($ccaps) /* Add Custom Capabilities. */
|
277 |
-
foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
|
278 |
-
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
279 |
-
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
280 |
-
/**/
|
281 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
282 |
-
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
283 |
-
{
|
284 |
-
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
285 |
-
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
286 |
-
/**/
|
287 |
-
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
288 |
-
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
289 |
-
}
|
290 |
-
/**/
|
291 |
-
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
292 |
-
/**/
|
293 |
-
if (($transient = md5 ("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array ($subscr_payment = get_transient ($transient)))
|
294 |
-
{
|
295 |
-
$proxy = array ("s2member_paypal_notify" => "1", "s2member_paypal_proxy" => "s2member_transient_ipn_subscr_payment", "s2member_paypal_proxy_verification" => ws_plugin__s2member_paypal_proxy_key_gen ());
|
296 |
-
ws_plugin__s2member_remote (add_query_arg (urlencode_deep ($proxy), get_bloginfo ("wpurl")), stripslashes_deep ($subscr_payment), array ("timeout" => 20));
|
297 |
-
delete_transient($transient);
|
298 |
-
}
|
299 |
-
/**/
|
300 |
-
setcookie ("s2member_signup_tracking", ws_plugin__s2member_encrypt ($subscr_id), time () + 31556926, "/");
|
301 |
-
/**/
|
302 |
-
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
303 |
-
{
|
304 |
-
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
305 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
306 |
-
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
307 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
308 |
-
}
|
309 |
-
/**/
|
310 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
311 |
-
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars ());
|
312 |
-
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
313 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
314 |
-
}
|
315 |
-
/**/
|
316 |
-
else if (!is_admin ()) /* Otherwise, if we are NOT inside the Dashboard during the creation of this account. */
|
317 |
-
{ /*
|
318 |
-
This routine could be processed through `wp-login.php?action=register`, `wp-activate.php`, or `/activate` via BuddyPress`.
|
319 |
-
This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
|
320 |
-
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
321 |
-
*/
|
322 |
-
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
323 |
-
/**/
|
324 |
-
$role = $role = $user->roles[0]; /* If they already have a Role, we can use it. */
|
325 |
-
$role = (!$role && is_multisite () && is_main_site ()) ? get_site_option ("default_user_role") : $role;
|
326 |
-
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise, the default role. */
|
327 |
-
/**/
|
328 |
-
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
329 |
-
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
330 |
-
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
331 |
-
$level = (!$level) ? "0" : $level;
|
332 |
-
/**/
|
333 |
-
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
|
334 |
-
/**/
|
335 |
-
$email = $user->user_email;
|
336 |
-
$login = $user->user_login;
|
337 |
-
$ip = $_SERVER["REMOTE_ADDR"];
|
338 |
-
$custom = $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"];
|
339 |
-
$subscr_id = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
|
340 |
-
$cv = preg_split ("/\|/", $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
|
341 |
-
/**/
|
342 |
-
$auto_eot_time = ($eot = $_pm["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
343 |
-
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
344 |
-
/**/
|
345 |
-
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
346 |
-
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
347 |
-
/**/
|
348 |
-
if (! ($fname = $user->first_name))
|
349 |
-
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
350 |
-
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
351 |
-
/**/
|
352 |
-
if (!$fname) /* Also try BuddyPress. */
|
353 |
-
if ($_pm["field_1"]) /* BuddyPress. */
|
354 |
-
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
355 |
-
/**/
|
356 |
-
if (! ($lname = $user->last_name))
|
357 |
-
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
358 |
-
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
359 |
-
/**/
|
360 |
-
if (!$lname) /* Also try BuddyPress. */
|
361 |
-
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
362 |
-
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
363 |
-
/**/
|
364 |
-
$name = trim ($fname . " " . $lname); /* Both names. */
|
365 |
-
/**/
|
366 |
-
if (! ($pass = $password)) /* Try s2Member's generator. */
|
367 |
-
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
368 |
-
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
369 |
-
/**/
|
370 |
-
if (!$pass) /* Also try BuddyPress password. */
|
371 |
-
if ($_pm["signup_password"]) /* BuddyPress. */
|
372 |
-
$pass = $_pm["signup_password"];
|
373 |
-
/**/
|
374 |
-
if ($pass) /* No password nag. Update this globally. */
|
375 |
-
{
|
376 |
-
delete_user_setting ("default_password_nag"); /* setcookie() */
|
377 |
-
update_user_option ($user_id, "default_password_nag", false, true);
|
378 |
-
}
|
379 |
-
/**/
|
380 |
-
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
381 |
-
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
382 |
-
update_user_option ($user_id, "s2member_custom", $custom);
|
383 |
-
update_user_option ($user_id, "s2member_notes", $notes);
|
384 |
-
/**/
|
385 |
-
if (!$user->first_name && $fname)
|
386 |
-
update_user_meta ($user_id, "first_name", $fname) ./**/
|
387 |
-
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
388 |
-
/**/
|
389 |
-
if (!$user->last_name && $lname)
|
390 |
-
update_user_meta ($user_id, "last_name", $lname);
|
391 |
-
/**/
|
392 |
-
if (is_multisite ()) /* Originating Blog ID#, and adjust Main Site permissions. */
|
393 |
-
{
|
394 |
-
(!is_main_site ()) ? remove_user_from_blog ($user_id, $current_site->blog_id) : null;
|
395 |
-
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
396 |
-
}
|
397 |
-
/**/
|
398 |
-
$user->set_role ($role); /* s2Member. */
|
399 |
-
/**/
|
400 |
-
if ($ccaps) /* Add Custom Capabilities. */
|
401 |
-
foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
|
402 |
-
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
403 |
-
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
404 |
-
/**/
|
405 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
406 |
-
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
407 |
-
{
|
408 |
-
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
409 |
-
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
410 |
-
/**/
|
411 |
-
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
412 |
-
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
413 |
-
}
|
414 |
-
/**/
|
415 |
-
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
416 |
-
/**/
|
417 |
-
if ($level > 0) /* We ONLY process this if they are higher than Level#0. */
|
418 |
-
{
|
419 |
-
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
420 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserve. */
|
421 |
-
$pr_times["level" . $level] = (!$pr_times["level" . $level]) ? time () : $pr_times["level" . $level];
|
422 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
|
423 |
-
}
|
424 |
-
/**/
|
425 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
426 |
-
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars ());
|
427 |
-
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
428 |
-
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
429 |
-
}
|
430 |
-
/**/
|
431 |
-
else if (is_admin () && $pagenow === "user-new.php") /* Else, if we're on this page. */
|
432 |
-
{ /*
|
433 |
-
This routine can ONLY be processed through `user-new.php` inside the backend Dashboard.
|
434 |
-
*/
|
435 |
-
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
436 |
-
/**/
|
437 |
-
$role = $role = $user->roles[0]; /* If they already have a Role, we can use it. */
|
438 |
-
$role = (!$role && is_multisite () && is_main_site ()) ? get_site_option ("default_user_role") : $role;
|
439 |
-
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise, the default role. */
|
440 |
-
/**/
|
441 |
-
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
442 |
-
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
443 |
-
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
444 |
-
$level = (!$level) ? "0" : $level;
|
445 |
-
/**/
|
446 |
-
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|