Version Description
= v130213 = (Maintenance Release) Upgrade immediately.
Download this release
Release Info
Developer | WebSharks |
Plugin | s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members) |
Version | 130213 |
Comparing to | |
See all releases |
Code changes from version 130207 to 130213
- checksum.txt +1 -1
- includes/classes/admin-css-js-in.inc.php +34 -36
- includes/classes/admin-css-js.inc.php +4 -4
- includes/classes/admin-lockouts.inc.php +27 -30
- includes/classes/admin-notices.inc.php +49 -54
- includes/classes/auto-eots.inc.php +90 -92
- includes/classes/brute-force.inc.php +18 -20
- includes/classes/cache.inc.php +19 -23
- includes/classes/catgs-sp.inc.php +23 -25
- includes/classes/catgs.inc.php +23 -26
- includes/classes/check-activation.inc.php +4 -5
- includes/classes/constants.inc.php +70 -70
- includes/classes/cron-jobs-in.inc.php +13 -14
- includes/classes/cron-jobs.inc.php +4 -4
- includes/classes/css-js-in.inc.php +52 -57
- includes/classes/css-js-themes.inc.php +20 -23
- includes/classes/css-js.inc.php +2 -2
- includes/classes/custom-reg-fields-4bp.inc.php +100 -103
- includes/classes/custom-reg-fields.inc.php +147 -167
- includes/classes/email-configs.inc.php +55 -56
- includes/classes/files-in.inc.php +298 -284
- includes/classes/files.inc.php +65 -65
- includes/classes/installation.inc.php +66 -66
- includes/classes/ip-restrictions.inc.php +87 -87
- includes/classes/labels.inc.php +10 -10
- includes/classes/list-servers.inc.php +150 -146
- includes/classes/login-customizations.inc.php +56 -44
- includes/classes/login-redirects-r.inc.php +11 -11
- includes/classes/login-redirects.inc.php +54 -52
- includes/classes/menu-pages-rs.inc.php +15 -15
- includes/classes/menu-pages.inc.php +498 -263
- includes/classes/meta-box-saves.inc.php +43 -43
- includes/classes/meta-box-security.inc.php +49 -49
- includes/classes/meta-boxes.inc.php +7 -7
- includes/classes/mms-patches.inc.php +37 -37
- includes/classes/mo-page-in.inc.php +17 -17
- includes/classes/mo-page.inc.php +3 -3
- includes/classes/no-cache.inc.php +37 -37
- includes/classes/op-notices.inc.php +42 -42
- includes/classes/option-forces.inc.php +49 -49
- includes/classes/pages-sp.inc.php +34 -34
- includes/classes/pages.inc.php +34 -34
- includes/classes/paypal-notify-in-cart.inc.php +27 -28
- includes/classes/paypal-notify-in-express-checkout.inc.php +26 -26
- includes/classes/paypal-notify-in-rec-profile-creation-w-level.inc.php +28 -28
- includes/classes/paypal-notify-in-send-money.inc.php +26 -26
- includes/classes/paypal-notify-in-sp-refund-reversal.inc.php +42 -42
- includes/classes/paypal-notify-in-subscr-modify-w-level.inc.php +92 -91
- includes/classes/paypal-notify-in-subscr-or-rp-cancellation-w-level.inc.php +63 -64
- includes/classes/paypal-notify-in-subscr-or-rp-eots-w-level.inc.php +166 -166
- includes/classes/paypal-notify-in-subscr-or-rp-payment-failed-w-level.inc.php +28 -28
- includes/classes/paypal-notify-in-subscr-or-rp-payment-w-level.inc.php +72 -72
- includes/classes/paypal-notify-in-subscr-or-wa-w-level.inc.php +192 -216
- includes/classes/paypal-notify-in-virtual-terminal.inc.php +26 -26
- includes/classes/paypal-notify-in-wa-ccaps-wo-level.inc.php +76 -76
- includes/classes/paypal-notify-in-web-accept-sp.inc.php +72 -72
- includes/classes/paypal-notify-in.inc.php +76 -75
- includes/classes/paypal-notify.inc.php +3 -3
- includes/classes/paypal-return-in-no-tx-data.inc.php +36 -32
- includes/classes/paypal-return-in-proxy-ty-email.inc.php +34 -29
- includes/classes/paypal-return-in-proxy-x-preview.inc.php +33 -28
- includes/classes/paypal-return-in-subscr-modify-w-level.inc.php +100 -103
- includes/classes/paypal-return-in-subscr-or-wa-w-level.inc.php +163 -171
- includes/classes/paypal-return-in-wa-ccaps-wo-level.inc.php +78 -82
- includes/classes/paypal-return-in-web-accept-sp.inc.php +55 -58
- includes/classes/paypal-return-in.inc.php +20 -20
checksum.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
d5307fe33825c3590ddb8e4809996e75
|
includes/classes/admin-css-js-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Administrative CSS/JS for menu pages (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_admin_css_js_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* Administrative CSS/JS for menu pages (
|
24 |
*
|
25 |
* @package s2Member\Admin_CSS_JS
|
26 |
* @since 3.5
|
@@ -40,35 +40,34 @@ if(!class_exists("c_ws_plugin__s2member_admin_css_js_in"))
|
|
40 |
public static function menu_pages_css()
|
41 |
{
|
42 |
do_action("ws_plugin__s2member_before_menu_pages_css", get_defined_vars());
|
43 |
-
|
44 |
if(!empty($_GET["ws_plugin__s2member_menu_pages_css"]) && is_user_logged_in() && current_user_can("create_users"))
|
45 |
{
|
46 |
-
status_header
|
47 |
-
|
48 |
-
header("Content-Type: text/css; charset=
|
49 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
50 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
51 |
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
52 |
header("Pragma: no-cache");
|
53 |
-
|
54 |
-
|
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");
|
60 |
-
|
61 |
include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages.css";
|
62 |
-
|
63 |
-
echo
|
64 |
-
|
65 |
@include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s.css";
|
66 |
-
|
67 |
do_action("ws_plugin__s2member_during_menu_pages_css", get_defined_vars());
|
68 |
-
|
69 |
-
exit
|
70 |
}
|
71 |
-
/**/
|
72 |
do_action("ws_plugin__s2member_after_menu_pages_css", get_defined_vars());
|
73 |
}
|
74 |
/**
|
@@ -84,37 +83,36 @@ if(!class_exists("c_ws_plugin__s2member_admin_css_js_in"))
|
|
84 |
public static function menu_pages_js()
|
85 |
{
|
86 |
do_action("ws_plugin__s2member_before_menu_pages_js", get_defined_vars());
|
87 |
-
|
88 |
if(!empty($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in() && current_user_can("create_users"))
|
89 |
{
|
90 |
-
status_header
|
91 |
-
|
92 |
-
header("Content-Type: application/x-javascript; charset=
|
93 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
94 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
95 |
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
96 |
header("Pragma: no-cache");
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
101 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
|
102 |
-
|
103 |
for($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
104 |
$labels .= "labels['level".$n."'] = '".((!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"])) ? str_replace('"', "", c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"], 3)) : "")."';";
|
105 |
unset($n);
|
106 |
-
|
107 |
include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-min.js";
|
108 |
-
|
109 |
-
echo
|
110 |
-
|
111 |
@include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s-min.js";
|
112 |
-
|
113 |
do_action("ws_plugin__s2member_during_menu_pages_js", get_defined_vars());
|
114 |
-
|
115 |
-
exit
|
116 |
}
|
117 |
-
/**/
|
118 |
do_action("ws_plugin__s2member_after_menu_pages_js", get_defined_vars());
|
119 |
}
|
120 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Administrative CSS/JS for menu pages (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_admin_css_js_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* Administrative CSS/JS for menu pages (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\Admin_CSS_JS
|
26 |
* @since 3.5
|
40 |
public static function menu_pages_css()
|
41 |
{
|
42 |
do_action("ws_plugin__s2member_before_menu_pages_css", get_defined_vars());
|
43 |
+
|
44 |
if(!empty($_GET["ws_plugin__s2member_menu_pages_css"]) && is_user_logged_in() && current_user_can("create_users"))
|
45 |
{
|
46 |
+
status_header /* 200 OK status header. */(200);
|
47 |
+
|
48 |
+
header("Content-Type: text/css; charset=UTF-8");
|
49 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
50 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
51 |
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
52 |
header("Pragma: no-cache");
|
53 |
+
|
54 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
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");
|
60 |
+
|
61 |
include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages.css";
|
62 |
+
|
63 |
+
echo /* Add a line break before inclusion of this file. */ "\n";
|
64 |
+
|
65 |
@include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s.css";
|
66 |
+
|
67 |
do_action("ws_plugin__s2member_during_menu_pages_css", get_defined_vars());
|
68 |
+
|
69 |
+
exit /* Clean exit. */();
|
70 |
}
|
|
|
71 |
do_action("ws_plugin__s2member_after_menu_pages_css", get_defined_vars());
|
72 |
}
|
73 |
/**
|
83 |
public static function menu_pages_js()
|
84 |
{
|
85 |
do_action("ws_plugin__s2member_before_menu_pages_js", get_defined_vars());
|
86 |
+
|
87 |
if(!empty($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in() && current_user_can("create_users"))
|
88 |
{
|
89 |
+
status_header /* 200 OK status header. */(200);
|
90 |
+
|
91 |
+
header("Content-Type: application/x-javascript; charset=UTF-8");
|
92 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
93 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
94 |
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
95 |
header("Pragma: no-cache");
|
96 |
+
|
97 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
98 |
+
|
99 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
100 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
|
101 |
+
|
102 |
for($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
103 |
$labels .= "labels['level".$n."'] = '".((!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"])) ? str_replace('"', "", c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"], 3)) : "")."';";
|
104 |
unset($n);
|
105 |
+
|
106 |
include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-min.js";
|
107 |
+
|
108 |
+
echo /* Add a line break before inclusion of this file. */"\n";
|
109 |
+
|
110 |
@include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s-min.js";
|
111 |
+
|
112 |
do_action("ws_plugin__s2member_during_menu_pages_js", get_defined_vars());
|
113 |
+
|
114 |
+
exit /* Clean exit. */();
|
115 |
}
|
|
|
116 |
do_action("ws_plugin__s2member_after_menu_pages_js", get_defined_vars());
|
117 |
}
|
118 |
}
|
includes/classes/admin-css-js.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
|
21 |
{
|
22 |
/**
|
@@ -39,7 +39,7 @@ if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
|
|
39 |
*/
|
40 |
public static function menu_pages_css ()
|
41 |
{
|
42 |
-
if (!empty ($_GET["ws_plugin__s2member_menu_pages_css"]))
|
43 |
{
|
44 |
return c_ws_plugin__s2member_admin_css_js_in::menu_pages_css ();
|
45 |
}
|
@@ -56,7 +56,7 @@ if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
|
|
56 |
*/
|
57 |
public static function menu_pages_js ()
|
58 |
{
|
59 |
-
if (!empty ($_GET["ws_plugin__s2member_menu_pages_js"]))
|
60 |
{
|
61 |
return c_ws_plugin__s2member_admin_css_js_in::menu_pages_js ();
|
62 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
|
21 |
{
|
22 |
/**
|
39 |
*/
|
40 |
public static function menu_pages_css ()
|
41 |
{
|
42 |
+
if (!empty ($_GET["ws_plugin__s2member_menu_pages_css"]))
|
43 |
{
|
44 |
return c_ws_plugin__s2member_admin_css_js_in::menu_pages_css ();
|
45 |
}
|
56 |
*/
|
57 |
public static function menu_pages_js ()
|
58 |
{
|
59 |
+
if (!empty ($_GET["ws_plugin__s2member_menu_pages_js"]))
|
60 |
{
|
61 |
return c_ws_plugin__s2member_admin_css_js_in::menu_pages_js ();
|
62 |
}
|
includes/classes/admin-lockouts.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
|
21 |
{
|
22 |
/**
|
@@ -37,23 +37,22 @@ if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
|
|
37 |
*
|
38 |
* @return null Or exits script execution after redirection.
|
39 |
*/
|
40 |
-
public static function admin_lockout ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
|
43 |
-
|
44 |
if (is_admin () && (!defined ("DOING_AJAX") || !DOING_AJAX) && !current_user_can ("edit_posts") /* Give Filters a chance here too. */)
|
45 |
if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
|
46 |
{
|
47 |
if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
|
48 |
-
wp_redirect ($redirection_url) . exit ();
|
49 |
-
|
50 |
-
else
|
51 |
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . exit ();
|
52 |
}
|
53 |
-
/**/
|
54 |
do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
|
55 |
-
|
56 |
-
return
|
57 |
}
|
58 |
/**
|
59 |
* Filters administrative menu bar for Users/Members.
|
@@ -69,9 +68,9 @@ if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
|
|
69 |
public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
|
70 |
{
|
71 |
do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
|
72 |
-
|
73 |
$uses_nodes = (version_compare (get_bloginfo ("version"), "3.3-RC1", ">=")) ? true : false;
|
74 |
-
|
75 |
if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* Always for Users/Members. */)
|
76 |
{
|
77 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("site-name"))
|
@@ -80,62 +79,60 @@ if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
|
|
80 |
$title = wp_html_excerpt /* A brief excerpt. */ (get_bloginfo ("name"), 42);
|
81 |
$title = ($title !== get_bloginfo ("name")) ? trim ($title) . "…" : $title;
|
82 |
$href = /* Change to front page. */ site_url ("/");
|
83 |
-
|
84 |
$wp_admin_bar->add_node (array ("id" => $id, "title" => $title, "href" => $href));
|
85 |
$wp_admin_bar->remove_node /* Ditch now, replacing this. */ ("site-name");
|
86 |
-
|
87 |
unset /* A little housekeeping. */ ($id, $title, $href);
|
88 |
}
|
89 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("wp-logo"))
|
90 |
$wp_admin_bar->remove_node /* Ditch this node. */ ("wp-logo");
|
91 |
-
|
92 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"dashboard"}))
|
93 |
unset /* Ditch this item. */ ($wp_admin_bar->menu->{"dashboard"});
|
94 |
-
|
95 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-blogs"}))
|
96 |
unset /* Ditch this item. */ ($wp_admin_bar->menu->{"my-blogs"});
|
97 |
-
|
98 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("my-sites"))
|
99 |
$wp_admin_bar->remove_node /* Ditch this node. */ ("my-sites");
|
100 |
}
|
101 |
-
/**/
|
102 |
if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* If locking Users/Members out of `/wp-admin/` areas. */)
|
103 |
if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
|
104 |
{
|
105 |
$lwp = c_ws_plugin__s2member_login_redirects::login_redirection_url ();
|
106 |
$lwp = (!$lwp) ? get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) : $lwp;
|
107 |
-
|
108 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("my-account"))
|
109 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "my-account", "href" => $lwp));
|
110 |
-
|
111 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("user-info"))
|
112 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "user-info", "href" => $lwp));
|
113 |
-
|
114 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("edit-profile"))
|
115 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "edit-profile", "href" => $lwp));
|
116 |
-
|
117 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["href"]))
|
118 |
$wp_admin_bar->menu->{"my-account"}["href"] = /* Update this item. */ $lwp;
|
119 |
-
|
120 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"]))
|
121 |
$wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"] = /* Update this item. */ $lwp;
|
122 |
-
|
123 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["children"]->{"user-info"}["href"]))
|
124 |
$wp_admin_bar->menu->{"my-account"}["children"]->{"user-info"}["href"] = /* Update this item. */ $lwp;
|
125 |
-
|
126 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"]))
|
127 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = /* Update this item. */ $lwp;
|
128 |
-
|
129 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"user-info"}["href"]))
|
130 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"user-info"}["href"] = /* Update this item. */ $lwp;
|
131 |
-
|
132 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"]))
|
133 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"] = /* Update this item. */ $lwp;
|
134 |
}
|
135 |
-
/**/
|
136 |
do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
|
137 |
-
|
138 |
-
return
|
139 |
}
|
140 |
}
|
141 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
|
21 |
{
|
22 |
/**
|
37 |
*
|
38 |
* @return null Or exits script execution after redirection.
|
39 |
*/
|
40 |
+
public static function admin_lockout ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
|
43 |
+
|
44 |
if (is_admin () && (!defined ("DOING_AJAX") || !DOING_AJAX) && !current_user_can ("edit_posts") /* Give Filters a chance here too. */)
|
45 |
if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
|
46 |
{
|
47 |
if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
|
48 |
+
/* Special Redirection. */wp_redirect ($redirection_url) . exit ();
|
49 |
+
|
50 |
+
else // Else we use the Login Welcome Page configured for s2Member.
|
51 |
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . exit ();
|
52 |
}
|
|
|
53 |
do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
|
54 |
+
|
55 |
+
return /* Return for uniformity. */;
|
56 |
}
|
57 |
/**
|
58 |
* Filters administrative menu bar for Users/Members.
|
68 |
public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
|
69 |
{
|
70 |
do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
|
71 |
+
|
72 |
$uses_nodes = (version_compare (get_bloginfo ("version"), "3.3-RC1", ">=")) ? true : false;
|
73 |
+
|
74 |
if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* Always for Users/Members. */)
|
75 |
{
|
76 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("site-name"))
|
79 |
$title = wp_html_excerpt /* A brief excerpt. */ (get_bloginfo ("name"), 42);
|
80 |
$title = ($title !== get_bloginfo ("name")) ? trim ($title) . "…" : $title;
|
81 |
$href = /* Change to front page. */ site_url ("/");
|
82 |
+
|
83 |
$wp_admin_bar->add_node (array ("id" => $id, "title" => $title, "href" => $href));
|
84 |
$wp_admin_bar->remove_node /* Ditch now, replacing this. */ ("site-name");
|
85 |
+
|
86 |
unset /* A little housekeeping. */ ($id, $title, $href);
|
87 |
}
|
88 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("wp-logo"))
|
89 |
$wp_admin_bar->remove_node /* Ditch this node. */ ("wp-logo");
|
90 |
+
// -------
|
91 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"dashboard"}))
|
92 |
unset /* Ditch this item. */ ($wp_admin_bar->menu->{"dashboard"});
|
93 |
+
|
94 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-blogs"}))
|
95 |
unset /* Ditch this item. */ ($wp_admin_bar->menu->{"my-blogs"});
|
96 |
+
// -------
|
97 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("my-sites"))
|
98 |
$wp_admin_bar->remove_node /* Ditch this node. */ ("my-sites");
|
99 |
}
|
|
|
100 |
if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* If locking Users/Members out of `/wp-admin/` areas. */)
|
101 |
if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
|
102 |
{
|
103 |
$lwp = c_ws_plugin__s2member_login_redirects::login_redirection_url ();
|
104 |
$lwp = (!$lwp) ? get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) : $lwp;
|
105 |
+
|
106 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("my-account"))
|
107 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "my-account", "href" => $lwp));
|
108 |
+
|
109 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("user-info"))
|
110 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "user-info", "href" => $lwp));
|
111 |
+
|
112 |
if ($uses_nodes && $wp_admin_bar->get_node /* We have this node? */ ("edit-profile"))
|
113 |
$wp_admin_bar->add_node /* Update this node. */ (array ("id" => "edit-profile", "href" => $lwp));
|
114 |
+
// -------
|
115 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["href"]))
|
116 |
$wp_admin_bar->menu->{"my-account"}["href"] = /* Update this item. */ $lwp;
|
117 |
+
|
118 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"]))
|
119 |
$wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"] = /* Update this item. */ $lwp;
|
120 |
+
|
121 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account"}["children"]->{"user-info"}["href"]))
|
122 |
$wp_admin_bar->menu->{"my-account"}["children"]->{"user-info"}["href"] = /* Update this item. */ $lwp;
|
123 |
+
// -------
|
124 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"]))
|
125 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = /* Update this item. */ $lwp;
|
126 |
+
|
127 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"user-info"}["href"]))
|
128 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"user-info"}["href"] = /* Update this item. */ $lwp;
|
129 |
+
|
130 |
if (!$uses_nodes && isset /* Have this item? */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"]))
|
131 |
$wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"] = /* Update this item. */ $lwp;
|
132 |
}
|
|
|
133 |
do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
|
134 |
+
|
135 |
+
return /* Return for uniformity. */;
|
136 |
}
|
137 |
}
|
138 |
}
|
includes/classes/admin-notices.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
21 |
{
|
22 |
/**
|
@@ -33,7 +33,7 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
|
33 |
* @package s2Member\Admin_Notices
|
34 |
* @since 3.5
|
35 |
*
|
36 |
-
* @param str $notice String value of actual notice *(
|
37 |
* @param str|array $on_pages Optional. Defaults to any page. String or array of pages to display this notice on.
|
38 |
* @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
|
39 |
* @param int $time Optional. Unix timestamp indicating when this notice will be displayed.
|
@@ -42,26 +42,25 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
|
42 |
*/
|
43 |
public static function enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
|
44 |
{
|
45 |
-
|
46 |
do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
|
47 |
-
unset
|
48 |
-
|
49 |
-
if
|
50 |
{
|
51 |
$notices = (array)get_option ("ws_plugin__s2member_notices");
|
52 |
-
|
53 |
array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time, "dismiss" => $dismiss));
|
54 |
-
|
55 |
-
|
56 |
do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
|
57 |
-
unset
|
58 |
-
|
59 |
update_option ("ws_plugin__s2member_notices", c_ws_plugin__s2member_utils_arrays::array_unique ($notices));
|
60 |
}
|
61 |
-
/**/
|
62 |
do_action ("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
|
63 |
-
|
64 |
-
return
|
65 |
}
|
66 |
/**
|
67 |
* Displays an administrative notice.
|
@@ -69,33 +68,32 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
|
69 |
* @package s2Member\Admin_Notices
|
70 |
* @since 3.5
|
71 |
*
|
72 |
-
* @param str $notice String value of actual notice *(
|
73 |
* @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
|
74 |
* @param bool $dismiss Optional. If true, the notice will be displayed with a dismissal link. Defaults to false.
|
75 |
* @return null
|
76 |
*/
|
77 |
public static function display_admin_notice ($notice = FALSE, $error = FALSE, $dismiss = FALSE)
|
78 |
{
|
79 |
-
|
80 |
do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
|
81 |
-
unset
|
82 |
-
|
83 |
-
if (is_string ($notice) && $notice && $error)
|
84 |
{
|
85 |
$notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
|
86 |
-
|
87 |
-
echo '<div class="error fade"><p>' . $notice . '</p></div>';
|
88 |
}
|
89 |
else if (is_string ($notice) && $notice)
|
90 |
{
|
91 |
$notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
|
92 |
-
|
93 |
echo '<div class="updated fade"><p>' . $notice . '</p></div>';
|
94 |
}
|
95 |
-
/**/
|
96 |
do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
|
97 |
-
|
98 |
-
return
|
99 |
}
|
100 |
/**
|
101 |
* Processes all administrative notices.
|
@@ -112,60 +110,57 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
|
112 |
*/
|
113 |
public static function admin_notices ()
|
114 |
{
|
115 |
-
global
|
116 |
-
|
117 |
do_action ("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
|
118 |
-
|
119 |
if (is_admin () && is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
|
120 |
{
|
121 |
$a = (is_blog_admin ()) ? "blog" : $a;
|
122 |
$a = (is_user_admin ()) ? "user" : $a;
|
123 |
$a = (is_network_admin ()) ? "network" : $a;
|
124 |
-
$a = (!$a) ? "blog" : $a;
|
125 |
-
|
126 |
-
foreach
|
127 |
foreach (((!$notice["on_pages"]) ? array ("*"): (array)$notice["on_pages"]) as $page)
|
128 |
{
|
129 |
-
if (!preg_match ("/^(.+?)\:/", $page))
|
130 |
-
$page = "blog:" . ltrim ($page, ":");
|
131 |
-
|
132 |
$adms = preg_split ("/\|/", preg_replace ("/\:(.*)$/i", "", $page));
|
133 |
$page = preg_replace ("/^([^\:]*)\:/i", "", $page);
|
134 |
-
|
135 |
if (empty ($adms) || in_array ("*", $adms) || in_array ($a, $adms))
|
136 |
if (!$page || "*" === $page || $pagenow === $page || $_GET["page"] === $page)
|
137 |
{
|
138 |
-
if (strtotime ("now") >= (int)$notice["time"])
|
139 |
{
|
140 |
-
|
141 |
do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
|
142 |
-
unset
|
143 |
-
|
144 |
if (!$notice["dismiss"] || (!empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5 ($notice["notice"])))
|
145 |
-
unset
|
146 |
-
|
147 |
if (!$notice["dismiss"] || empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5 ($notice["notice"]))
|
148 |
c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice["notice"], $notice["error"], $notice["dismiss"]);
|
149 |
-
|
150 |
do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
|
151 |
}
|
152 |
-
|
153 |
-
continue 2; /* This Notice processed; continue. */
|
154 |
}
|
155 |
}
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
160 |
do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
|
161 |
-
unset
|
162 |
-
|
163 |
update_option ("ws_plugin__s2member_notices", $notices);
|
164 |
}
|
165 |
-
/**/
|
166 |
do_action ("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
|
167 |
-
|
168 |
-
return
|
169 |
}
|
170 |
}
|
171 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
|
21 |
{
|
22 |
/**
|
33 |
* @package s2Member\Admin_Notices
|
34 |
* @since 3.5
|
35 |
*
|
36 |
+
* @param str $notice String value of actual notice *(i.e. the message)*.
|
37 |
* @param str|array $on_pages Optional. Defaults to any page. String or array of pages to display this notice on.
|
38 |
* @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
|
39 |
* @param int $time Optional. Unix timestamp indicating when this notice will be displayed.
|
42 |
*/
|
43 |
public static function enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
|
44 |
{
|
45 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
46 |
do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
|
47 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
48 |
+
|
49 |
+
if /* If we have a valid string. */(is_string ($notice) && $notice)
|
50 |
{
|
51 |
$notices = (array)get_option ("ws_plugin__s2member_notices");
|
52 |
+
|
53 |
array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time, "dismiss" => $dismiss));
|
54 |
+
|
55 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
56 |
do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
|
57 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
58 |
+
|
59 |
update_option ("ws_plugin__s2member_notices", c_ws_plugin__s2member_utils_arrays::array_unique ($notices));
|
60 |
}
|
|
|
61 |
do_action ("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
|
62 |
+
|
63 |
+
return /* Return for uniformity. */;
|
64 |
}
|
65 |
/**
|
66 |
* Displays an administrative notice.
|
68 |
* @package s2Member\Admin_Notices
|
69 |
* @since 3.5
|
70 |
*
|
71 |
+
* @param str $notice String value of actual notice *(i.e. the message)*.
|
72 |
* @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
|
73 |
* @param bool $dismiss Optional. If true, the notice will be displayed with a dismissal link. Defaults to false.
|
74 |
* @return null
|
75 |
*/
|
76 |
public static function display_admin_notice ($notice = FALSE, $error = FALSE, $dismiss = FALSE)
|
77 |
{
|
78 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
79 |
do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
|
80 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
81 |
+
|
82 |
+
if /* Slightly different/special format for errors. */ (is_string ($notice) && $notice && $error)
|
83 |
{
|
84 |
$notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
|
85 |
+
|
86 |
+
echo /* Error. */ '<div class="error fade"><p>' . $notice . '</p></div>';
|
87 |
}
|
88 |
else if (is_string ($notice) && $notice)
|
89 |
{
|
90 |
$notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
|
91 |
+
|
92 |
echo '<div class="updated fade"><p>' . $notice . '</p></div>';
|
93 |
}
|
|
|
94 |
do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
|
95 |
+
|
96 |
+
return /* Return for uniformity. */;
|
97 |
}
|
98 |
/**
|
99 |
* Processes all administrative notices.
|
110 |
*/
|
111 |
public static function admin_notices ()
|
112 |
{
|
113 |
+
global /* This holds the current page filename. */ $pagenow;
|
114 |
+
|
115 |
do_action ("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
|
116 |
+
|
117 |
if (is_admin () && is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
|
118 |
{
|
119 |
$a = (is_blog_admin ()) ? "blog" : $a;
|
120 |
$a = (is_user_admin ()) ? "user" : $a;
|
121 |
$a = (is_network_admin ()) ? "network" : $a;
|
122 |
+
$a = /* Default Blog Admin. */(!$a) ? "blog" : $a;
|
123 |
+
|
124 |
+
foreach /* Check several things about each Notice. */ ($notices as $i => $notice)
|
125 |
foreach (((!$notice["on_pages"]) ? array ("*"): (array)$notice["on_pages"]) as $page)
|
126 |
{
|
127 |
+
if /* NO prefix? */ (!preg_match ("/^(.+?)\:/", $page))
|
128 |
+
$page = /* `blog:` */ "blog:" . ltrim ($page, ":");
|
129 |
+
|
130 |
$adms = preg_split ("/\|/", preg_replace ("/\:(.*)$/i", "", $page));
|
131 |
$page = preg_replace ("/^([^\:]*)\:/i", "", $page);
|
132 |
+
|
133 |
if (empty ($adms) || in_array ("*", $adms) || in_array ($a, $adms))
|
134 |
if (!$page || "*" === $page || $pagenow === $page || $_GET["page"] === $page)
|
135 |
{
|
136 |
+
if /* Time to show it? */ (strtotime ("now") >= (int)$notice["time"])
|
137 |
{
|
138 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
139 |
do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
|
140 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
141 |
+
|
142 |
if (!$notice["dismiss"] || (!empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5 ($notice["notice"])))
|
143 |
+
unset /* Clear this administrative notice now? */($notices[$i]);
|
144 |
+
|
145 |
if (!$notice["dismiss"] || empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5 ($notice["notice"]))
|
146 |
c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice["notice"], $notice["error"], $notice["dismiss"]);
|
147 |
+
|
148 |
do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
|
149 |
}
|
150 |
+
continue /* This Notice processed; continue. */ 2;
|
|
|
151 |
}
|
152 |
}
|
153 |
+
$notices = /* Re-index array. */array_merge ($notices);
|
154 |
+
|
155 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
156 |
do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
|
157 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
158 |
+
|
159 |
update_option ("ws_plugin__s2member_notices", $notices);
|
160 |
}
|
|
|
161 |
do_action ("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
|
162 |
+
|
163 |
+
return /* Return for uniformity. */;
|
164 |
}
|
165 |
}
|
166 |
}
|
includes/classes/auto-eots.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's Auto-EOT System *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's Auto-EOT System *(
|
24 |
*
|
25 |
* @package s2Member\Auto_EOT_System
|
26 |
* @since 3.5
|
@@ -38,18 +38,18 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
38 |
public static function add_auto_eot_system ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_before_add_auto_eot_system", get_defined_vars ());
|
41 |
-
|
42 |
if (!c_ws_plugin__s2member_auto_eots::delete_auto_eot_system ())
|
43 |
{
|
44 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
45 |
}
|
46 |
-
else if
|
47 |
{
|
48 |
wp_schedule_event (time (), "every10m", "ws_plugin__s2member_auto_eot_system__schedule");
|
49 |
-
|
50 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", true, get_defined_vars ());
|
51 |
}
|
52 |
-
else
|
53 |
{
|
54 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
55 |
}
|
@@ -65,23 +65,23 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
65 |
public static function delete_auto_eot_system ()
|
66 |
{
|
67 |
do_action ("ws_plugin__s2member_before_delete_auto_eot_system", get_defined_vars ());
|
68 |
-
|
69 |
-
if
|
70 |
{
|
71 |
-
wp_clear_scheduled_hook
|
72 |
-
|
73 |
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
|
74 |
}
|
75 |
-
else
|
76 |
{
|
77 |
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
|
78 |
}
|
79 |
}
|
80 |
/**
|
81 |
-
* Processed by WP_Cron; this handles Auto-EOTs *(
|
82 |
*
|
83 |
* If you have a HUGE userbase, increase the max EOTs per process.
|
84 |
-
* But NOTE, this runs ``$per_process`` *(
|
85 |
* To increase, use: ``add_filter ("ws_plugin__s2member_auto_eot_system_per_process");``.
|
86 |
*
|
87 |
* This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`.
|
@@ -97,79 +97,82 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
97 |
*/
|
98 |
public static function auto_eot_system ($per_process = 3)
|
99 |
{
|
100 |
-
global
|
101 |
-
global $current_site, $current_blog;
|
102 |
-
|
103 |
include_once ABSPATH . "wp-admin/includes/admin.php";
|
104 |
-
|
105 |
-
@set_time_limit
|
106 |
@ini_set ("memory_limit", apply_filters ("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
|
107 |
-
|
108 |
-
|
109 |
do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
|
110 |
-
unset
|
111 |
-
|
112 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
113 |
{
|
114 |
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
|
115 |
-
|
116 |
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)))
|
117 |
{
|
118 |
-
foreach
|
119 |
{
|
120 |
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
121 |
{
|
122 |
-
delete_user_option ($user_id, "s2member_auto_eot_time");
|
123 |
-
|
124 |
-
if
|
125 |
{
|
126 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
127 |
{
|
128 |
-
$eot_del_type = /* Set EOT/Del type. */
|
129 |
-
|
130 |
-
/**/
|
131 |
$custom = get_user_option ("s2member_custom", $user_id);
|
|
|
132 |
$subscr_id = get_user_option ("s2member_subscr_id", $user_id);
|
133 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
134 |
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
135 |
-
|
136 |
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
|
137 |
$existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
138 |
-
|
139 |
-
|
140 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars ());
|
141 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), $eot_del_type, "modification", $demotion_role);
|
142 |
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "modification");
|
143 |
-
unset
|
144 |
-
|
145 |
-
if
|
146 |
-
$user->set_role
|
147 |
-
|
148 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
149 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
150 |
$user->remove_cap ($ccap = $cap);
|
151 |
-
|
152 |
delete_user_option ($user_id, "s2member_custom");
|
153 |
delete_user_option ($user_id, "s2member_subscr_id");
|
154 |
delete_user_option ($user_id, "s2member_subscr_gateway");
|
155 |
-
|
156 |
delete_user_option ($user_id, "s2member_ipn_signup_vars");
|
157 |
if (!apply_filters ("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars ()))
|
158 |
delete_user_option ($user_id, "s2member_paid_registration_times");
|
159 |
-
|
160 |
delete_user_option ($user_id, "s2member_last_status_scan");
|
161 |
delete_user_option ($user_id, "s2member_first_payment_txn_id");
|
162 |
delete_user_option ($user_id, "s2member_last_payment_time");
|
163 |
delete_user_option ($user_id, "s2member_auto_eot_time");
|
164 |
-
|
165 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
166 |
-
|
167 |
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
168 |
-
|
|
|
|
|
|
|
169 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
170 |
{
|
171 |
-
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url)
|
172 |
-
|
173 |
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ("auto-eot-cancellation-expiration-demotion")), $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($subscr_id)), $url)))
|
174 |
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)))
|
175 |
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)))
|
@@ -179,23 +182,22 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
179 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
180 |
{
|
181 |
if (is_array ($fields) && !empty ($fields))
|
182 |
-
foreach ($fields as $var => $val)
|
183 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
184 |
break;
|
185 |
-
|
186 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
187 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
188 |
}
|
189 |
}
|
190 |
-
/**/
|
191 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
192 |
{
|
193 |
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
|
194 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
195 |
-
|
196 |
-
$msg = $sbj = "(
|
197 |
-
$msg .=
|
198 |
-
|
199 |
$msg .= "eot_del_type: %%eot_del_type%%\n";
|
200 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
201 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
@@ -205,11 +207,11 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
205 |
$msg .= "user_login: %%user_login%%\n";
|
206 |
$msg .= "user_ip: %%user_ip%%\n";
|
207 |
$msg .= "user_id: %%user_id%%\n";
|
208 |
-
|
209 |
if (is_array ($fields) && !empty ($fields))
|
210 |
foreach ($fields as $var => $val)
|
211 |
$msg .= $var . ": %%" . $var . "%%\n";
|
212 |
-
|
213 |
$msg .= "cv0: %%cv0%%\n";
|
214 |
$msg .= "cv1: %%cv1%%\n";
|
215 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -220,7 +222,7 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
220 |
$msg .= "cv7: %%cv7%%\n";
|
221 |
$msg .= "cv8: %%cv8%%\n";
|
222 |
$msg .= "cv9: %%cv9%%";
|
223 |
-
|
224 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ("auto-eot-cancellation-expiration-demotion"), $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($subscr_id), $msg)))
|
225 |
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)))
|
226 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
@@ -230,65 +232,61 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
|
230 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
231 |
{
|
232 |
if (is_array ($fields) && !empty ($fields))
|
233 |
-
foreach ($fields as $var => $val)
|
234 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
235 |
break;
|
236 |
-
|
237 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
238 |
-
|
239 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient)
|
240 |
-
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 ()), "Content-Type: text/plain; charset=
|
241 |
}
|
242 |
-
|
243 |
-
if ($email_configs_were_on) /* Back on? */
|
244 |
c_ws_plugin__s2member_email_configs::email_config ();
|
245 |
}
|
246 |
-
|
247 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
248 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
|
249 |
-
unset
|
250 |
}
|
251 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
252 |
{
|
253 |
$eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion";
|
254 |
-
|
255 |
-
|
256 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars ());
|
257 |
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "removal-deletion");
|
258 |
-
unset
|
259 |
-
|
260 |
-
if
|
261 |
{
|
262 |
remove_user_from_blog ($user_id, $current_blog->blog_id);
|
263 |
-
|
264 |
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
|
265 |
}
|
266 |
-
|
267 |
-
|
268 |
-
/*
|
269 |
-
|
270 |
-
|
271 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
272 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
273 |
-
unset
|
274 |
}
|
275 |
-
|
276 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
277 |
do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
|
278 |
-
unset
|
279 |
}
|
280 |
}
|
281 |
}
|
282 |
}
|
283 |
}
|
284 |
-
|
285 |
-
c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients
|
286 |
-
|
287 |
-
|
288 |
do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
|
289 |
-
unset
|
290 |
-
|
291 |
-
return
|
292 |
}
|
293 |
}
|
294 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's Auto-EOT System *(EOT = End Of Term)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's Auto-EOT System *(EOT = End Of Term)*.
|
24 |
*
|
25 |
* @package s2Member\Auto_EOT_System
|
26 |
* @since 3.5
|
38 |
public static function add_auto_eot_system ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_before_add_auto_eot_system", get_defined_vars ());
|
41 |
+
|
42 |
if (!c_ws_plugin__s2member_auto_eots::delete_auto_eot_system ())
|
43 |
{
|
44 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
45 |
}
|
46 |
+
else if /* Otherwise, we can schedule? */ (function_exists ("wp_cron"))
|
47 |
{
|
48 |
wp_schedule_event (time (), "every10m", "ws_plugin__s2member_auto_eot_system__schedule");
|
49 |
+
|
50 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", true, get_defined_vars ());
|
51 |
}
|
52 |
+
else // Otherwise, it would appear that WP-Cron is not available.
|
53 |
{
|
54 |
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
55 |
}
|
65 |
public static function delete_auto_eot_system ()
|
66 |
{
|
67 |
do_action ("ws_plugin__s2member_before_delete_auto_eot_system", get_defined_vars ());
|
68 |
+
|
69 |
+
if /* Is `wp_cron()` even available? */ (function_exists ("wp_cron"))
|
70 |
{
|
71 |
+
wp_clear_scheduled_hook /* Since v3.0.3. */ ("ws_plugin__s2member_auto_eot_system__schedule");
|
72 |
+
|
73 |
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
|
74 |
}
|
75 |
+
else // Otherwise, it would appear that WP-Cron is not available.
|
76 |
{
|
77 |
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
|
78 |
}
|
79 |
}
|
80 |
/**
|
81 |
+
* Processed by WP_Cron; this handles Auto-EOTs *(EOT = End Of Term)*.
|
82 |
*
|
83 |
* If you have a HUGE userbase, increase the max EOTs per process.
|
84 |
+
* But NOTE, this runs ``$per_process`` *(per Blog)* on a Multisite Network.
|
85 |
* To increase, use: ``add_filter ("ws_plugin__s2member_auto_eot_system_per_process");``.
|
86 |
*
|
87 |
* This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`.
|
97 |
*/
|
98 |
public static function auto_eot_system ($per_process = 3)
|
99 |
{
|
100 |
+
global /* Need global DB obj. */ $wpdb;
|
101 |
+
global /* Multisite. */ $current_site, $current_blog;
|
102 |
+
|
103 |
include_once ABSPATH . "wp-admin/includes/admin.php";
|
104 |
+
|
105 |
+
@set_time_limit /* Make time for processing a larger userbase. */ (0);
|
106 |
@ini_set ("memory_limit", apply_filters ("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
|
107 |
+
|
108 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
109 |
do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
|
110 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
111 |
+
|
112 |
+
if /* Enabled? */($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
113 |
{
|
114 |
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
|
115 |
+
|
116 |
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)))
|
117 |
{
|
118 |
+
foreach /* Go through the array of EOTS. We need to (demote|delete) each of them. */ ($eots as $eot)
|
119 |
{
|
120 |
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
121 |
{
|
122 |
+
delete_user_option /* Always delete. */ ($user_id, "s2member_auto_eot_time");
|
123 |
+
|
124 |
+
if /* Do NOT process Administrator accounts. */(!$user->has_cap ("administrator"))
|
125 |
{
|
126 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
127 |
{
|
128 |
+
$eot_del_type = /* Set EOT/Del type. */ "auto-eot-cancellation-expiration-demotion";
|
129 |
+
|
|
|
130 |
$custom = get_user_option ("s2member_custom", $user_id);
|
131 |
+
$subscr_gateway = get_user_option ("s2member_subscr_gateway", $user_id);
|
132 |
$subscr_id = get_user_option ("s2member_subscr_id", $user_id);
|
133 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
134 |
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
135 |
+
|
136 |
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
|
137 |
$existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
138 |
+
|
139 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
140 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars ());
|
141 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), $eot_del_type, "modification", $demotion_role);
|
142 |
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "modification");
|
143 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
144 |
+
|
145 |
+
if /* Only if NOT the existing Role. */($existing_role !== $demotion_role)
|
146 |
+
$user->set_role /* Give User the demotion Role. */ ($demotion_role);
|
147 |
+
|
148 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
149 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
150 |
$user->remove_cap ($ccap = $cap);
|
151 |
+
|
152 |
delete_user_option ($user_id, "s2member_custom");
|
153 |
delete_user_option ($user_id, "s2member_subscr_id");
|
154 |
delete_user_option ($user_id, "s2member_subscr_gateway");
|
155 |
+
|
156 |
delete_user_option ($user_id, "s2member_ipn_signup_vars");
|
157 |
if (!apply_filters ("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars ()))
|
158 |
delete_user_option ($user_id, "s2member_paid_registration_times");
|
159 |
+
|
160 |
delete_user_option ($user_id, "s2member_last_status_scan");
|
161 |
delete_user_option ($user_id, "s2member_first_payment_txn_id");
|
162 |
delete_user_option ($user_id, "s2member_last_payment_time");
|
163 |
delete_user_option ($user_id, "s2member_auto_eot_time");
|
164 |
+
|
165 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
166 |
+
|
167 |
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
168 |
+
|
169 |
+
if($subscr_gateway && $subscr_id) // Also note the Paid Subscr. Gateway/ID so there is a reference left behind here.
|
170 |
+
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Paid Subscr. ID @ time of demotion: ".$subscr_gateway." -› ".$subscr_id);
|
171 |
+
|
172 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
173 |
{
|
174 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) // Handle EOT Notifications.
|
175 |
+
|
176 |
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ("auto-eot-cancellation-expiration-demotion")), $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($subscr_id)), $url)))
|
177 |
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)))
|
178 |
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)))
|
182 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
183 |
{
|
184 |
if (is_array ($fields) && !empty ($fields))
|
185 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
186 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
187 |
break;
|
188 |
+
|
189 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
190 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
191 |
}
|
192 |
}
|
|
|
193 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
194 |
{
|
195 |
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
|
196 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
197 |
+
|
198 |
+
$msg = $sbj = "(s2Member / API Notification Email) - EOT/Deletion";
|
199 |
+
$msg .= /* Spacing in the message body. */"\n\n";
|
200 |
+
|
201 |
$msg .= "eot_del_type: %%eot_del_type%%\n";
|
202 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
203 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
207 |
$msg .= "user_login: %%user_login%%\n";
|
208 |
$msg .= "user_ip: %%user_ip%%\n";
|
209 |
$msg .= "user_id: %%user_id%%\n";
|
210 |
+
|
211 |
if (is_array ($fields) && !empty ($fields))
|
212 |
foreach ($fields as $var => $val)
|
213 |
$msg .= $var . ": %%" . $var . "%%\n";
|
214 |
+
|
215 |
$msg .= "cv0: %%cv0%%\n";
|
216 |
$msg .= "cv1: %%cv1%%\n";
|
217 |
$msg .= "cv2: %%cv2%%\n";
|
222 |
$msg .= "cv7: %%cv7%%\n";
|
223 |
$msg .= "cv8: %%cv8%%\n";
|
224 |
$msg .= "cv9: %%cv9%%";
|
225 |
+
|
226 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ("auto-eot-cancellation-expiration-demotion"), $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($subscr_id), $msg)))
|
227 |
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)))
|
228 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
232 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
233 |
{
|
234 |
if (is_array ($fields) && !empty ($fields))
|
235 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
236 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
237 |
break;
|
238 |
+
|
239 |
+
if /* Still have a ``$sbj`` and a ``$msg``? */ ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
240 |
+
|
241 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient)
|
242 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
243 |
}
|
244 |
+
if /* Back on? */ ($email_configs_were_on)
|
|
|
245 |
c_ws_plugin__s2member_email_configs::email_config ();
|
246 |
}
|
247 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
248 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
|
249 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
250 |
}
|
251 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
252 |
{
|
253 |
$eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion";
|
254 |
+
|
255 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
256 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars ());
|
257 |
do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "removal-deletion");
|
258 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
259 |
+
|
260 |
+
if /* Multisite does NOT actually delete; ONLY removes. */(is_multisite ())
|
261 |
{
|
262 |
remove_user_from_blog ($user_id, $current_blog->blog_id);
|
263 |
+
// This will automatically trigger `eot_del_notification_urls`.
|
264 |
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
|
265 |
}
|
266 |
+
else // Otherwise, we can actually delete them.
|
267 |
+
// This will automatically trigger `eot_del_notification_urls`
|
268 |
+
wp_delete_user /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */ ($user_id);
|
269 |
+
|
270 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
271 |
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
272 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
273 |
}
|
274 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
275 |
do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
|
276 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
277 |
}
|
278 |
}
|
279 |
}
|
280 |
}
|
281 |
}
|
282 |
+
|
283 |
+
c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients /* Cleanup. */ ();
|
284 |
+
|
285 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
286 |
do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
|
287 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
288 |
+
|
289 |
+
return /* Return for uniformity. */;
|
290 |
}
|
291 |
}
|
292 |
}
|
includes/classes/brute-force.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_brute_force"))
|
21 |
{
|
22 |
/**
|
@@ -43,22 +43,21 @@ if (!class_exists ("c_ws_plugin__s2member_brute_force"))
|
|
43 |
*/
|
44 |
public static function track_failed_logins ($username = FALSE)
|
45 |
{
|
46 |
-
|
47 |
do_action ("ws_plugin__s2member_before_track_failed_logins", get_defined_vars ());
|
48 |
-
unset
|
49 |
-
|
50 |
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
51 |
{
|
52 |
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
53 |
-
|
54 |
-
|
55 |
$transient = "s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"]);
|
56 |
set_transient ($transient, (int)get_transient ($transient) + 1, $exp_secs);
|
57 |
}
|
58 |
-
/**/
|
59 |
do_action ("ws_plugin__s2member_after_track_failed_logins", get_defined_vars ());
|
60 |
-
|
61 |
-
return
|
62 |
}
|
63 |
/**
|
64 |
* Stops anyone attempting a Brute Force attack.
|
@@ -77,27 +76,26 @@ if (!class_exists ("c_ws_plugin__s2member_brute_force"))
|
|
77 |
*/
|
78 |
public static function stop_brute_force_logins ($user = FALSE)
|
79 |
{
|
80 |
-
|
81 |
do_action ("ws_plugin__s2member_before_stop_brute_force_logins", get_defined_vars ());
|
82 |
-
unset
|
83 |
-
|
84 |
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
85 |
{
|
86 |
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
87 |
-
|
88 |
-
|
89 |
$about = c_ws_plugin__s2member_utils_time::approx_time_difference (time (), time () + $exp_secs);
|
90 |
-
|
91 |
if ((int)get_transient ("s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"])) > $max)
|
92 |
{
|
93 |
$errors = new WP_Error ("incorrect_password", sprintf (_x ("Max failed logins. Please wait %s and try again.", "s2member-front", "s2member"), $about));
|
94 |
-
|
95 |
-
|
96 |
do_action ("ws_plugin__s2member_during_stop_brute_force_logins", get_defined_vars ());
|
97 |
-
unset
|
98 |
}
|
99 |
}
|
100 |
-
/**/
|
101 |
return apply_filters ("ws_plugin__s2member_stop_brute_force_logins", ((!empty ($errors)) ? $errors : $user), get_defined_vars ());
|
102 |
}
|
103 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_brute_force"))
|
21 |
{
|
22 |
/**
|
43 |
*/
|
44 |
public static function track_failed_logins ($username = FALSE)
|
45 |
{
|
46 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
47 |
do_action ("ws_plugin__s2member_before_track_failed_logins", get_defined_vars ());
|
48 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
49 |
+
|
50 |
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
51 |
{
|
52 |
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
53 |
+
// If you add Filters to this value, you should use a string that is compatible with PHP's strtotime() function.
|
54 |
+
|
55 |
$transient = "s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"]);
|
56 |
set_transient ($transient, (int)get_transient ($transient) + 1, $exp_secs);
|
57 |
}
|
|
|
58 |
do_action ("ws_plugin__s2member_after_track_failed_logins", get_defined_vars ());
|
59 |
+
|
60 |
+
return /* Return for uniformity. */;
|
61 |
}
|
62 |
/**
|
63 |
* Stops anyone attempting a Brute Force attack.
|
76 |
*/
|
77 |
public static function stop_brute_force_logins ($user = FALSE)
|
78 |
{
|
79 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
80 |
do_action ("ws_plugin__s2member_before_stop_brute_force_logins", get_defined_vars ());
|
81 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
82 |
+
|
83 |
if (($max = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]))
|
84 |
{
|
85 |
$exp_secs = strtotime ("+" . apply_filters ("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes", get_defined_vars ())) - time ();
|
86 |
+
// If you add Filters to this value, you should use a string that is compatible with PHP's strtotime() function.
|
87 |
+
|
88 |
$about = c_ws_plugin__s2member_utils_time::approx_time_difference (time (), time () + $exp_secs);
|
89 |
+
|
90 |
if ((int)get_transient ("s2m_ipr_" . md5 ("s2member_transient_failed_login_attempts_" . $_SERVER["REMOTE_ADDR"])) > $max)
|
91 |
{
|
92 |
$errors = new WP_Error ("incorrect_password", sprintf (_x ("Max failed logins. Please wait %s and try again.", "s2member-front", "s2member"), $about));
|
93 |
+
|
94 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
95 |
do_action ("ws_plugin__s2member_during_stop_brute_force_logins", get_defined_vars ());
|
96 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
97 |
}
|
98 |
}
|
|
|
99 |
return apply_filters ("ws_plugin__s2member_stop_brute_force_logins", ((!empty ($errors)) ? $errors : $user), get_defined_vars ());
|
100 |
}
|
101 |
}
|
includes/classes/cache.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cache"))
|
21 |
{
|
22 |
/**
|
@@ -43,65 +43,61 @@ if (!class_exists ("c_ws_plugin__s2member_cache"))
|
|
43 |
public static function cached_page_links ()
|
44 |
{
|
45 |
do_action ("ws_plugin__s2member_before_cached_page_links", get_defined_vars ());
|
46 |
-
|
47 |
$lwp = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
48 |
$mop = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
49 |
$fdlep = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
50 |
-
|
51 |
$lwp_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
|
52 |
$mop_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
|
53 |
$fdlep_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
|
54 |
-
|
55 |
$links = array ("login_welcome_page" => "", "membership_options_page" => "", "file_download_limit_exceeded_page" => "");
|
56 |
-
|
57 |
if (isset ($lwp_cache["page"], $lwp_cache["time"], $lwp_cache["link"]) && $lwp_cache["page"] === $lwp && $lwp_cache["time"] >= strtotime ("-15 minutes") && $lwp_cache["link"])
|
58 |
{
|
59 |
$links["login_welcome_page"] = $lwp_cache["link"];
|
60 |
}
|
61 |
-
else
|
62 |
{
|
63 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $lwp;
|
64 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = time ();
|
65 |
$links["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($lwp);
|
66 |
-
|
67 |
-
$cache_needs_updating =
|
68 |
}
|
69 |
-
/**/
|
70 |
if (isset ($mop_cache["page"], $mop_cache["time"], $mop_cache["link"]) && $mop_cache["page"] === $mop && $mop_cache["time"] >= strtotime ("-15 minutes") && $mop_cache["link"])
|
71 |
{
|
72 |
$links["membership_options_page"] = $mop_cache["link"];
|
73 |
}
|
74 |
-
else
|
75 |
{
|
76 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $mop;
|
77 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = time ();
|
78 |
$links["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($mop);
|
79 |
-
|
80 |
-
$cache_needs_updating =
|
81 |
}
|
82 |
-
/**/
|
83 |
if (isset ($fdlep_cache["page"], $fdlep_cache["time"], $fdlep_cache["link"]) && $fdlep_cache["page"] === $fdlep && $fdlep_cache["time"] >= strtotime ("-15 minutes") && $fdlep_cache["link"])
|
84 |
{
|
85 |
$links["file_download_limit_exceeded_page"] = $fdlep_cache["link"];
|
86 |
}
|
87 |
-
else
|
88 |
{
|
89 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $fdlep;
|
90 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = time ();
|
91 |
$links["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($fdlep);
|
92 |
-
|
93 |
-
$cache_needs_updating =
|
94 |
}
|
95 |
-
|
96 |
-
if ($cache_needs_updating) /* Cache is also reset dynamically during back-end option updates. */
|
97 |
{
|
98 |
update_option ("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]);
|
99 |
}
|
100 |
-
|
101 |
-
|
102 |
-
foreach ($links as &$link) /* Conversions for SSL and non-SSL mode. */
|
103 |
$link = preg_replace ("/^https?\:\/\//i", $scheme . "://", $link);
|
104 |
-
|
105 |
return apply_filters ("ws_plugin__s2member_cached_page_links", $links, get_defined_vars ());
|
106 |
}
|
107 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cache"))
|
21 |
{
|
22 |
/**
|
43 |
public static function cached_page_links ()
|
44 |
{
|
45 |
do_action ("ws_plugin__s2member_before_cached_page_links", get_defined_vars ());
|
46 |
+
|
47 |
$lwp = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
48 |
$mop = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
49 |
$fdlep = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
50 |
+
|
51 |
$lwp_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
|
52 |
$mop_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
|
53 |
$fdlep_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
|
54 |
+
|
55 |
$links = array ("login_welcome_page" => "", "membership_options_page" => "", "file_download_limit_exceeded_page" => "");
|
56 |
+
|
57 |
if (isset ($lwp_cache["page"], $lwp_cache["time"], $lwp_cache["link"]) && $lwp_cache["page"] === $lwp && $lwp_cache["time"] >= strtotime ("-15 minutes") && $lwp_cache["link"])
|
58 |
{
|
59 |
$links["login_welcome_page"] = $lwp_cache["link"];
|
60 |
}
|
61 |
+
else // Otherwise, query the database using ``get_page_link()`` and update the cache.
|
62 |
{
|
63 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $lwp;
|
64 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = time ();
|
65 |
$links["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($lwp);
|
66 |
+
|
67 |
+
$cache_needs_updating = /* Flag for cache update. */ true;
|
68 |
}
|
|
|
69 |
if (isset ($mop_cache["page"], $mop_cache["time"], $mop_cache["link"]) && $mop_cache["page"] === $mop && $mop_cache["time"] >= strtotime ("-15 minutes") && $mop_cache["link"])
|
70 |
{
|
71 |
$links["membership_options_page"] = $mop_cache["link"];
|
72 |
}
|
73 |
+
else // Otherwise, query the database using ``get_page_link()`` and update the cache.
|
74 |
{
|
75 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $mop;
|
76 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = time ();
|
77 |
$links["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($mop);
|
78 |
+
|
79 |
+
$cache_needs_updating = /* Flag for cache update. */ true;
|
80 |
}
|
|
|
81 |
if (isset ($fdlep_cache["page"], $fdlep_cache["time"], $fdlep_cache["link"]) && $fdlep_cache["page"] === $fdlep && $fdlep_cache["time"] >= strtotime ("-15 minutes") && $fdlep_cache["link"])
|
82 |
{
|
83 |
$links["file_download_limit_exceeded_page"] = $fdlep_cache["link"];
|
84 |
}
|
85 |
+
else // Otherwise, query the database using ``get_page_link()`` and update the cache.
|
86 |
{
|
87 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $fdlep;
|
88 |
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = time ();
|
89 |
$links["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($fdlep);
|
90 |
+
|
91 |
+
$cache_needs_updating = /* Flag for cache update. */ true;
|
92 |
}
|
93 |
+
if /* Cache is also reset dynamically during back-end option updates. */ ($cache_needs_updating)
|
|
|
94 |
{
|
95 |
update_option ("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]);
|
96 |
}
|
97 |
+
$scheme = /* SSL mode? */ (is_ssl ()) ? "https" : "http";
|
98 |
+
foreach /* Conversions for SSL and non-SSL mode. */ ($links as &$link)
|
|
|
99 |
$link = preg_replace ("/^https?\:\/\//i", $scheme . "://", $link);
|
100 |
+
|
101 |
return apply_filters ("ws_plugin__s2member_cached_page_links", $links, get_defined_vars ());
|
102 |
}
|
103 |
}
|
includes/classes/catgs-sp.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's Category protection routines *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's Category protection routines *(
|
24 |
*
|
25 |
* @package s2Member\Categories
|
26 |
* @since 3.5
|
@@ -28,62 +28,60 @@ if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
|
|
28 |
class c_ws_plugin__s2member_catgs_sp
|
29 |
{
|
30 |
/**
|
31 |
-
* Handles Category Level Access *(
|
32 |
*
|
33 |
* @package s2Member\Categories
|
34 |
* @since 3.5
|
35 |
*
|
36 |
* @param int|str $cat_id Numeric Category ID.
|
37 |
* @param bool $check_user Test permissions against the current User? Defaults to true.
|
38 |
-
* @return null|array Non-empty array (
|
39 |
*/
|
40 |
public static function check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars ());
|
43 |
-
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars ());
|
45 |
-
|
46 |
if (!$excluded && is_numeric ($cat_id) && ($cat_id = (int)$cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
-
$cat_uri =
|
49 |
-
|
50 |
-
if
|
51 |
{
|
52 |
-
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
53 |
-
|
54 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")))
|
55 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
56 |
-
|
57 |
-
else if
|
58 |
{
|
59 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
60 |
{
|
61 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
62 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
63 |
-
|
64 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
65 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
66 |
-
|
67 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])
|
68 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
|
69 |
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
70 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
71 |
}
|
72 |
-
|
73 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
74 |
{
|
75 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
76 |
-
|
77 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
78 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
79 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
80 |
}
|
81 |
}
|
82 |
-
/**/
|
83 |
do_action ("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars ());
|
84 |
}
|
85 |
}
|
86 |
-
/**/
|
87 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars ());
|
88 |
}
|
89 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's Category protection routines *(for specific Categories)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's Category protection routines *(for specific Categories)*.
|
24 |
*
|
25 |
* @package s2Member\Categories
|
26 |
* @since 3.5
|
28 |
class c_ws_plugin__s2member_catgs_sp
|
29 |
{
|
30 |
/**
|
31 |
+
* Handles Category Level Access *(for specific Categories)*.
|
32 |
*
|
33 |
* @package s2Member\Categories
|
34 |
* @since 3.5
|
35 |
*
|
36 |
* @param int|str $cat_id Numeric Category ID.
|
37 |
* @param bool $check_user Test permissions against the current User? Defaults to true.
|
38 |
+
* @return null|array Non-empty array (with details) if access is denied, else null if access is allowed.
|
39 |
*/
|
40 |
public static function check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars ());
|
43 |
+
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars ());
|
45 |
+
|
46 |
if (!$excluded && is_numeric ($cat_id) && ($cat_id = (int)$cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
+
$cat_uri = /* Get a full valid URI for this Category. */ c_ws_plugin__s2member_utils_urls::parse_uri (get_category_link ($cat_id));
|
49 |
+
|
50 |
+
if /* Do NOT touch WordPress® Systematics. */ (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page (null, $cat_uri))
|
51 |
{
|
52 |
+
$user = /* Current User's object. */(is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
53 |
+
|
54 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")))
|
55 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
56 |
+
|
57 |
+
else if /* Never restrict Systematics. However, there is 1 exception ^. */ (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $cat_uri))
|
58 |
{
|
59 |
+
for /* Category Level restrictions. Go through each Level. We also check nested Categories. */ ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
60 |
{
|
61 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
62 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
63 |
+
|
64 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
65 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
66 |
+
|
67 |
+
else if /* Check Category ancestry. */ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])
|
68 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
|
69 |
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
70 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
71 |
}
|
72 |
+
|
73 |
+
for /* URIs. Go through each Level. */ ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
74 |
{
|
75 |
+
if /* URIs configured at this Level? */ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
76 |
+
|
77 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
78 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
79 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
80 |
}
|
81 |
}
|
|
|
82 |
do_action ("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars ());
|
83 |
}
|
84 |
}
|
|
|
85 |
return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars ());
|
86 |
}
|
87 |
}
|
includes/classes/catgs.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's Category protection routines *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_catgs"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's Category protection routines *(
|
24 |
*
|
25 |
* @package s2Member\Categories
|
26 |
* @since 3.5
|
@@ -28,7 +28,7 @@ if (!class_exists ("c_ws_plugin__s2member_catgs"))
|
|
28 |
class c_ws_plugin__s2member_catgs
|
29 |
{
|
30 |
/**
|
31 |
-
* Handles Category Level Access *(
|
32 |
*
|
33 |
* @package s2Member\Categories
|
34 |
* @since 3.5
|
@@ -37,54 +37,51 @@ if (!class_exists ("c_ws_plugin__s2member_catgs"))
|
|
37 |
*/
|
38 |
public static function check_catg_level_access ()
|
39 |
{
|
40 |
-
global
|
41 |
-
|
42 |
do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
|
43 |
-
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
45 |
-
|
46 |
if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && ($cat_id = (int)$cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
-
if
|
49 |
{
|
50 |
-
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
51 |
-
|
52 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")))
|
53 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
54 |
-
|
55 |
-
else if
|
56 |
{
|
57 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
58 |
{
|
59 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
60 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
61 |
-
|
62 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
63 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
64 |
-
|
65 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]
|
66 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
|
67 |
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
68 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
69 |
}
|
70 |
-
|
71 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
|
72 |
{
|
73 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
74 |
-
|
75 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
76 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
77 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit ();
|
78 |
}
|
79 |
}
|
80 |
-
/**/
|
81 |
do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
|
82 |
}
|
83 |
}
|
84 |
-
/**/
|
85 |
do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
|
86 |
-
|
87 |
-
return
|
88 |
}
|
89 |
}
|
90 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's Category protection routines *(for current page)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_catgs"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's Category protection routines *(for current page)*.
|
24 |
*
|
25 |
* @package s2Member\Categories
|
26 |
* @since 3.5
|
28 |
class c_ws_plugin__s2member_catgs
|
29 |
{
|
30 |
/**
|
31 |
+
* Handles Category Level Access *(for current page)*.
|
32 |
*
|
33 |
* @package s2Member\Categories
|
34 |
* @since 3.5
|
37 |
*/
|
38 |
public static function check_catg_level_access ()
|
39 |
{
|
40 |
+
global /* ``get_the_ID()`` is NOT available outside The Loop. */ $post;
|
41 |
+
|
42 |
do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
|
43 |
+
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
45 |
+
|
46 |
if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && ($cat_id = (int)$cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
+
if /* Do NOT touch WordPress® Systematics. This excludes all WordPress® Systematics. */ (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page ())
|
49 |
{
|
50 |
+
$user = /* Current User's object. */ (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
51 |
+
|
52 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")))
|
53 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
54 |
+
|
55 |
+
else if /* Do NOT protect Systematics. However, there is 1 exception above. */ (!c_ws_plugin__s2member_systematics::is_systematic_use_page ())
|
56 |
{
|
57 |
+
for /* Category Level restrictions. Go through each Level. We also check nested Categories. */ ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
58 |
{
|
59 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
60 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
61 |
+
|
62 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
63 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
64 |
+
|
65 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] /* Check Category ancestry. */)
|
66 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
|
67 |
if ($catg && cat_is_ancestor_of ($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
68 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
69 |
}
|
70 |
+
for /* URIs. Go through each Level. */ ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
|
|
71 |
{
|
72 |
+
if /* URIs configured at this Level? */ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
73 |
+
|
74 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
75 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
76 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit ();
|
77 |
}
|
78 |
}
|
|
|
79 |
do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
|
80 |
}
|
81 |
}
|
|
|
82 |
do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
|
83 |
+
|
84 |
+
return /* For uniformity. */;
|
85 |
}
|
86 |
}
|
87 |
}
|
includes/classes/check-activation.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_check_activation"))
|
21 |
{
|
22 |
/**
|
@@ -37,7 +37,7 @@ if (!class_exists ("c_ws_plugin__s2member_check_activation"))
|
|
37 |
*
|
38 |
* @return null
|
39 |
*/
|
40 |
-
public static function check ()
|
41 |
{
|
42 |
if (!($v = get_option ("ws_plugin__s2member_activated_version")) || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
|
43 |
{
|
@@ -51,8 +51,7 @@ if (!class_exists ("c_ws_plugin__s2member_check_activation"))
|
|
51 |
{
|
52 |
c_ws_plugin__s2member_installation::activate ("levels");
|
53 |
}
|
54 |
-
|
55 |
-
return; /* Return for uniformity. */
|
56 |
}
|
57 |
}
|
58 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_check_activation"))
|
21 |
{
|
22 |
/**
|
37 |
*
|
38 |
* @return null
|
39 |
*/
|
40 |
+
public static function check ()
|
41 |
{
|
42 |
if (!($v = get_option ("ws_plugin__s2member_activated_version")) || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
|
43 |
{
|
51 |
{
|
52 |
c_ws_plugin__s2member_installation::activate ("levels");
|
53 |
}
|
54 |
+
return /* Return for uniformity. */;
|
|
|
55 |
}
|
56 |
}
|
57 |
}
|
includes/classes/constants.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's API Constants *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_constants"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's API Constants *(
|
24 |
*
|
25 |
* @package s2Member\API_Constants
|
26 |
* @since 3.5
|
@@ -44,15 +44,15 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
44 |
public static function constants ()
|
45 |
{
|
46 |
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
|
47 |
-
|
48 |
$links = c_ws_plugin__s2member_cache::cached_page_links ();
|
49 |
-
|
50 |
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && $user->ID) ? $user : false;
|
51 |
-
|
52 |
$level = c_ws_plugin__s2member_user_access::user_access_level ($user);
|
53 |
$file_downloads = c_ws_plugin__s2member_files::user_downloads ($user);
|
54 |
$login_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user);
|
55 |
-
|
56 |
$custom = ($user) ? get_user_option ("s2member_custom", $user->ID) : "";
|
57 |
$subscr_id = ($user) ? get_user_option ("s2member_subscr_id", $user->ID) : "";
|
58 |
$subscr_gateway = ($user) ? get_user_option ("s2member_subscr_gateway", $user->ID) : "";
|
@@ -60,10 +60,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
60 |
$custom_fields = ($user) ? get_user_option ("s2member_custom_fields", $user->ID) : array ();
|
61 |
$paid_registration_times = ($user) ? get_user_option ("s2member_paid_registration_times", $user->ID) : array ();
|
62 |
$login_counter = ($user) ? (int)get_user_option ("s2member_login_counter") : -1;
|
63 |
-
|
64 |
-
|
65 |
do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
|
66 |
-
unset
|
67 |
/**
|
68 |
* Current version of s2Member.
|
69 |
*
|
@@ -250,7 +250,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
250 |
* The current User's Membership Access Label.
|
251 |
*
|
252 |
* As configured by the site owner. Each Membership Level is associated with a Membership Label
|
253 |
-
* *(
|
254 |
*
|
255 |
* An empty string if NOT logged-in.
|
256 |
*
|
@@ -284,7 +284,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
284 |
if (!defined ("S2MEMBER_CURRENT_USER_ACCESS_LABEL"))
|
285 |
define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]));
|
286 |
/**
|
287 |
-
* The current User's Paid Subscription ID (
|
288 |
*
|
289 |
* An empty string if NOT logged-in.
|
290 |
*
|
@@ -322,7 +322,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
322 |
if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_ID"))
|
323 |
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", ($c[] = (($user) ? (string)$subscr_id : "")));
|
324 |
/**
|
325 |
-
* The current User's Paid Subscription ID (
|
326 |
* otherwise, this will contain their WordPress® User ID.
|
327 |
*
|
328 |
* An empty string if NOT logged-in.
|
@@ -361,7 +361,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
361 |
if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID"))
|
362 |
define ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID", ($c[] = (($user) ? (($subscr_id) ? (string)$subscr_id : (string)$user->ID) : "")));
|
363 |
/**
|
364 |
-
* The current User's Paid Subscription Gateway Code (
|
365 |
*
|
366 |
* Usually one of these values: `paypal`, `authnet`, `clickbank`, `google`, `ccbill`, `alipay`.
|
367 |
*
|
@@ -822,7 +822,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
822 |
if (!defined ("S2MEMBER_CURRENT_USER_EMAIL"))
|
823 |
define ("S2MEMBER_CURRENT_USER_EMAIL", ($c[] = (($user) ? (string)$user->user_email : "")));
|
824 |
/**
|
825 |
-
* The current User's IP Address (
|
826 |
*
|
827 |
* This is the current IP Address, taken from ``$_SERVER["REMOTE_ADDR"]``.
|
828 |
*
|
@@ -1050,7 +1050,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1050 |
*
|
1051 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1052 |
*
|
1053 |
-
* @see `Dashboard
|
1054 |
*/
|
1055 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED"))
|
1056 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", ($c[] = (int)$file_downloads["allowed"]));
|
@@ -1104,7 +1104,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1104 |
*
|
1105 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1106 |
*
|
1107 |
-
* @see `Dashboard
|
1108 |
*/
|
1109 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED"))
|
1110 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", ($c[] = (($file_downloads["allowed"] >= 999999999) ? true : false)));
|
@@ -1149,7 +1149,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1149 |
*
|
1150 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1151 |
*
|
1152 |
-
* @see `Dashboard
|
1153 |
*/
|
1154 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY"))
|
1155 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", ($c[] = (int)$file_downloads["currently"]));
|
@@ -1194,7 +1194,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1194 |
*
|
1195 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1196 |
*
|
1197 |
-
* @see `Dashboard
|
1198 |
*/
|
1199 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS"))
|
1200 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$file_downloads["allowed_days"]));
|
@@ -1249,7 +1249,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1249 |
*
|
1250 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1251 |
*
|
1252 |
-
* @see `Dashboard
|
1253 |
*/
|
1254 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID"))
|
1255 |
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]));
|
@@ -1289,7 +1289,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1289 |
*
|
1290 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1291 |
*
|
1292 |
-
* @see `Dashboard
|
1293 |
*/
|
1294 |
if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID"))
|
1295 |
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]));
|
@@ -1329,14 +1329,14 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1329 |
*
|
1330 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1331 |
*
|
1332 |
-
* @see `Dashboard
|
1333 |
*/
|
1334 |
if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_ID"))
|
1335 |
define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
1336 |
/**
|
1337 |
* A URL, which leads to the Stand-Alone Profile Modification Page.
|
1338 |
*
|
1339 |
-
* This is always a reference to `/?s2member_profile=1` *(
|
1340 |
*
|
1341 |
* ———— Quick PHP Code Sample ————
|
1342 |
* ```
|
@@ -1368,7 +1368,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1368 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
|
1369 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
|
1370 |
*
|
1371 |
-
* @see `Dashboard
|
1372 |
*/
|
1373 |
if (!defined ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL"))
|
1374 |
define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = (string)site_url ("/?s2member_profile=1")));
|
@@ -1423,7 +1423,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1423 |
*
|
1424 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1425 |
*
|
1426 |
-
* @see `Dashboard
|
1427 |
*/
|
1428 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL"))
|
1429 |
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
|
@@ -1463,10 +1463,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1463 |
*
|
1464 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1465 |
*
|
1466 |
-
* @see `Dashboard
|
1467 |
*/
|
1468 |
if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL"))
|
1469 |
-
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"]));
|
1470 |
/**
|
1471 |
* The URL, which leads to the Login Welcome Page; as configured by the site owner.
|
1472 |
*
|
@@ -1503,7 +1503,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1503 |
*
|
1504 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1505 |
*
|
1506 |
-
* @see `Dashboard
|
1507 |
*/
|
1508 |
if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_URL"))
|
1509 |
define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
|
@@ -1546,7 +1546,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1546 |
* @see http://codex.wordpress.org/Function_Reference/wp_logout_url wp_logout_url()
|
1547 |
*/
|
1548 |
if (!defined ("S2MEMBER_LOGOUT_PAGE_URL"))
|
1549 |
-
define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ()));
|
1550 |
/**
|
1551 |
* The URL, where a User can log into their account.
|
1552 |
*
|
@@ -1586,9 +1586,9 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1586 |
* @see http://codex.wordpress.org/Function_Reference/wp_login_url wp_login_url()
|
1587 |
*/
|
1588 |
if (!defined ("S2MEMBER_LOGIN_PAGE_URL"))
|
1589 |
-
define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url
|
1590 |
/**
|
1591 |
-
* Each Membership Level (
|
1592 |
*
|
1593 |
* The defaults are as follows:
|
1594 |
* o Level #0 ``S2MEMBER_LEVEL0_LABEL`` = Free Subscriber
|
@@ -1625,7 +1625,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1625 |
*
|
1626 |
* @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
|
1627 |
*
|
1628 |
-
* @see `Dashboard
|
1629 |
*/
|
1630 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1631 |
{
|
@@ -1677,7 +1677,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1677 |
*
|
1678 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1679 |
*
|
1680 |
-
* @see `Dashboard
|
1681 |
*/
|
1682 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1683 |
{
|
@@ -1730,7 +1730,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1730 |
*
|
1731 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1732 |
*
|
1733 |
-
* @see `Dashboard
|
1734 |
*/
|
1735 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1736 |
{
|
@@ -1774,7 +1774,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1774 |
* @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
|
1775 |
* @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
|
1776 |
*
|
1777 |
-
* @see `Dashboard
|
1778 |
*/
|
1779 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS"))
|
1780 |
define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]));
|
@@ -1801,7 +1801,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1801 |
*
|
1802 |
* @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_EMAIL
|
1803 |
*
|
1804 |
-
* @see `Dashboard
|
1805 |
*/
|
1806 |
if (!defined ("S2MEMBER_REG_EMAIL_FROM_NAME"))
|
1807 |
define ("S2MEMBER_REG_EMAIL_FROM_NAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]));
|
@@ -1828,7 +1828,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1828 |
*
|
1829 |
* @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_NAME
|
1830 |
*
|
1831 |
-
* @see `Dashboard
|
1832 |
*/
|
1833 |
if (!defined ("S2MEMBER_REG_EMAIL_FROM_EMAIL"))
|
1834 |
define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]));
|
@@ -1856,7 +1856,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1856 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
|
1857 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
|
1858 |
*
|
1859 |
-
* @see `Dashboard
|
1860 |
*/
|
1861 |
if (!defined ("S2MEMBER_PAYPAL_NOTIFY_URL"))
|
1862 |
define ("S2MEMBER_PAYPAL_NOTIFY_URL", ($c[] = (string)site_url ("/?s2member_paypal_notify=1")));
|
@@ -1884,7 +1884,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1884 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
|
1885 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
|
1886 |
*
|
1887 |
-
* @see `Dashboard
|
1888 |
*/
|
1889 |
if (!defined ("S2MEMBER_PAYPAL_RETURN_URL"))
|
1890 |
define ("S2MEMBER_PAYPAL_RETURN_URL", ($c[] = (string)site_url ("/?s2member_paypal_return=1")));
|
@@ -1913,12 +1913,12 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1913 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
1914 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
1915 |
*
|
1916 |
-
* @see `Dashboard
|
1917 |
*/
|
1918 |
if (!defined ("S2MEMBER_PAYPAL_BUSINESS"))
|
1919 |
define ("S2MEMBER_PAYPAL_BUSINESS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]));
|
1920 |
/**
|
1921 |
-
* PayPal® endpoint domain (
|
1922 |
*
|
1923 |
* o In Sandbox Mode, this is: `www.sandbox.paypal.com`.
|
1924 |
* o In Production Mode, this is: `www.paypal.com`.
|
@@ -1943,12 +1943,12 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1943 |
*
|
1944 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_ENDPOINT
|
1945 |
*
|
1946 |
-
* @see `Dashboard
|
1947 |
*/
|
1948 |
if (!defined ("S2MEMBER_PAYPAL_ENDPOINT"))
|
1949 |
define ("S2MEMBER_PAYPAL_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")));
|
1950 |
/**
|
1951 |
-
* PayPal® API endpoint domain (
|
1952 |
*
|
1953 |
* o In Sandbox Mode, this is: `api-3t.sandbox.paypal.com`.
|
1954 |
* o In Production Mode, this is: `api-3t.paypal.com`.
|
@@ -1973,7 +1973,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
1973 |
*
|
1974 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_ENDPOINT
|
1975 |
*
|
1976 |
-
* @see `Dashboard
|
1977 |
*/
|
1978 |
if (!defined ("S2MEMBER_PAYPAL_API_ENDPOINT"))
|
1979 |
define ("S2MEMBER_PAYPAL_API_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com")));
|
@@ -2001,7 +2001,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2001 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
2002 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
2003 |
*
|
2004 |
-
* @see `Dashboard
|
2005 |
*/
|
2006 |
if (!defined ("S2MEMBER_PAYPAL_API_USERNAME"))
|
2007 |
define ("S2MEMBER_PAYPAL_API_USERNAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]));
|
@@ -2029,7 +2029,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2029 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
|
2030 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
2031 |
*
|
2032 |
-
* @see `Dashboard
|
2033 |
*/
|
2034 |
if (!defined ("S2MEMBER_PAYPAL_API_PASSWORD"))
|
2035 |
define ("S2MEMBER_PAYPAL_API_PASSWORD", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]));
|
@@ -2057,7 +2057,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2057 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
|
2058 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
2059 |
*
|
2060 |
-
* @see `Dashboard
|
2061 |
*/
|
2062 |
if (!defined ("S2MEMBER_PAYPAL_API_SIGNATURE"))
|
2063 |
define ("S2MEMBER_PAYPAL_API_SIGNATURE", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]));
|
@@ -2084,7 +2084,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2084 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
|
2085 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
|
2086 |
*
|
2087 |
-
* @see `Dashboard
|
2088 |
*/
|
2089 |
if (!defined ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN"))
|
2090 |
define ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]));
|
@@ -2095,7 +2095,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2095 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2096 |
*
|
2097 |
* Note. This API Constant is excluded from the ``$c[]`` hash calculation used in the generation of {@link s2Member\API_Constants\WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5}.
|
2098 |
-
* It MUST be excluded, because the value of this particular API Constant will change too often *(
|
2099 |
* So, when including this API Constant in the JavaScript API as a Global, care must be taken to build an Invoice, using JavaScript
|
2100 |
* to calculate the unique time-based code, with something like: `Math.round (new Date ().getTime ())`.
|
2101 |
*
|
@@ -2111,10 +2111,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2111 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2112 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2113 |
*
|
2114 |
-
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(
|
2115 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2116 |
*
|
2117 |
-
* Instead of forcing a Member *(
|
2118 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2119 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2120 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
@@ -2144,14 +2144,14 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2144 |
*
|
2145 |
* @see s2Member\API_Functions\s2member_value_for_pp_inv()
|
2146 |
*
|
2147 |
-
* @see `Dashboard
|
2148 |
*/
|
2149 |
if (!defined ("S2MEMBER_VALUE_FOR_PP_INV"))
|
2150 |
define ("S2MEMBER_VALUE_FOR_PP_INV", uniqid () . "~" . S2MEMBER_CURRENT_USER_IP);
|
2151 |
/**
|
2152 |
* PayPal® value for Payment Buttons with input name: `on0`.
|
2153 |
*
|
2154 |
-
* Used in PayPal® Modification Buttons *(
|
2155 |
*
|
2156 |
* This auto-fills the `on0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
|
2157 |
* this will auto-fill the value for the `on0` input variable, with the string: "Referencing Customer ID".
|
@@ -2169,10 +2169,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2169 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2170 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2171 |
*
|
2172 |
-
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(
|
2173 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2174 |
*
|
2175 |
-
* Instead of forcing a Member *(
|
2176 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2177 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2178 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
@@ -2202,18 +2202,18 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2202 |
*
|
2203 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0
|
2204 |
*
|
2205 |
-
* @see `Dashboard
|
2206 |
*/
|
2207 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0"))
|
2208 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? "Referencing Customer ID" : "Originating Domain")));
|
2209 |
/**
|
2210 |
* PayPal® value for Payment Buttons with input name: `os0`.
|
2211 |
*
|
2212 |
-
* Used in PayPal® Modification Buttons *(
|
2213 |
*
|
2214 |
* This auto-fills the `os0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
|
2215 |
* this will auto-fill the value for the `os0` input variable, with the value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID}.
|
2216 |
-
* Otherwise, it will be set to a default value of ``$_SERVER["HTTP_HOST"]`` *(
|
2217 |
*
|
2218 |
* These five API Constants are special.
|
2219 |
* o {@link s2Member\API_Constants\S2MEMBER_VALUE_FOR_PP_INV}
|
@@ -2227,10 +2227,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2227 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2228 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2229 |
*
|
2230 |
-
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(
|
2231 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2232 |
*
|
2233 |
-
* Instead of forcing a Member *(
|
2234 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2235 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2236 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
@@ -2260,7 +2260,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2260 |
*
|
2261 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0
|
2262 |
*
|
2263 |
-
* @see `Dashboard
|
2264 |
*/
|
2265 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0"))
|
2266 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID : (string)$_SERVER["HTTP_HOST"])));
|
@@ -2282,10 +2282,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2282 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2283 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2284 |
*
|
2285 |
-
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(
|
2286 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2287 |
*
|
2288 |
-
* Instead of forcing a Member *(
|
2289 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2290 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2291 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
@@ -2315,7 +2315,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2315 |
*
|
2316 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1
|
2317 |
*
|
2318 |
-
* @see `Dashboard
|
2319 |
*/
|
2320 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1"))
|
2321 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1", ($c[] = "Customer IP Address" /* Via $_SERVER["REMOTE_ADDR"] below. */));
|
@@ -2337,10 +2337,10 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2337 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2338 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2339 |
*
|
2340 |
-
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(
|
2341 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2342 |
*
|
2343 |
-
* Instead of forcing a Member *(
|
2344 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2345 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2346 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
@@ -2370,7 +2370,7 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2370 |
*
|
2371 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1
|
2372 |
*
|
2373 |
-
* @see `Dashboard
|
2374 |
*/
|
2375 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1"))
|
2376 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
|
@@ -2392,8 +2392,8 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
|
|
2392 |
Calls the after Hook. Do NOT set Constants here.
|
2393 |
*/
|
2394 |
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
|
2395 |
-
|
2396 |
-
return
|
2397 |
}
|
2398 |
}
|
2399 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's API Constants *(for site owners)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_constants"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's API Constants *(for site owners)*.
|
24 |
*
|
25 |
* @package s2Member\API_Constants
|
26 |
* @since 3.5
|
44 |
public static function constants ()
|
45 |
{
|
46 |
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
|
47 |
+
|
48 |
$links = c_ws_plugin__s2member_cache::cached_page_links ();
|
49 |
+
|
50 |
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && $user->ID) ? $user : false;
|
51 |
+
|
52 |
$level = c_ws_plugin__s2member_user_access::user_access_level ($user);
|
53 |
$file_downloads = c_ws_plugin__s2member_files::user_downloads ($user);
|
54 |
$login_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user);
|
55 |
+
|
56 |
$custom = ($user) ? get_user_option ("s2member_custom", $user->ID) : "";
|
57 |
$subscr_id = ($user) ? get_user_option ("s2member_subscr_id", $user->ID) : "";
|
58 |
$subscr_gateway = ($user) ? get_user_option ("s2member_subscr_gateway", $user->ID) : "";
|
60 |
$custom_fields = ($user) ? get_user_option ("s2member_custom_fields", $user->ID) : array ();
|
61 |
$paid_registration_times = ($user) ? get_user_option ("s2member_paid_registration_times", $user->ID) : array ();
|
62 |
$login_counter = ($user) ? (int)get_user_option ("s2member_login_counter") : -1;
|
63 |
+
|
64 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
65 |
do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
|
66 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
67 |
/**
|
68 |
* Current version of s2Member.
|
69 |
*
|
250 |
* The current User's Membership Access Label.
|
251 |
*
|
252 |
* As configured by the site owner. Each Membership Level is associated with a Membership Label
|
253 |
+
* *(i.e. Bronze, Silver, Gold, Platinum)*, or whatever the site owner has configured.
|
254 |
*
|
255 |
* An empty string if NOT logged-in.
|
256 |
*
|
284 |
if (!defined ("S2MEMBER_CURRENT_USER_ACCESS_LABEL"))
|
285 |
define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]));
|
286 |
/**
|
287 |
+
* The current User's Paid Subscription ID (when applicable).
|
288 |
*
|
289 |
* An empty string if NOT logged-in.
|
290 |
*
|
322 |
if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_ID"))
|
323 |
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", ($c[] = (($user) ? (string)$subscr_id : "")));
|
324 |
/**
|
325 |
+
* The current User's Paid Subscription ID (when applicable);
|
326 |
* otherwise, this will contain their WordPress® User ID.
|
327 |
*
|
328 |
* An empty string if NOT logged-in.
|
361 |
if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID"))
|
362 |
define ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID", ($c[] = (($user) ? (($subscr_id) ? (string)$subscr_id : (string)$user->ID) : "")));
|
363 |
/**
|
364 |
+
* The current User's Paid Subscription Gateway Code (when applicable).
|
365 |
*
|
366 |
* Usually one of these values: `paypal`, `authnet`, `clickbank`, `google`, `ccbill`, `alipay`.
|
367 |
*
|
822 |
if (!defined ("S2MEMBER_CURRENT_USER_EMAIL"))
|
823 |
define ("S2MEMBER_CURRENT_USER_EMAIL", ($c[] = (($user) ? (string)$user->user_email : "")));
|
824 |
/**
|
825 |
+
* The current User's IP Address (even if/when NOT logged-in).
|
826 |
*
|
827 |
* This is the current IP Address, taken from ``$_SERVER["REMOTE_ADDR"]``.
|
828 |
*
|
1050 |
*
|
1051 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1052 |
*
|
1053 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1054 |
*/
|
1055 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED"))
|
1056 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", ($c[] = (int)$file_downloads["allowed"]));
|
1104 |
*
|
1105 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1106 |
*
|
1107 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1108 |
*/
|
1109 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED"))
|
1110 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", ($c[] = (($file_downloads["allowed"] >= 999999999) ? true : false)));
|
1149 |
*
|
1150 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1151 |
*
|
1152 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1153 |
*/
|
1154 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY"))
|
1155 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", ($c[] = (int)$file_downloads["currently"]));
|
1194 |
*
|
1195 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1196 |
*
|
1197 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1198 |
*/
|
1199 |
if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS"))
|
1200 |
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$file_downloads["allowed_days"]));
|
1249 |
*
|
1250 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1251 |
*
|
1252 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1253 |
*/
|
1254 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID"))
|
1255 |
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]));
|
1289 |
*
|
1290 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1291 |
*
|
1292 |
+
* @see `Dashboard -› s2Member -› General Options -› Membership Options Page`
|
1293 |
*/
|
1294 |
if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID"))
|
1295 |
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]));
|
1329 |
*
|
1330 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1331 |
*
|
1332 |
+
* @see `Dashboard -› s2Member -› General Options -› Login Welcome Page`
|
1333 |
*/
|
1334 |
if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_ID"))
|
1335 |
define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
1336 |
/**
|
1337 |
* A URL, which leads to the Stand-Alone Profile Modification Page.
|
1338 |
*
|
1339 |
+
* This is always a reference to `/?s2member_profile=1` *(i.e. the Stand-Alone version)*.
|
1340 |
*
|
1341 |
* ———— Quick PHP Code Sample ————
|
1342 |
* ```
|
1368 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
|
1369 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
|
1370 |
*
|
1371 |
+
* @see `Dashboard -› s2Member -› General Options -› Profile Modifications`
|
1372 |
*/
|
1373 |
if (!defined ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL"))
|
1374 |
define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = (string)site_url ("/?s2member_profile=1")));
|
1423 |
*
|
1424 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1425 |
*
|
1426 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1427 |
*/
|
1428 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL"))
|
1429 |
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
|
1463 |
*
|
1464 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1465 |
*
|
1466 |
+
* @see `Dashboard -› s2Member -› General Options -› Membership Options Page`
|
1467 |
*/
|
1468 |
if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL"))
|
1469 |
+
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"])); // Signup page.
|
1470 |
/**
|
1471 |
* The URL, which leads to the Login Welcome Page; as configured by the site owner.
|
1472 |
*
|
1503 |
*
|
1504 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
|
1505 |
*
|
1506 |
+
* @see `Dashboard -› s2Member -› General Options -› Login Welcome Page`
|
1507 |
*/
|
1508 |
if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_URL"))
|
1509 |
define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
|
1546 |
* @see http://codex.wordpress.org/Function_Reference/wp_logout_url wp_logout_url()
|
1547 |
*/
|
1548 |
if (!defined ("S2MEMBER_LOGOUT_PAGE_URL"))
|
1549 |
+
define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ())); // This triggers `wp_nonce_tick()`; watch out for dynamic changes.
|
1550 |
/**
|
1551 |
* The URL, where a User can log into their account.
|
1552 |
*
|
1586 |
* @see http://codex.wordpress.org/Function_Reference/wp_login_url wp_login_url()
|
1587 |
*/
|
1588 |
if (!defined ("S2MEMBER_LOGIN_PAGE_URL"))
|
1589 |
+
define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url /* Will not trigger `wp_nonce_tick()`, no worries in this case. */ ()));
|
1590 |
/**
|
1591 |
+
* Each Membership Level (Label); as configured by the site owner.
|
1592 |
*
|
1593 |
* The defaults are as follows:
|
1594 |
* o Level #0 ``S2MEMBER_LEVEL0_LABEL`` = Free Subscriber
|
1625 |
*
|
1626 |
* @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
|
1627 |
*
|
1628 |
+
* @see `Dashboard -› s2Member -› General Options -› Membership Level (Labels)`
|
1629 |
*/
|
1630 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1631 |
{
|
1677 |
*
|
1678 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1679 |
*
|
1680 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1681 |
*/
|
1682 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1683 |
{
|
1730 |
*
|
1731 |
* @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
|
1732 |
*
|
1733 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1734 |
*/
|
1735 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
1736 |
{
|
1774 |
* @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
|
1775 |
* @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
|
1776 |
*
|
1777 |
+
* @see `Dashboard -› s2Member -› Download Options`
|
1778 |
*/
|
1779 |
if (!defined ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS"))
|
1780 |
define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]));
|
1801 |
*
|
1802 |
* @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_EMAIL
|
1803 |
*
|
1804 |
+
* @see `Dashboard -› s2Member -› General Options`
|
1805 |
*/
|
1806 |
if (!defined ("S2MEMBER_REG_EMAIL_FROM_NAME"))
|
1807 |
define ("S2MEMBER_REG_EMAIL_FROM_NAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]));
|
1828 |
*
|
1829 |
* @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_NAME
|
1830 |
*
|
1831 |
+
* @see `Dashboard -› s2Member -› General Options`
|
1832 |
*/
|
1833 |
if (!defined ("S2MEMBER_REG_EMAIL_FROM_EMAIL"))
|
1834 |
define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]));
|
1856 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
|
1857 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
|
1858 |
*
|
1859 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› IPN Integration`
|
1860 |
*/
|
1861 |
if (!defined ("S2MEMBER_PAYPAL_NOTIFY_URL"))
|
1862 |
define ("S2MEMBER_PAYPAL_NOTIFY_URL", ($c[] = (string)site_url ("/?s2member_paypal_notify=1")));
|
1884 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
|
1885 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
|
1886 |
*
|
1887 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Auto-Return/PDT Integration`
|
1888 |
*/
|
1889 |
if (!defined ("S2MEMBER_PAYPAL_RETURN_URL"))
|
1890 |
define ("S2MEMBER_PAYPAL_RETURN_URL", ($c[] = (string)site_url ("/?s2member_paypal_return=1")));
|
1913 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
1914 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
1915 |
*
|
1916 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
1917 |
*/
|
1918 |
if (!defined ("S2MEMBER_PAYPAL_BUSINESS"))
|
1919 |
define ("S2MEMBER_PAYPAL_BUSINESS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]));
|
1920 |
/**
|
1921 |
+
* PayPal® endpoint domain (changes when Sandbox Mode is enabled).
|
1922 |
*
|
1923 |
* o In Sandbox Mode, this is: `www.sandbox.paypal.com`.
|
1924 |
* o In Production Mode, this is: `www.paypal.com`.
|
1943 |
*
|
1944 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_ENDPOINT
|
1945 |
*
|
1946 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
1947 |
*/
|
1948 |
if (!defined ("S2MEMBER_PAYPAL_ENDPOINT"))
|
1949 |
define ("S2MEMBER_PAYPAL_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")));
|
1950 |
/**
|
1951 |
+
* PayPal® API endpoint domain (changes when Sandbox Mode is enabled).
|
1952 |
*
|
1953 |
* o In Sandbox Mode, this is: `api-3t.sandbox.paypal.com`.
|
1954 |
* o In Production Mode, this is: `api-3t.paypal.com`.
|
1973 |
*
|
1974 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_ENDPOINT
|
1975 |
*
|
1976 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
1977 |
*/
|
1978 |
if (!defined ("S2MEMBER_PAYPAL_API_ENDPOINT"))
|
1979 |
define ("S2MEMBER_PAYPAL_API_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com")));
|
2001 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
2002 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
2003 |
*
|
2004 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
2005 |
*/
|
2006 |
if (!defined ("S2MEMBER_PAYPAL_API_USERNAME"))
|
2007 |
define ("S2MEMBER_PAYPAL_API_USERNAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]));
|
2029 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
|
2030 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
|
2031 |
*
|
2032 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
2033 |
*/
|
2034 |
if (!defined ("S2MEMBER_PAYPAL_API_PASSWORD"))
|
2035 |
define ("S2MEMBER_PAYPAL_API_PASSWORD", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]));
|
2057 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
|
2058 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
|
2059 |
*
|
2060 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Account Details`
|
2061 |
*/
|
2062 |
if (!defined ("S2MEMBER_PAYPAL_API_SIGNATURE"))
|
2063 |
define ("S2MEMBER_PAYPAL_API_SIGNATURE", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]));
|
2084 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
|
2085 |
* @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
|
2086 |
*
|
2087 |
+
* @see `Dashboard -› s2Member -› PayPal® Options -› Auto-Return/PDT Integration`
|
2088 |
*/
|
2089 |
if (!defined ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN"))
|
2090 |
define ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]));
|
2095 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2096 |
*
|
2097 |
* Note. This API Constant is excluded from the ``$c[]`` hash calculation used in the generation of {@link s2Member\API_Constants\WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5}.
|
2098 |
+
* It MUST be excluded, because the value of this particular API Constant will change too often *(i.e. it changes, depending on microtime)*.
|
2099 |
* So, when including this API Constant in the JavaScript API as a Global, care must be taken to build an Invoice, using JavaScript
|
2100 |
* to calculate the unique time-based code, with something like: `Math.round (new Date ().getTime ())`.
|
2101 |
*
|
2111 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2112 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2113 |
*
|
2114 |
+
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(and/or a Free Subscriber)*, who is already logged-in
|
2115 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2116 |
*
|
2117 |
+
* Instead of forcing a Member *(and/or a Free Subscriber)* to re-register for a new account,
|
2118 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2119 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2120 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
2144 |
*
|
2145 |
* @see s2Member\API_Functions\s2member_value_for_pp_inv()
|
2146 |
*
|
2147 |
+
* @see `Dashboard -› s2Member -› PayPal® Buttons`
|
2148 |
*/
|
2149 |
if (!defined ("S2MEMBER_VALUE_FOR_PP_INV"))
|
2150 |
define ("S2MEMBER_VALUE_FOR_PP_INV", uniqid () . "~" . S2MEMBER_CURRENT_USER_IP);
|
2151 |
/**
|
2152 |
* PayPal® value for Payment Buttons with input name: `on0`.
|
2153 |
*
|
2154 |
+
* Used in PayPal® Modification Buttons *(i.e. upgrades/downgrades)*.
|
2155 |
*
|
2156 |
* This auto-fills the `on0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
|
2157 |
* this will auto-fill the value for the `on0` input variable, with the string: "Referencing Customer ID".
|
2169 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2170 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2171 |
*
|
2172 |
+
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(and/or a Free Subscriber)*, who is already logged-in
|
2173 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2174 |
*
|
2175 |
+
* Instead of forcing a Member *(and/or a Free Subscriber)* to re-register for a new account,
|
2176 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2177 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2178 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
2202 |
*
|
2203 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0
|
2204 |
*
|
2205 |
+
* @see `Dashboard -› s2Member -› PayPal® Buttons`
|
2206 |
*/
|
2207 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0"))
|
2208 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? "Referencing Customer ID" : "Originating Domain")));
|
2209 |
/**
|
2210 |
* PayPal® value for Payment Buttons with input name: `os0`.
|
2211 |
*
|
2212 |
+
* Used in PayPal® Modification Buttons *(i.e. upgrades/downgrades)*.
|
2213 |
*
|
2214 |
* This auto-fills the `os0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
|
2215 |
* this will auto-fill the value for the `os0` input variable, with the value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID}.
|
2216 |
+
* Otherwise, it will be set to a default value of ``$_SERVER["HTTP_HOST"]`` *(the originating domain name)*.
|
2217 |
*
|
2218 |
* These five API Constants are special.
|
2219 |
* o {@link s2Member\API_Constants\S2MEMBER_VALUE_FOR_PP_INV}
|
2227 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2228 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2229 |
*
|
2230 |
+
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(and/or a Free Subscriber)*, who is already logged-in
|
2231 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2232 |
*
|
2233 |
+
* Instead of forcing a Member *(and/or a Free Subscriber)* to re-register for a new account,
|
2234 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2235 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2236 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
2260 |
*
|
2261 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0
|
2262 |
*
|
2263 |
+
* @see `Dashboard -› s2Member -› PayPal® Buttons`
|
2264 |
*/
|
2265 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0"))
|
2266 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID : (string)$_SERVER["HTTP_HOST"])));
|
2282 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2283 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2284 |
*
|
2285 |
+
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(and/or a Free Subscriber)*, who is already logged-in
|
2286 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2287 |
*
|
2288 |
+
* Instead of forcing a Member *(and/or a Free Subscriber)* to re-register for a new account,
|
2289 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2290 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2291 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
2315 |
*
|
2316 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1
|
2317 |
*
|
2318 |
+
* @see `Dashboard -› s2Member -› PayPal® Buttons`
|
2319 |
*/
|
2320 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1"))
|
2321 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1", ($c[] = "Customer IP Address" /* Via $_SERVER["REMOTE_ADDR"] below. */));
|
2337 |
* The `INV` value can be used to auto-fill the `invoice` for PayPal® Button Codes, with a unique Code~IP combination.
|
2338 |
* However, in cases where multiple Buttons are displayed on the same page, the alternative {@link s2Member\API_Functions\s2member_value_for_pp_inv()} function should be used instead.
|
2339 |
*
|
2340 |
+
* The `ON0/OS0` values, are how s2Member identifies an existing Member *(and/or a Free Subscriber)*, who is already logged-in
|
2341 |
* when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
|
2342 |
*
|
2343 |
+
* Instead of forcing a Member *(and/or a Free Subscriber)* to re-register for a new account,
|
2344 |
* s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
|
2345 |
* These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
|
2346 |
* you won't even see these, because they're added internally by the Shortcode processor.
|
2370 |
*
|
2371 |
* @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1
|
2372 |
*
|
2373 |
+
* @see `Dashboard -› s2Member -› PayPal® Buttons`
|
2374 |
*/
|
2375 |
if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1"))
|
2376 |
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
|
2392 |
Calls the after Hook. Do NOT set Constants here.
|
2393 |
*/
|
2394 |
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
|
2395 |
+
|
2396 |
+
return /* Return for uniformity. */;
|
2397 |
}
|
2398 |
}
|
2399 |
}
|
includes/classes/cron-jobs-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Cron routines handled by s2Member (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* Cron routines handled by s2Member (
|
24 |
*
|
25 |
* @package s2Member\Cron_Jobs
|
26 |
* @since 3.5
|
@@ -40,12 +40,12 @@ if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
|
|
40 |
*/
|
41 |
public static function extend_cron_schedules ($schedules = array ())
|
42 |
{
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_before_extend_cron_schedules", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
$array = array ("every10m" => array ("interval" => 600, "display" => "Every 10 Minutes"));
|
48 |
-
|
49 |
return apply_filters ("ws_plugin__s2member_extend_cron_schedules", array_merge ($array, $schedules), get_defined_vars ());
|
50 |
}
|
51 |
/**
|
@@ -61,18 +61,17 @@ if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
|
|
61 |
public static function auto_eot_system_via_cron ()
|
62 |
{
|
63 |
do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
|
64 |
-
|
65 |
-
if (!empty ($_GET["s2member_auto_eot_system_via_cron"]))
|
66 |
{
|
67 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
68 |
{
|
69 |
-
c_ws_plugin__s2member_auto_eots::auto_eot_system ();
|
70 |
-
|
71 |
do_action ("ws_plugin__s2member_during_auto_eot_system_via_cron", get_defined_vars ());
|
72 |
}
|
73 |
-
exit
|
74 |
}
|
75 |
-
/**/
|
76 |
do_action ("ws_plugin__s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
77 |
}
|
78 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Cron routines handled by s2Member (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* Cron routines handled by s2Member (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\Cron_Jobs
|
26 |
* @since 3.5
|
40 |
*/
|
41 |
public static function extend_cron_schedules ($schedules = array ())
|
42 |
{
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_before_extend_cron_schedules", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
$array = array ("every10m" => array ("interval" => 600, "display" => "Every 10 Minutes"));
|
48 |
+
|
49 |
return apply_filters ("ws_plugin__s2member_extend_cron_schedules", array_merge ($array, $schedules), get_defined_vars ());
|
50 |
}
|
51 |
/**
|
61 |
public static function auto_eot_system_via_cron ()
|
62 |
{
|
63 |
do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
|
64 |
+
|
65 |
+
if /* Called through HTTP? */ (!empty ($_GET["s2member_auto_eot_system_via_cron"]))
|
66 |
{
|
67 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
68 |
{
|
69 |
+
c_ws_plugin__s2member_auto_eots::auto_eot_system (); // Process.
|
70 |
+
|
71 |
do_action ("ws_plugin__s2member_during_auto_eot_system_via_cron", get_defined_vars ());
|
72 |
}
|
73 |
+
exit /* Clean exit. */ ();
|
74 |
}
|
|
|
75 |
do_action ("ws_plugin__s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
76 |
}
|
77 |
}
|
includes/classes/cron-jobs.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
|
21 |
{
|
22 |
/**
|
@@ -38,7 +38,7 @@ if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
|
|
38 |
* @param array $schedules Expects an array of WP_Cron schedules passed in by the Filter.
|
39 |
* @return inner Return-value of inner routine.
|
40 |
*/
|
41 |
-
public static function extend_cron_schedules ($schedules = array ())
|
42 |
{
|
43 |
return c_ws_plugin__s2member_cron_jobs_in::extend_cron_schedules ($schedules);
|
44 |
}
|
@@ -54,7 +54,7 @@ if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
|
|
54 |
*/
|
55 |
public static function auto_eot_system_via_cron ()
|
56 |
{
|
57 |
-
if (!empty ($_GET["s2member_auto_eot_system_via_cron"]))
|
58 |
{
|
59 |
return c_ws_plugin__s2member_cron_jobs_in::auto_eot_system_via_cron ();
|
60 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
|
21 |
{
|
22 |
/**
|
38 |
* @param array $schedules Expects an array of WP_Cron schedules passed in by the Filter.
|
39 |
* @return inner Return-value of inner routine.
|
40 |
*/
|
41 |
+
public static function extend_cron_schedules ($schedules = array ())
|
42 |
{
|
43 |
return c_ws_plugin__s2member_cron_jobs_in::extend_cron_schedules ($schedules);
|
44 |
}
|
54 |
*/
|
55 |
public static function auto_eot_system_via_cron ()
|
56 |
{
|
57 |
+
if (!empty ($_GET["s2member_auto_eot_system_via_cron"]))
|
58 |
{
|
59 |
return c_ws_plugin__s2member_cron_jobs_in::auto_eot_system_via_cron ();
|
60 |
}
|
includes/classes/css-js-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* CSS/JS loading handlers for s2Member (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_css_js_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* CSS/JS loading handlers for s2Member (
|
24 |
*
|
25 |
* @package s2Member\CSS_JS
|
26 |
* @since 3.5
|
@@ -40,31 +40,30 @@ if(!class_exists("c_ws_plugin__s2member_css_js_in"))
|
|
40 |
public static function css()
|
41 |
{
|
42 |
do_action("ws_plugin__s2member_before_css", get_defined_vars());
|
43 |
-
|
44 |
if(!empty($_GET["ws_plugin__s2member_css"]))
|
45 |
{
|
46 |
-
status_header
|
47 |
-
|
48 |
-
header("Content-Type: text/css; charset=
|
49 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
|
50 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
51 |
header("Cache-Control: max-age=604800");
|
52 |
header("Pragma: public");
|
53 |
-
|
54 |
-
|
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");
|
60 |
-
|
61 |
include_once dirname(dirname(__FILE__))."/s2member.css";
|
62 |
-
|
63 |
do_action("ws_plugin__s2member_during_css", get_defined_vars());
|
64 |
-
|
65 |
-
exit
|
66 |
}
|
67 |
-
/**/
|
68 |
do_action("ws_plugin__s2member_after_css", get_defined_vars());
|
69 |
}
|
70 |
/**
|
@@ -82,123 +81,119 @@ if(!class_exists("c_ws_plugin__s2member_css_js_in"))
|
|
82 |
public static function js_w_globals()
|
83 |
{
|
84 |
do_action("ws_plugin__s2member_before_js_w_globals", get_defined_vars());
|
85 |
-
|
86 |
if(!empty($_GET["ws_plugin__s2member_js_w_globals"]))
|
87 |
{
|
88 |
-
status_header
|
89 |
-
|
90 |
-
header("Content-Type: application/x-javascript; charset=
|
91 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
|
92 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
93 |
header("Cache-Control: max-age=604800");
|
94 |
header("Pragma: public");
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
include_once dirname(dirname(__FILE__))."/jquery/jquery.sprintf/jquery.sprintf-min.js";
|
99 |
-
|
100 |
-
echo
|
101 |
-
|
102 |
echo "var S2MEMBER_VERSION = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_VERSION)."',";
|
103 |
-
|
104 |
echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = ".S2MEMBER_CURRENT_USER_LOGIN_COUNTER.",";
|
105 |
-
|
106 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false").",";
|
107 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false").",";
|
108 |
-
|
109 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = ".S2MEMBER_CURRENT_USER_ACCESS_LEVEL.",";
|
110 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_ACCESS_LABEL)."',";
|
111 |
-
|
112 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_ID)."',";
|
113 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID)."',";
|
114 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY)."',";
|
115 |
echo "S2MEMBER_CURRENT_USER_CUSTOM = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_CUSTOM)."',";
|
116 |
-
|
117 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_REGISTRATION_TIME.",";
|
118 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME.",";
|
119 |
-
|
120 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS.",";
|
121 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_REGISTRATION_DAYS.",";
|
122 |
-
|
123 |
echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_DISPLAY_NAME)."',";
|
124 |
echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_FIRST_NAME)."',";
|
125 |
echo "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LAST_NAME)."',";
|
126 |
-
|
127 |
echo "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LOGIN)."',";
|
128 |
echo "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_EMAIL)."',";
|
129 |
echo "S2MEMBER_CURRENT_USER_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
|
130 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_REGISTRATION_IP)."',";
|
131 |
-
|
132 |
echo "S2MEMBER_CURRENT_USER_ID = ".S2MEMBER_CURRENT_USER_ID.",";
|
133 |
echo "S2MEMBER_CURRENT_USER_FIELDS = ".S2MEMBER_CURRENT_USER_FIELDS.",";
|
134 |
-
|
135 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED.",";
|
136 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false").",";
|
137 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY.",";
|
138 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS.",";
|
139 |
-
|
140 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = ".S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID.",";
|
141 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID.",";
|
142 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = ".S2MEMBER_LOGIN_WELCOME_PAGE_ID.",";
|
143 |
-
|
144 |
echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL)."',";
|
145 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL)."',";
|
146 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL)."',";
|
147 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_WELCOME_PAGE_URL)."',";
|
148 |
echo "S2MEMBER_LOGOUT_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGOUT_PAGE_URL)."',";
|
149 |
echo "S2MEMBER_LOGIN_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_PAGE_URL)."',";
|
150 |
-
|
151 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
152 |
{
|
153 |
if(defined(($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL".$n."_LABEL")))
|
154 |
echo $S2MEMBER_LEVELn_LABEL." = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(constant($S2MEMBER_LEVELn_LABEL))."',";
|
155 |
}
|
156 |
-
/**/
|
157 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
158 |
{
|
159 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED")))
|
160 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED).",";
|
161 |
}
|
162 |
-
/**/
|
163 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
164 |
{
|
165 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED_DAYS")))
|
166 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS).",";
|
167 |
}
|
168 |
-
/**/
|
169 |
echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS)."',";
|
170 |
-
|
171 |
echo "S2MEMBER_REG_EMAIL_FROM_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_NAME)."',";
|
172 |
echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_EMAIL)."',";
|
173 |
-
|
174 |
echo "S2MEMBER_PAYPAL_NOTIFY_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_NOTIFY_URL)."',";
|
175 |
echo "S2MEMBER_PAYPAL_RETURN_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_RETURN_URL)."',";
|
176 |
-
|
177 |
echo "S2MEMBER_PAYPAL_BUSINESS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_BUSINESS)."',";
|
178 |
echo "S2MEMBER_PAYPAL_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_ENDPOINT)."',";
|
179 |
echo "S2MEMBER_PAYPAL_API_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_API_ENDPOINT)."',";
|
180 |
-
|
181 |
echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
|
182 |
echo "S2MEMBER_VALUE_FOR_PP_INV_GEN = s2member_value_for_pp_inv_gen = function(){ var invoice = '', formatSeed = function(seed, reqWidth) { seed = parseInt(seed, 10).toString (16); if (reqWidth < seed.length) return seed.slice (seed.length - reqWidth); else if (reqWidth > seed.length) return Array(1 + (reqWidth - seed.length)).join ('0') + seed; return seed; }; if (typeof S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED === 'undefined') S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED = Math.floor (Math.random () * 0x75bcd15); S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED++; invoice = formatSeed(parseInt(new Date ().getTime () / 1000, 10), 8); invoice += formatSeed(S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED, 5); invoice += '~' + S2MEMBER_CURRENT_USER_IP; return invoice; },";
|
183 |
-
|
184 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0)."',";
|
185 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0)."',";
|
186 |
-
|
187 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1)."',";
|
188 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1)."';";
|
189 |
-
|
190 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
191 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
|
192 |
-
|
193 |
-
echo
|
194 |
-
|
195 |
include_once dirname(dirname(__FILE__))."/s2member-min.js";
|
196 |
-
|
197 |
do_action("ws_plugin__s2member_during_js_w_globals", get_defined_vars());
|
198 |
-
|
199 |
-
exit
|
200 |
}
|
201 |
-
/**/
|
202 |
do_action("ws_plugin__s2member_after_js_w_globals", get_defined_vars());
|
203 |
}
|
204 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* CSS/JS loading handlers for s2Member (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_css_js_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* CSS/JS loading handlers for s2Member (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\CSS_JS
|
26 |
* @since 3.5
|
40 |
public static function css()
|
41 |
{
|
42 |
do_action("ws_plugin__s2member_before_css", get_defined_vars());
|
43 |
+
|
44 |
if(!empty($_GET["ws_plugin__s2member_css"]))
|
45 |
{
|
46 |
+
status_header /* 200 OK status. */(200);
|
47 |
+
|
48 |
+
header("Content-Type: text/css; charset=UTF-8");
|
49 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
|
50 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
51 |
header("Cache-Control: max-age=604800");
|
52 |
header("Pragma: public");
|
53 |
+
|
54 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
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");
|
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 |
do_action("ws_plugin__s2member_after_css", get_defined_vars());
|
68 |
}
|
69 |
/**
|
81 |
public static function js_w_globals()
|
82 |
{
|
83 |
do_action("ws_plugin__s2member_before_js_w_globals", get_defined_vars());
|
84 |
+
|
85 |
if(!empty($_GET["ws_plugin__s2member_js_w_globals"]))
|
86 |
{
|
87 |
+
status_header /* 200 OK status header. */(200);
|
88 |
+
|
89 |
+
header("Content-Type: application/x-javascript; charset=UTF-8");
|
90 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
|
91 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
92 |
header("Cache-Control: max-age=604800");
|
93 |
header("Pragma: public");
|
94 |
+
|
95 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
96 |
+
|
97 |
include_once dirname(dirname(__FILE__))."/jquery/jquery.sprintf/jquery.sprintf-min.js";
|
98 |
+
|
99 |
+
echo /* Add a line break before writing JavaScript Globals to file. */ "\n";
|
100 |
+
|
101 |
echo "var S2MEMBER_VERSION = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_VERSION)."',";
|
102 |
+
|
103 |
echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = ".S2MEMBER_CURRENT_USER_LOGIN_COUNTER.",";
|
104 |
+
|
105 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false").",";
|
106 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false").",";
|
107 |
+
|
108 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = ".S2MEMBER_CURRENT_USER_ACCESS_LEVEL.",";
|
109 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_ACCESS_LABEL)."',";
|
110 |
+
|
111 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_ID)."',";
|
112 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID)."',";
|
113 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY)."',";
|
114 |
echo "S2MEMBER_CURRENT_USER_CUSTOM = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_CUSTOM)."',";
|
115 |
+
|
116 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_REGISTRATION_TIME.",";
|
117 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME.",";
|
118 |
+
|
119 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS.",";
|
120 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_REGISTRATION_DAYS.",";
|
121 |
+
|
122 |
echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_DISPLAY_NAME)."',";
|
123 |
echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_FIRST_NAME)."',";
|
124 |
echo "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LAST_NAME)."',";
|
125 |
+
|
126 |
echo "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LOGIN)."',";
|
127 |
echo "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_EMAIL)."',";
|
128 |
echo "S2MEMBER_CURRENT_USER_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
|
129 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_REGISTRATION_IP)."',";
|
130 |
+
|
131 |
echo "S2MEMBER_CURRENT_USER_ID = ".S2MEMBER_CURRENT_USER_ID.",";
|
132 |
echo "S2MEMBER_CURRENT_USER_FIELDS = ".S2MEMBER_CURRENT_USER_FIELDS.",";
|
133 |
+
|
134 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED.",";
|
135 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false").",";
|
136 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY.",";
|
137 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS.",";
|
138 |
+
|
139 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = ".S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID.",";
|
140 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID.",";
|
141 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = ".S2MEMBER_LOGIN_WELCOME_PAGE_ID.",";
|
142 |
+
|
143 |
echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL)."',";
|
144 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL)."',";
|
145 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL)."',";
|
146 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_WELCOME_PAGE_URL)."',";
|
147 |
echo "S2MEMBER_LOGOUT_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGOUT_PAGE_URL)."',";
|
148 |
echo "S2MEMBER_LOGIN_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_PAGE_URL)."',";
|
149 |
+
|
150 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
151 |
{
|
152 |
if(defined(($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL".$n."_LABEL")))
|
153 |
echo $S2MEMBER_LEVELn_LABEL." = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(constant($S2MEMBER_LEVELn_LABEL))."',";
|
154 |
}
|
|
|
155 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
156 |
{
|
157 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED")))
|
158 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED).",";
|
159 |
}
|
|
|
160 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
161 |
{
|
162 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED_DAYS")))
|
163 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS).",";
|
164 |
}
|
|
|
165 |
echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS)."',";
|
166 |
+
|
167 |
echo "S2MEMBER_REG_EMAIL_FROM_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_NAME)."',";
|
168 |
echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_EMAIL)."',";
|
169 |
+
|
170 |
echo "S2MEMBER_PAYPAL_NOTIFY_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_NOTIFY_URL)."',";
|
171 |
echo "S2MEMBER_PAYPAL_RETURN_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_RETURN_URL)."',";
|
172 |
+
|
173 |
echo "S2MEMBER_PAYPAL_BUSINESS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_BUSINESS)."',";
|
174 |
echo "S2MEMBER_PAYPAL_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_ENDPOINT)."',";
|
175 |
echo "S2MEMBER_PAYPAL_API_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_API_ENDPOINT)."',";
|
176 |
+
|
177 |
echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
|
178 |
echo "S2MEMBER_VALUE_FOR_PP_INV_GEN = s2member_value_for_pp_inv_gen = function(){ var invoice = '', formatSeed = function(seed, reqWidth) { seed = parseInt(seed, 10).toString (16); if (reqWidth < seed.length) return seed.slice (seed.length - reqWidth); else if (reqWidth > seed.length) return Array(1 + (reqWidth - seed.length)).join ('0') + seed; return seed; }; if (typeof S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED === 'undefined') S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED = Math.floor (Math.random () * 0x75bcd15); S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED++; invoice = formatSeed(parseInt(new Date ().getTime () / 1000, 10), 8); invoice += formatSeed(S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED, 5); invoice += '~' + S2MEMBER_CURRENT_USER_IP; return invoice; },";
|
179 |
+
|
180 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0)."',";
|
181 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0)."',";
|
182 |
+
|
183 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1)."',";
|
184 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1)."';";
|
185 |
+
|
186 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
187 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
|
188 |
+
|
189 |
+
echo /* Add a line break before inclusion. */ "\n";
|
190 |
+
|
191 |
include_once dirname(dirname(__FILE__))."/s2member-min.js";
|
192 |
+
|
193 |
do_action("ws_plugin__s2member_during_js_w_globals", get_defined_vars());
|
194 |
+
|
195 |
+
exit /* Clean exit. */();
|
196 |
}
|
|
|
197 |
do_action("ws_plugin__s2member_after_js_w_globals", get_defined_vars());
|
198 |
}
|
199 |
}
|
includes/classes/css-js-themes.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
|
21 |
{
|
22 |
/**
|
@@ -40,19 +40,18 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
|
|
40 |
public static function add_css ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ());
|
43 |
-
|
44 |
-
if
|
45 |
{
|
46 |
$s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
|
47 |
-
|
48 |
wp_enqueue_style ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_css=1&qcABC=1", array (), c_ws_plugin__s2member_utilities::ver_checksum (), "all");
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
|
51 |
}
|
52 |
-
/**/
|
53 |
do_action ("ws_plugin__s2member_after_add_css", get_defined_vars ());
|
54 |
-
|
55 |
-
return
|
56 |
}
|
57 |
/**
|
58 |
* Enqueues JS file for theme integration.
|
@@ -68,32 +67,30 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
|
|
68 |
*/
|
69 |
public static function add_js_w_globals ()
|
70 |
{
|
71 |
-
global
|
72 |
-
|
73 |
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
|
74 |
-
|
75 |
if (!is_admin () || (is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
|
76 |
{
|
77 |
$s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
|
78 |
-
|
79 |
-
if
|
80 |
{
|
81 |
-
$md5 =
|
82 |
-
|
83 |
-
|
84 |
wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
|
85 |
}
|
86 |
-
else
|
87 |
-
{
|
88 |
wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=1&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
|
89 |
}
|
90 |
-
/**/
|
91 |
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
|
92 |
}
|
93 |
-
/**/
|
94 |
do_action ("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars ());
|
95 |
-
|
96 |
-
return
|
97 |
}
|
98 |
}
|
99 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
|
21 |
{
|
22 |
/**
|
40 |
public static function add_css ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ());
|
43 |
+
|
44 |
+
if /* Not in the admin. */ (!is_admin ())
|
45 |
{
|
46 |
$s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
|
47 |
+
|
48 |
wp_enqueue_style ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_css=1&qcABC=1", array (), c_ws_plugin__s2member_utilities::ver_checksum (), "all");
|
49 |
+
|
50 |
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
|
51 |
}
|
|
|
52 |
do_action ("ws_plugin__s2member_after_add_css", get_defined_vars ());
|
53 |
+
|
54 |
+
return /* Return for uniformity. */;
|
55 |
}
|
56 |
/**
|
57 |
* Enqueues JS file for theme integration.
|
67 |
*/
|
68 |
public static function add_js_w_globals ()
|
69 |
{
|
70 |
+
global /* Need this for comparisons. */ $pagenow;
|
71 |
+
|
72 |
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
|
73 |
+
|
74 |
if (!is_admin () || (is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
|
75 |
{
|
76 |
$s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
|
77 |
+
|
78 |
+
if /* Separate version for logged-in Users/Members. */ (is_user_logged_in ())
|
79 |
{
|
80 |
+
$md5 = /* An MD5 hash based on global key => values. */ WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5;
|
81 |
+
// The MD5 hash allows the script to be cached in the browser until the globals happen to change.
|
82 |
+
// For instance, the global variables may change when a User who is logged-in changes their Profile.
|
83 |
wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
|
84 |
}
|
85 |
+
else // Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5.
|
86 |
+
{ // This essentially creates 2 versions of the script. One while logged in & another when not.
|
87 |
wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=1&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
|
88 |
}
|
|
|
89 |
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
|
90 |
}
|
|
|
91 |
do_action ("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars ());
|
92 |
+
|
93 |
+
return /* Return for uniformity. */;
|
94 |
}
|
95 |
}
|
96 |
}
|
includes/classes/css-js.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_css_js"))
|
21 |
{
|
22 |
/**
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_css_js"))
|
21 |
{
|
22 |
/**
|
includes/classes/custom-reg-fields-4bp.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
|
21 |
{
|
22 |
/**
|
@@ -41,93 +41,91 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
|
|
41 |
*/
|
42 |
public static function custom_registration_fields_4bp ()
|
43 |
{
|
44 |
-
static $processed =
|
45 |
-
|
46 |
do_action ("ws_plugin__s2member_before_custom_registration_fields_4bp", get_defined_vars ());
|
47 |
-
|
48 |
if (!$processed && in_array ("registration", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
49 |
if (apply_filters ("ws_plugin__s2member_custom_registration_fields_4bp_display", true, get_defined_vars ()))
|
50 |
if (bp_is_register_page () && ($processed = true))
|
51 |
{
|
52 |
$_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
|
53 |
-
|
54 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
55 |
-
if (($
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
/**/
|
63 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
64 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before", get_defined_vars ());
|
65 |
-
unset
|
66 |
-
|
67 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
68 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
|
69 |
{
|
70 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
71 |
{
|
72 |
-
|
73 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_custom_fields", get_defined_vars ());
|
74 |
-
unset
|
75 |
-
|
76 |
-
if (in_array ($field["id"], $fields_applicable))
|
77 |
{
|
78 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
79 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
80 |
-
|
81 |
-
|
82 |
if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
83 |
{
|
84 |
-
if (!empty ($field["section"]) && $field["section"] === "yes")
|
85 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
|
86 |
-
|
87 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
|
88 |
echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
|
89 |
echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
|
90 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-4bp-", "ws-plugin--s2member-custom-reg-field-4bp", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
|
91 |
echo '</div>' . "\n";
|
92 |
}
|
93 |
-
unset
|
94 |
}
|
95 |
-
|
96 |
-
|
97 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_custom_fields", get_defined_vars ());
|
98 |
-
unset
|
99 |
}
|
100 |
}
|
101 |
-
|
102 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
|
103 |
{
|
104 |
-
|
105 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_opt_in", get_defined_vars ());
|
106 |
-
unset
|
107 |
-
|
108 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp field_opt_in editfield">' . "\n";
|
109 |
echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-opt-in">' . "\n";
|
110 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-4bp-opt-in" class="ws-plugin--s2member-custom-reg-field-4bp" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
|
111 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
112 |
echo '</label>' . "\n";
|
113 |
echo '</div>' . "\n";
|
114 |
-
|
115 |
-
|
116 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_opt_in", get_defined_vars ());
|
117 |
-
unset
|
118 |
}
|
119 |
-
|
120 |
if (isset ($close_section_container) && $close_section_container)
|
121 |
echo '</div>' . "\n" . '</div>' . "\n";
|
122 |
-
|
123 |
-
|
124 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after", get_defined_vars ());
|
125 |
-
unset
|
126 |
}
|
127 |
-
|
128 |
do_action ("ws_plugin__s2member_after_custom_registration_fields_4bp", get_defined_vars ());
|
129 |
-
|
130 |
-
return
|
131 |
}
|
132 |
/**
|
133 |
* Adds Custom Fields to BuddyPress Profiles.
|
@@ -141,70 +139,70 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
|
|
141 |
*/
|
142 |
public static function custom_profile_fields_4bp ()
|
143 |
{
|
144 |
-
global
|
145 |
-
static $processed =
|
146 |
-
|
147 |
do_action ("ws_plugin__s2member_before_custom_profile_fields_4bp", get_defined_vars ());
|
148 |
-
|
149 |
if (!$processed && in_array ("profile", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
150 |
if (apply_filters ("ws_plugin__s2member_custom_profile_fields_4bp_display", true, get_defined_vars ()))
|
151 |
-
if (bp_is_user_profile () && (( /* BuddyPress v1.5. */function_exists ("bp_is_user_profile_edit") && bp_is_user_profile_edit ())
|
152 |
|| ( /* for BuddyPress < v1.5. */function_exists ("bp_is_profile_edit") && bp_is_profile_edit ())) && (int)bp_get_the_profile_group_id () === 1)
|
153 |
if (isset ($bp->displayed_user->id) && ($user_id = $bp->displayed_user->id))
|
154 |
-
if (($processed = true)
|
155 |
{
|
156 |
echo '<input type="hidden" name="ws_plugin__s2member_profile_4bp_save" id="ws-plugin--s2member-profile-4bp-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-profile-4bp-save")) . '" />' . "\n";
|
157 |
-
|
158 |
-
|
159 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before", get_defined_vars ());
|
160 |
-
unset
|
161 |
-
|
162 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
163 |
if (($level = c_ws_plugin__s2member_user_access::user_access_level (new WP_User ($user_id))) >= 0)
|
164 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level, "profile"))
|
165 |
{
|
166 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
167 |
-
|
168 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
169 |
{
|
170 |
-
|
171 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before_custom_fields", get_defined_vars ());
|
172 |
-
unset
|
173 |
-
|
174 |
-
if (in_array ($field["id"], $fields_applicable))
|
175 |
{
|
176 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
177 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
178 |
-
|
179 |
-
|
180 |
if (apply_filters ("ws_plugin__s2member_during_custom_profile_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
181 |
{
|
182 |
-
if (!empty ($field["section"]) && $field["section"] === "yes")
|
183 |
echo '<div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
|
184 |
-
|
185 |
echo '<div class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
|
186 |
echo '<label for="ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
|
187 |
echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
|
188 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile");
|
189 |
echo '</div>' . "\n";
|
190 |
}
|
191 |
-
unset
|
192 |
}
|
193 |
-
|
194 |
-
|
195 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after_custom_fields", get_defined_vars ());
|
196 |
-
unset
|
197 |
}
|
198 |
}
|
199 |
-
|
200 |
-
|
201 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after", get_defined_vars ());
|
202 |
-
unset
|
203 |
}
|
204 |
-
|
205 |
do_action ("ws_plugin__s2member_after_custom_profile_fields_4bp", get_defined_vars ());
|
206 |
-
|
207 |
-
return
|
208 |
}
|
209 |
/**
|
210 |
* Adds Custom Fields to BuddyPress Profiles in public view.
|
@@ -218,71 +216,70 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
|
|
218 |
*/
|
219 |
public static function custom_profile_field_items_4bp ()
|
220 |
{
|
221 |
-
global
|
222 |
-
static $processed =
|
223 |
-
|
224 |
do_action ("ws_plugin__s2member_before_custom_profile_field_items_4bp", get_defined_vars ());
|
225 |
-
|
226 |
if (!$processed && in_array ("profile-view", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
227 |
if (apply_filters ("ws_plugin__s2member_custom_profile_field_items_4bp_display", true, get_defined_vars ()))
|
228 |
-
if (bp_is_user_profile () && (( /* BuddyPress v1.5. */function_exists ("bp_is_user_profile_edit") && !bp_is_user_profile_edit ())
|
229 |
|| ( /* for BuddyPress < v1.5. */function_exists ("bp_is_profile_edit") && !bp_is_profile_edit ())) && (int)bp_get_the_profile_group_id () === 1)
|
230 |
if (isset ($bp->displayed_user->id) && ($user_id = $bp->displayed_user->id))
|
231 |
-
if
|
232 |
{
|
233 |
-
|
234 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before", get_defined_vars ());
|
235 |
-
unset
|
236 |
-
|
237 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
238 |
if (($level = c_ws_plugin__s2member_user_access::user_access_level (new WP_User ($user_id))) >= 0)
|
239 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level, "profile-view"))
|
240 |
{
|
241 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
242 |
-
|
243 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
244 |
{
|
245 |
-
|
246 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before_custom_fields", get_defined_vars ());
|
247 |
-
unset
|
248 |
-
|
249 |
-
if (in_array ($field["id"], $fields_applicable))
|
250 |
{
|
251 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
252 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
253 |
-
|
254 |
-
|
255 |
if (apply_filters ("ws_plugin__s2member_during_custom_profile_field_items_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
256 |
{
|
257 |
-
if (!empty ($field["section"]) && $field["section"] === "yes")
|
258 |
{
|
259 |
echo '<tr class="ws-plugin--s2member-profile-field-4bp-divider-section">' . "\n";
|
260 |
echo '<td colspan="2"><div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div></td>' . "\n";
|
261 |
echo '</tr>' . "\n";
|
262 |
}
|
263 |
-
|
264 |
echo '<tr class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . '">' . "\n";
|
265 |
echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' label"><span>' . $field["label"] . '</span></td>' . "\n";
|
266 |
echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' data">' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile-view") . '</td>' . "\n";
|
267 |
echo '</tr>' . "\n";
|
268 |
}
|
269 |
-
unset
|
270 |
}
|
271 |
-
|
272 |
-
|
273 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after_custom_fields", get_defined_vars ());
|
274 |
-
unset
|
275 |
}
|
276 |
}
|
277 |
-
|
278 |
-
|
279 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after", get_defined_vars ());
|
280 |
-
unset
|
281 |
}
|
282 |
-
/**/
|
283 |
do_action ("ws_plugin__s2member_after_custom_profile_field_items_4bp", get_defined_vars ());
|
284 |
-
|
285 |
-
return
|
286 |
}
|
287 |
}
|
288 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
|
21 |
{
|
22 |
/**
|
41 |
*/
|
42 |
public static function custom_registration_fields_4bp ()
|
43 |
{
|
44 |
+
static $processed = /* Process this routine only one time. */ false;
|
45 |
+
|
46 |
do_action ("ws_plugin__s2member_before_custom_registration_fields_4bp", get_defined_vars ());
|
47 |
+
|
48 |
if (!$processed && in_array ("registration", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
49 |
if (apply_filters ("ws_plugin__s2member_custom_registration_fields_4bp_display", true, get_defined_vars ()))
|
50 |
if (bp_is_register_page () && ($processed = true))
|
51 |
{
|
52 |
$_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
|
53 |
+
|
54 |
+
if (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] && ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))) || ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ()))
|
55 |
+
if (($close_section_container = true))
|
56 |
+
{
|
57 |
+
echo '<div id="ws-plugin--s2member-custom-reg-fields-4bp-section" class="ws-plugin--s2member-custom-reg-fields-4bp-section register-section">' . "\n";
|
58 |
+
echo '<div id="ws-plugin--s2member-custom-reg-fields-4bp-container" class="ws-plugin--s2member-custom-reg-fields-4bp-container">' . "\n";
|
59 |
+
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
|
60 |
+
}
|
61 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
|
|
62 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before", get_defined_vars ());
|
63 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
64 |
+
|
65 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
66 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
|
67 |
{
|
68 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
69 |
{
|
70 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
71 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_custom_fields", get_defined_vars ());
|
72 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
73 |
+
|
74 |
+
if /* Field applicable? */ (in_array ($field["id"], $fields_applicable))
|
75 |
{
|
76 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
77 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
78 |
+
|
79 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
80 |
if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
81 |
{
|
82 |
+
if /* Starts a new section? */ (!empty ($field["section"]) && $field["section"] === "yes")
|
83 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
|
84 |
+
|
85 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
|
86 |
echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
|
87 |
echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
|
88 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-4bp-", "ws-plugin--s2member-custom-reg-field-4bp", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
|
89 |
echo '</div>' . "\n";
|
90 |
}
|
91 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
92 |
}
|
93 |
+
|
94 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
95 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_custom_fields", get_defined_vars ());
|
96 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
97 |
}
|
98 |
}
|
99 |
+
|
100 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
|
101 |
{
|
102 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
103 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_opt_in", get_defined_vars ());
|
104 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
105 |
+
|
106 |
echo '<div class="ws-plugin--s2member-custom-reg-field-4bp field_opt_in editfield">' . "\n";
|
107 |
echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-opt-in">' . "\n";
|
108 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-4bp-opt-in" class="ws-plugin--s2member-custom-reg-field-4bp" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
|
109 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
110 |
echo '</label>' . "\n";
|
111 |
echo '</div>' . "\n";
|
112 |
+
|
113 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
114 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_opt_in", get_defined_vars ());
|
115 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
116 |
}
|
117 |
+
|
118 |
if (isset ($close_section_container) && $close_section_container)
|
119 |
echo '</div>' . "\n" . '</div>' . "\n";
|
120 |
+
|
121 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
122 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after", get_defined_vars ());
|
123 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
124 |
}
|
125 |
+
|
126 |
do_action ("ws_plugin__s2member_after_custom_registration_fields_4bp", get_defined_vars ());
|
127 |
+
|
128 |
+
return /* Return for uniformity. */;
|
129 |
}
|
130 |
/**
|
131 |
* Adds Custom Fields to BuddyPress Profiles.
|
139 |
*/
|
140 |
public static function custom_profile_fields_4bp ()
|
141 |
{
|
142 |
+
global /* Global BuddyPress object reference. */ $bp;
|
143 |
+
static $processed = /* Process this routine only one time. */ false;
|
144 |
+
|
145 |
do_action ("ws_plugin__s2member_before_custom_profile_fields_4bp", get_defined_vars ());
|
146 |
+
|
147 |
if (!$processed && in_array ("profile", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
148 |
if (apply_filters ("ws_plugin__s2member_custom_profile_fields_4bp_display", true, get_defined_vars ()))
|
149 |
+
if (bp_is_user_profile () && (( /* BuddyPress v1.5. */function_exists ("bp_is_user_profile_edit") && bp_is_user_profile_edit ())
|
150 |
|| ( /* for BuddyPress < v1.5. */function_exists ("bp_is_profile_edit") && bp_is_profile_edit ())) && (int)bp_get_the_profile_group_id () === 1)
|
151 |
if (isset ($bp->displayed_user->id) && ($user_id = $bp->displayed_user->id))
|
152 |
+
if (($processed = true) /* Mark as having been processed now. */)
|
153 |
{
|
154 |
echo '<input type="hidden" name="ws_plugin__s2member_profile_4bp_save" id="ws-plugin--s2member-profile-4bp-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-profile-4bp-save")) . '" />' . "\n";
|
155 |
+
|
156 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
157 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before", get_defined_vars ());
|
158 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
159 |
+
|
160 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
161 |
if (($level = c_ws_plugin__s2member_user_access::user_access_level (new WP_User ($user_id))) >= 0)
|
162 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level, "profile"))
|
163 |
{
|
164 |
+
$fields = /* Existing Custom Fields. */get_user_option ("s2member_custom_fields", $user_id);
|
165 |
+
|
166 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
167 |
{
|
168 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
169 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before_custom_fields", get_defined_vars ());
|
170 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
171 |
+
|
172 |
+
if /* Field applicable? */ (in_array ($field["id"], $fields_applicable))
|
173 |
{
|
174 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
175 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
176 |
+
|
177 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
178 |
if (apply_filters ("ws_plugin__s2member_during_custom_profile_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
179 |
{
|
180 |
+
if /* Starts a new section? */ (!empty ($field["section"]) && $field["section"] === "yes")
|
181 |
echo '<div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
|
182 |
+
|
183 |
echo '<div class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
|
184 |
echo '<label for="ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
|
185 |
echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
|
186 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile");
|
187 |
echo '</div>' . "\n";
|
188 |
}
|
189 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
190 |
}
|
191 |
+
|
192 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
193 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after_custom_fields", get_defined_vars ());
|
194 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
195 |
}
|
196 |
}
|
197 |
+
|
198 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
199 |
do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after", get_defined_vars ());
|
200 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
201 |
}
|
202 |
+
|
203 |
do_action ("ws_plugin__s2member_after_custom_profile_fields_4bp", get_defined_vars ());
|
204 |
+
|
205 |
+
return /* Return for uniformity. */;
|
206 |
}
|
207 |
/**
|
208 |
* Adds Custom Fields to BuddyPress Profiles in public view.
|
216 |
*/
|
217 |
public static function custom_profile_field_items_4bp ()
|
218 |
{
|
219 |
+
global /* Global BuddyPress object reference. */ $bp;
|
220 |
+
static $processed = /* Process this routine only one time. */ false;
|
221 |
+
|
222 |
do_action ("ws_plugin__s2member_before_custom_profile_field_items_4bp", get_defined_vars ());
|
223 |
+
|
224 |
if (!$processed && in_array ("profile-view", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
|
225 |
if (apply_filters ("ws_plugin__s2member_custom_profile_field_items_4bp_display", true, get_defined_vars ()))
|
226 |
+
if (bp_is_user_profile () && (( /* BuddyPress v1.5. */function_exists ("bp_is_user_profile_edit") && !bp_is_user_profile_edit ())
|
227 |
|| ( /* for BuddyPress < v1.5. */function_exists ("bp_is_profile_edit") && !bp_is_profile_edit ())) && (int)bp_get_the_profile_group_id () === 1)
|
228 |
if (isset ($bp->displayed_user->id) && ($user_id = $bp->displayed_user->id))
|
229 |
+
if /* Mark as having been processed now. */ (($processed = true))
|
230 |
{
|
231 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
232 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before", get_defined_vars ());
|
233 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
234 |
+
|
235 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
236 |
if (($level = c_ws_plugin__s2member_user_access::user_access_level (new WP_User ($user_id))) >= 0)
|
237 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ($level, "profile-view"))
|
238 |
{
|
239 |
+
$fields = /* Existing Custom Fields. */ get_user_option ("s2member_custom_fields", $user_id);
|
240 |
+
|
241 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
242 |
{
|
243 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
244 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before_custom_fields", get_defined_vars ());
|
245 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
246 |
+
|
247 |
+
if /* Field applicable? */ (in_array ($field["id"], $fields_applicable))
|
248 |
{
|
249 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
250 |
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
251 |
+
|
252 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
253 |
if (apply_filters ("ws_plugin__s2member_during_custom_profile_field_items_4bp_during_custom_fields_display", true, get_defined_vars ()))
|
254 |
{
|
255 |
+
if /* New section? */ (!empty ($field["section"]) && $field["section"] === "yes")
|
256 |
{
|
257 |
echo '<tr class="ws-plugin--s2member-profile-field-4bp-divider-section">' . "\n";
|
258 |
echo '<td colspan="2"><div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div></td>' . "\n";
|
259 |
echo '</tr>' . "\n";
|
260 |
}
|
261 |
+
|
262 |
echo '<tr class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . '">' . "\n";
|
263 |
echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' label"><span>' . $field["label"] . '</span></td>' . "\n";
|
264 |
echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' data">' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile-view") . '</td>' . "\n";
|
265 |
echo '</tr>' . "\n";
|
266 |
}
|
267 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
268 |
}
|
269 |
+
|
270 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
271 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after_custom_fields", get_defined_vars ());
|
272 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
273 |
}
|
274 |
}
|
275 |
+
|
276 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
277 |
do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after", get_defined_vars ());
|
278 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
279 |
}
|
|
|
280 |
do_action ("ws_plugin__s2member_after_custom_profile_field_items_4bp", get_defined_vars ());
|
281 |
+
|
282 |
+
return /* Return for uniformity. */;
|
283 |
}
|
284 |
}
|
285 |
}
|
includes/classes/custom-reg-fields.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
21 |
{
|
22 |
/**
|
@@ -48,23 +48,23 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
48 |
*/
|
49 |
public static function custom_field_gen($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_editable_context = FALSE)
|
50 |
{
|
51 |
-
|
52 |
do_action("ws_plugin__s2member_before_custom_field_gen", get_defined_vars());
|
53 |
-
unset
|
54 |
-
|
55 |
if(!($gen = "") && $_function && is_array($field = $_field) && !empty($field["type"]) && !empty($field["id"]) && $_name_prefix && $_id_prefix)
|
56 |
{
|
57 |
-
|
58 |
do_action("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars());
|
59 |
-
unset
|
60 |
-
|
61 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
62 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
63 |
-
|
64 |
$name_suffix = (preg_match("/\[$/", $_name_prefix)) ? ']' : '';
|
65 |
$field_name = trim($_name_prefix.$field_var.$name_suffix);
|
66 |
-
|
67 |
-
$common =
|
68 |
$common .= ' name="'.esc_attr($field_name).'"';
|
69 |
$common .= ' id="'.esc_attr($_id_prefix.$field_id_class).'"';
|
70 |
$common .= ((!empty($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : '');
|
@@ -74,33 +74,31 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
74 |
$common .= (($_classes || !empty($field["classes"])) ? ' class="'.esc_attr(trim($_classes.((!empty($field["classes"])) ? ' '.$field["classes"] : ''))).'"' : '');
|
75 |
$common .= (($_styles || !empty($field["styles"])) ? ' style="'.esc_attr(trim($_styles.((!empty($field["styles"])) ? ' '.$field["styles"] : ''))).'"' : '');
|
76 |
$common .= (($_attrs || !empty($field["attrs"])) ? ' '.trim($_attrs.((!empty($field["attrs"])) ? ' '.$field["attrs"] : '')) : '');
|
77 |
-
|
78 |
if($field["type"] === "text")
|
79 |
{
|
80 |
if($_editable_context === "profile-view")
|
81 |
$gen = esc_html((string)$_value);
|
82 |
-
|
83 |
-
else
|
84 |
{
|
85 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
86 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
|
87 |
$gen .= $common.' />';
|
88 |
}
|
89 |
}
|
90 |
-
/**/
|
91 |
else if($field["type"] === "textarea")
|
92 |
{
|
93 |
if($_editable_context === "profile-view")
|
94 |
$gen = nl2br(esc_html((string)$_value));
|
95 |
-
|
96 |
-
else
|
97 |
{
|
98 |
$gen = '<textarea rows="3"'.$common.'>';
|
99 |
$gen .= format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value);
|
100 |
$gen .= '</textarea>';
|
101 |
}
|
102 |
}
|
103 |
-
/**/
|
104 |
else if($field["type"] === "select" && !empty($field["options"]))
|
105 |
{
|
106 |
if($_editable_context === "profile-view")
|
@@ -115,7 +113,7 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
115 |
}
|
116 |
}
|
117 |
}
|
118 |
-
else
|
119 |
{
|
120 |
$gen = '<select'.$common.'>';
|
121 |
$selected_default_option = false;
|
@@ -127,7 +125,6 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
127 |
$gen .= '</select>';
|
128 |
}
|
129 |
}
|
130 |
-
/**/
|
131 |
else if($field["type"] === "selects" && !empty($field["options"]))
|
132 |
{
|
133 |
if($_editable_context === "profile-view")
|
@@ -140,11 +137,11 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
140 |
}
|
141 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
|
142 |
}
|
143 |
-
else
|
144 |
{
|
145 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
146 |
$common = preg_replace('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
|
147 |
-
|
148 |
$gen = '<select multiple="multiple" size="3"'.$common.'>';
|
149 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
|
150 |
{
|
@@ -154,33 +151,30 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
154 |
$gen .= '</select>';
|
155 |
}
|
156 |
}
|
157 |
-
/**/
|
158 |
else if($field["type"] === "checkbox" && !empty($field["label"]))
|
159 |
{
|
160 |
if($_editable_context === "profile-view")
|
161 |
$gen = ((string)$_value) ? "yes" : "no";
|
162 |
-
|
163 |
-
else
|
164 |
{
|
165 |
$gen = '<input type="checkbox" value="1"';
|
166 |
$gen .= (((string)$_value) ? ' checked="checked"' : '');
|
167 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
|
168 |
}
|
169 |
}
|
170 |
-
/**/
|
171 |
else if($field["type"] === "pre_checkbox" && !empty($field["label"]))
|
172 |
{
|
173 |
if($_editable_context === "profile-view")
|
174 |
$gen = ((string)$_value) ? "yes" : "no";
|
175 |
-
|
176 |
-
else
|
177 |
{
|
178 |
$gen = '<input type="checkbox" value="1"';
|
179 |
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
|
180 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
|
181 |
}
|
182 |
}
|
183 |
-
/**/
|
184 |
else if($field["type"] === "checkboxes" && !empty($field["options"]))
|
185 |
{
|
186 |
if($_editable_context === "profile-view")
|
@@ -193,27 +187,26 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
193 |
}
|
194 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
|
195 |
}
|
196 |
-
else
|
197 |
{
|
198 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
199 |
-
|
200 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_sep", " ", get_defined_vars());
|
201 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
|
202 |
-
|
203 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
204 |
{
|
205 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
|
206 |
-
|
207 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
|
208 |
-
|
209 |
-
$gen .= ($i > 0) ? $sep : '';
|
210 |
$gen .= '<input type="checkbox" value="'.esc_attr($option_value).'"';
|
211 |
$gen .= ((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' checked="checked"' : '');
|
212 |
$gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
|
213 |
}
|
214 |
}
|
215 |
}
|
216 |
-
/**/
|
217 |
else if($field["type"] === "radios" && !empty($field["options"]))
|
218 |
{
|
219 |
if($_editable_context === "profile-view")
|
@@ -228,42 +221,40 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
228 |
}
|
229 |
}
|
230 |
}
|
231 |
-
else
|
232 |
{
|
233 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_radios_sep", " ", get_defined_vars());
|
234 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
|
235 |
-
|
236 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
237 |
{
|
238 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
|
239 |
-
|
240 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
|
241 |
-
|
242 |
-
$gen .= ($i > 0) ? $sep : '';
|
243 |
$gen .= '<input type="radio" value="'.esc_attr($option_value).'"';
|
244 |
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
|
245 |
$gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
|
246 |
}
|
247 |
}
|
248 |
}
|
249 |
-
else
|
250 |
{
|
251 |
if($_editable_context === "profile-view")
|
252 |
$gen = esc_html((string)$_value);
|
253 |
-
|
254 |
-
else
|
255 |
{
|
256 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
257 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
|
258 |
$gen .= $common.' />';
|
259 |
}
|
260 |
}
|
261 |
-
|
262 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
263 |
do_action("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars());
|
264 |
-
unset
|
265 |
}
|
266 |
-
/**/
|
267 |
return apply_filters("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars());
|
268 |
}
|
269 |
/**
|
@@ -279,16 +270,16 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
279 |
*/
|
280 |
public static function custom_fields_configured_at_level($_level = "auto-detection", $_editable_context = FALSE)
|
281 |
{
|
282 |
-
|
283 |
do_action("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars());
|
284 |
-
unset
|
285 |
-
|
286 |
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level() : $_level;
|
287 |
if($_level === "auto-detection" && $level < 0 && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number, $m) && !empty($m[1]) && is_numeric($m[1]))
|
288 |
$level = /* A numeric Membership Level # . */ $m[1];
|
289 |
-
|
290 |
$level = ($level !== "any" && (!is_numeric($level) || $level < 0)) ? 0 : /* Default. */ $level;
|
291 |
-
|
292 |
if(($level === "any" || (is_numeric($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
293 |
{
|
294 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
@@ -296,7 +287,6 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
296 |
if(empty($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "no-always-invisible" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible" && $field["editable"] !== "no-always-invisible"))
|
297 |
$configured[] = /* Add this to the array. */ $field["id"];
|
298 |
}
|
299 |
-
/**/
|
300 |
return apply_filters("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty($configured)) ? $configured : array()), get_defined_vars());
|
301 |
}
|
302 |
/**
|
@@ -316,104 +306,99 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
316 |
public static function ms_custom_registration_fields()
|
317 |
{
|
318 |
do_action("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars());
|
319 |
-
|
320 |
-
if
|
321 |
{
|
322 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
|
323 |
-
|
324 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
|
325 |
-
|
326 |
-
|
327 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars());
|
328 |
-
unset
|
329 |
-
|
330 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
|
331 |
{
|
332 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
|
333 |
-
|
334 |
-
|
335 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars());
|
336 |
-
unset
|
337 |
-
|
338 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'._x("First Name", "s2member-front", "s2member").' *</label>'."\n";
|
339 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" />'."\n";
|
340 |
echo '<br />'."\n";
|
341 |
-
|
342 |
-
|
343 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars());
|
344 |
-
unset
|
345 |
-
|
346 |
-
|
347 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars());
|
348 |
-
unset
|
349 |
-
|
350 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'._x("Last Name", "s2member-front", "s2member").' *</label>'."\n";
|
351 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" />'."\n";
|
352 |
echo '<br />'."\n";
|
353 |
-
|
354 |
-
|
355 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars());
|
356 |
-
unset
|
357 |
}
|
358 |
-
/**/
|
359 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
360 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
|
361 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
362 |
{
|
363 |
-
|
364 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars());
|
365 |
-
unset
|
366 |
-
|
367 |
-
if(in_array($field["id"], $fields_applicable))
|
368 |
{
|
369 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
370 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
371 |
-
|
372 |
-
|
373 |
if(apply_filters("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
|
374 |
{
|
375 |
-
if(!empty($field["section"]) && $field["section"] === "yes")
|
376 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
|
377 |
-
|
378 |
echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'"'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '<br />' : '')."\n";
|
379 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
380 |
echo '<br />'."\n";
|
381 |
}
|
382 |
-
unset
|
383 |
}
|
384 |
-
|
385 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
386 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars());
|
387 |
-
unset
|
388 |
}
|
389 |
-
/**/
|
390 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
|
391 |
{
|
392 |
-
|
393 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars());
|
394 |
-
unset
|
395 |
-
|
396 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
|
397 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' />'."\n";
|
398 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
|
399 |
echo '</label>'."\n";
|
400 |
echo '<br />'."\n";
|
401 |
-
|
402 |
-
|
403 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars());
|
404 |
-
unset
|
405 |
}
|
406 |
-
|
407 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
408 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars());
|
409 |
-
unset
|
410 |
}
|
411 |
-
|
412 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
413 |
do_action("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars());
|
414 |
-
unset
|
415 |
-
|
416 |
-
return
|
417 |
}
|
418 |
/**
|
419 |
* Adds Custom Fields to: `/wp-login.php?action=register`.
|
@@ -430,142 +415,137 @@ if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
|
430 |
public static function custom_registration_fields()
|
431 |
{
|
432 |
do_action("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars());
|
433 |
-
|
434 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
|
435 |
-
|
436 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
|
437 |
-
|
438 |
-
$tabindex =
|
439 |
-
|
440 |
-
|
441 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars());
|
442 |
-
unset
|
443 |
-
|
444 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
445 |
{
|
446 |
-
|
447 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars());
|
448 |
-
unset
|
449 |
-
|
450 |
echo '<p>'."\n";
|
451 |
-
|
452 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
|
453 |
-
echo '<span>'._x("Password (
|
454 |
echo '<input type="password" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
455 |
echo '</label>'."\n";
|
456 |
-
|
457 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
|
458 |
echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
459 |
echo '</label>'."\n";
|
460 |
-
|
461 |
echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>'._x("password strength indicator", "s2member-front", "s2member").'</em></div>'."\n";
|
462 |
-
|
463 |
echo '</p>'."\n";
|
464 |
-
|
465 |
-
|
466 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars());
|
467 |
-
unset
|
468 |
}
|
469 |
-
/**/
|
470 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
|
471 |
{
|
472 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
|
473 |
-
|
474 |
-
|
475 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars());
|
476 |
-
unset
|
477 |
-
|
478 |
echo '<p>'."\n";
|
479 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'."\n";
|
480 |
echo '<span>'._x("First Name", "s2member-front", "s2member").' *</span><br />'."\n";
|
481 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
482 |
echo '</label>'."\n";
|
483 |
echo '</p>'."\n";
|
484 |
-
|
485 |
-
|
486 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars());
|
487 |
-
unset
|
488 |
-
|
489 |
-
|
490 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars());
|
491 |
-
unset
|
492 |
-
|
493 |
echo '<p>'."\n";
|
494 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'."\n";
|
495 |
echo '<span>'._x("Last Name", "s2member-front", "s2member").' *</span><br />'."\n";
|
496 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
497 |
echo '</label>'."\n";
|
498 |
echo '</p>'."\n";
|
499 |
-
|
500 |
-
|
501 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars());
|
502 |
-
unset
|
503 |
}
|
504 |
-
/**/
|
505 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
506 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
|
507 |
{
|
508 |
-
$tabindex =
|
509 |
-
|
510 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
511 |
{
|
512 |
-
|
513 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars());
|
514 |
-
unset
|
515 |
-
|
516 |
-
if(in_array($field["id"], $fields_applicable))
|
517 |
{
|
518 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
519 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
520 |
-
|
521 |
-
|
522 |
if(apply_filters("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
|
523 |
{
|
524 |
-
if(!empty($field["section"]) && $field["section"] === "yes")
|
525 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
|
526 |
-
|
527 |
echo '<p>'."\n";
|
528 |
echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'">'."\n";
|
529 |
echo '<span'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</span></label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />')."\n";
|
530 |
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 + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
531 |
echo '</p>'."\n";
|
532 |
}
|
533 |
-
unset
|
534 |
}
|
535 |
-
|
536 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
537 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars());
|
538 |
-
unset
|
539 |
}
|
540 |
}
|
541 |
-
/**/
|
542 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
|
543 |
{
|
544 |
-
|
545 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars());
|
546 |
-
unset
|
547 |
-
|
548 |
echo '<p>'."\n";
|
549 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
|
550 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
551 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
|
552 |
echo '</label>'."\n";
|
553 |
echo '</p>'."\n";
|
554 |
-
|
555 |
-
|
556 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars());
|
557 |
-
unset
|
558 |
}
|
559 |
-
|
560 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
561 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars());
|
562 |
-
unset
|
563 |
-
|
564 |
-
|
565 |
do_action("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars());
|
566 |
-
unset
|
567 |
-
|
568 |
-
return
|
569 |
}
|
570 |
}
|
571 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_custom_reg_fields"))
|
21 |
{
|
22 |
/**
|
48 |
*/
|
49 |
public static function custom_field_gen($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_editable_context = FALSE)
|
50 |
{
|
51 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
52 |
do_action("ws_plugin__s2member_before_custom_field_gen", get_defined_vars());
|
53 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
54 |
+
|
55 |
if(!($gen = "") && $_function && is_array($field = $_field) && !empty($field["type"]) && !empty($field["id"]) && $_name_prefix && $_id_prefix)
|
56 |
{
|
57 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
58 |
do_action("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars());
|
59 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
60 |
+
|
61 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
62 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
63 |
+
|
64 |
$name_suffix = (preg_match("/\[$/", $_name_prefix)) ? ']' : '';
|
65 |
$field_name = trim($_name_prefix.$field_var.$name_suffix);
|
66 |
+
|
67 |
+
$common = /* Common attributes. */ '';
|
68 |
$common .= ' name="'.esc_attr($field_name).'"';
|
69 |
$common .= ' id="'.esc_attr($_id_prefix.$field_id_class).'"';
|
70 |
$common .= ((!empty($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : '');
|
74 |
$common .= (($_classes || !empty($field["classes"])) ? ' class="'.esc_attr(trim($_classes.((!empty($field["classes"])) ? ' '.$field["classes"] : ''))).'"' : '');
|
75 |
$common .= (($_styles || !empty($field["styles"])) ? ' style="'.esc_attr(trim($_styles.((!empty($field["styles"])) ? ' '.$field["styles"] : ''))).'"' : '');
|
76 |
$common .= (($_attrs || !empty($field["attrs"])) ? ' '.trim($_attrs.((!empty($field["attrs"])) ? ' '.$field["attrs"] : '')) : '');
|
77 |
+
|
78 |
if($field["type"] === "text")
|
79 |
{
|
80 |
if($_editable_context === "profile-view")
|
81 |
$gen = esc_html((string)$_value);
|
82 |
+
|
83 |
+
else // Else handle normally.
|
84 |
{
|
85 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
86 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
|
87 |
$gen .= $common.' />';
|
88 |
}
|
89 |
}
|
|
|
90 |
else if($field["type"] === "textarea")
|
91 |
{
|
92 |
if($_editable_context === "profile-view")
|
93 |
$gen = nl2br(esc_html((string)$_value));
|
94 |
+
|
95 |
+
else // Else handle normally.
|
96 |
{
|
97 |
$gen = '<textarea rows="3"'.$common.'>';
|
98 |
$gen .= format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value);
|
99 |
$gen .= '</textarea>';
|
100 |
}
|
101 |
}
|
|
|
102 |
else if($field["type"] === "select" && !empty($field["options"]))
|
103 |
{
|
104 |
if($_editable_context === "profile-view")
|
113 |
}
|
114 |
}
|
115 |
}
|
116 |
+
else // Else handle normally.
|
117 |
{
|
118 |
$gen = '<select'.$common.'>';
|
119 |
$selected_default_option = false;
|
125 |
$gen .= '</select>';
|
126 |
}
|
127 |
}
|
|
|
128 |
else if($field["type"] === "selects" && !empty($field["options"]))
|
129 |
{
|
130 |
if($_editable_context === "profile-view")
|
137 |
}
|
138 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
|
139 |
}
|
140 |
+
else // Else handle normally.
|
141 |
{
|
142 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
143 |
$common = preg_replace('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
|
144 |
+
|
145 |
$gen = '<select multiple="multiple" size="3"'.$common.'>';
|
146 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
|
147 |
{
|
151 |
$gen .= '</select>';
|
152 |
}
|
153 |
}
|
|
|
154 |
else if($field["type"] === "checkbox" && !empty($field["label"]))
|
155 |
{
|
156 |
if($_editable_context === "profile-view")
|
157 |
$gen = ((string)$_value) ? "yes" : "no";
|
158 |
+
|
159 |
+
else // Else handle normally.
|
160 |
{
|
161 |
$gen = '<input type="checkbox" value="1"';
|
162 |
$gen .= (((string)$_value) ? ' checked="checked"' : '');
|
163 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
|
164 |
}
|
165 |
}
|
|
|
166 |
else if($field["type"] === "pre_checkbox" && !empty($field["label"]))
|
167 |
{
|
168 |
if($_editable_context === "profile-view")
|
169 |
$gen = ((string)$_value) ? "yes" : "no";
|
170 |
+
|
171 |
+
else // Else handle normally.
|
172 |
{
|
173 |
$gen = '<input type="checkbox" value="1"';
|
174 |
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
|
175 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
|
176 |
}
|
177 |
}
|
|
|
178 |
else if($field["type"] === "checkboxes" && !empty($field["options"]))
|
179 |
{
|
180 |
if($_editable_context === "profile-view")
|
187 |
}
|
188 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
|
189 |
}
|
190 |
+
else // Else handle normally.
|
191 |
{
|
192 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
193 |
+
|
194 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_sep", " ", get_defined_vars());
|
195 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
|
196 |
+
|
197 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
198 |
{
|
199 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
|
200 |
+
|
201 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
|
202 |
+
|
203 |
+
$gen .= ($i > 0) ? $sep : ''; // Separators can be filtered above.
|
204 |
$gen .= '<input type="checkbox" value="'.esc_attr($option_value).'"';
|
205 |
$gen .= ((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' checked="checked"' : '');
|
206 |
$gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
|
207 |
}
|
208 |
}
|
209 |
}
|
|
|
210 |
else if($field["type"] === "radios" && !empty($field["options"]))
|
211 |
{
|
212 |
if($_editable_context === "profile-view")
|
221 |
}
|
222 |
}
|
223 |
}
|
224 |
+
else // Else handle normally.
|
225 |
{
|
226 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_radios_sep", " ", get_defined_vars());
|
227 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
|
228 |
+
|
229 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
230 |
{
|
231 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
|
232 |
+
|
233 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
|
234 |
+
|
235 |
+
$gen .= ($i > 0) ? $sep : ''; // Separators can be filtered above.
|
236 |
$gen .= '<input type="radio" value="'.esc_attr($option_value).'"';
|
237 |
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
|
238 |
$gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
|
239 |
}
|
240 |
}
|
241 |
}
|
242 |
+
else // Default to a text field input type when nothing matches.
|
243 |
{
|
244 |
if($_editable_context === "profile-view")
|
245 |
$gen = esc_html((string)$_value);
|
246 |
+
|
247 |
+
else // Else handle normally.
|
248 |
{
|
249 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
250 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
|
251 |
$gen .= $common.' />';
|
252 |
}
|
253 |
}
|
254 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
255 |
do_action("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars());
|
256 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
257 |
}
|
|
|
258 |
return apply_filters("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars());
|
259 |
}
|
260 |
/**
|
270 |
*/
|
271 |
public static function custom_fields_configured_at_level($_level = "auto-detection", $_editable_context = FALSE)
|
272 |
{
|
273 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
274 |
do_action("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars());
|
275 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
276 |
+
|
277 |
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level() : $_level;
|
278 |
if($_level === "auto-detection" && $level < 0 && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number, $m) && !empty($m[1]) && is_numeric($m[1]))
|
279 |
$level = /* A numeric Membership Level # . */ $m[1];
|
280 |
+
|
281 |
$level = ($level !== "any" && (!is_numeric($level) || $level < 0)) ? 0 : /* Default. */ $level;
|
282 |
+
|
283 |
if(($level === "any" || (is_numeric($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
284 |
{
|
285 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
287 |
if(empty($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "no-always-invisible" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible" && $field["editable"] !== "no-always-invisible"))
|
288 |
$configured[] = /* Add this to the array. */ $field["id"];
|
289 |
}
|
|
|
290 |
return apply_filters("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty($configured)) ? $configured : array()), get_defined_vars());
|
291 |
}
|
292 |
/**
|
306 |
public static function ms_custom_registration_fields()
|
307 |
{
|
308 |
do_action("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars());
|
309 |
+
|
310 |
+
if /* Must be Main Site of a Network. */(is_multisite() && is_main_site())
|
311 |
{
|
312 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
|
313 |
+
|
314 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
|
315 |
+
|
316 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
317 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars());
|
318 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
319 |
+
|
320 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
|
321 |
{
|
322 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
|
323 |
+
|
324 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
325 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars());
|
326 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
327 |
+
|
328 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'._x("First Name", "s2member-front", "s2member").' *</label>'."\n";
|
329 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" />'."\n";
|
330 |
echo '<br />'."\n";
|
331 |
+
|
332 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
333 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars());
|
334 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
335 |
+
|
336 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
337 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars());
|
338 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
339 |
+
|
340 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'._x("Last Name", "s2member-front", "s2member").' *</label>'."\n";
|
341 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" />'."\n";
|
342 |
echo '<br />'."\n";
|
343 |
+
|
344 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
345 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars());
|
346 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
347 |
}
|
|
|
348 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
349 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
|
350 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
351 |
{
|
352 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
353 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars());
|
354 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
355 |
+
|
356 |
+
if /* Field applicable? */(in_array($field["id"], $fields_applicable))
|
357 |
{
|
358 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
359 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
360 |
+
|
361 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
362 |
if(apply_filters("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
|
363 |
{
|
364 |
+
if /* Starts a new section? */(!empty($field["section"]) && $field["section"] === "yes")
|
365 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
|
366 |
+
|
367 |
echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'"'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '<br />' : '')."\n";
|
368 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
369 |
echo '<br />'."\n";
|
370 |
}
|
371 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
372 |
}
|
373 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
374 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars());
|
375 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
376 |
}
|
|
|
377 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
|
378 |
{
|
379 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
380 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars());
|
381 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
382 |
+
|
383 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
|
384 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' />'."\n";
|
385 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
|
386 |
echo '</label>'."\n";
|
387 |
echo '<br />'."\n";
|
388 |
+
|
389 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
390 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars());
|
391 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
392 |
}
|
393 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
394 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars());
|
395 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
396 |
}
|
397 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
398 |
do_action("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars());
|
399 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
400 |
+
|
401 |
+
return /* Return for uniformity. */;
|
402 |
}
|
403 |
/**
|
404 |
* Adds Custom Fields to: `/wp-login.php?action=register`.
|
415 |
public static function custom_registration_fields()
|
416 |
{
|
417 |
do_action("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars());
|
418 |
+
|
419 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
|
420 |
+
|
421 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
|
422 |
+
|
423 |
+
$tabindex = /* Incremented tabindex starting with 20. */ 20;
|
424 |
+
|
425 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
426 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars());
|
427 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
428 |
+
|
429 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
430 |
{
|
431 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
432 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars());
|
433 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
434 |
+
|
435 |
echo '<p>'."\n";
|
436 |
+
|
437 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
|
438 |
+
echo '<span>'._x("Password (please type it twice)", "s2member-front", "s2member").' *</span><br />'."\n";
|
439 |
echo '<input type="password" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
440 |
echo '</label>'."\n";
|
441 |
+
|
442 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
|
443 |
echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
444 |
echo '</label>'."\n";
|
445 |
+
|
446 |
echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>'._x("password strength indicator", "s2member-front", "s2member").'</em></div>'."\n";
|
447 |
+
|
448 |
echo '</p>'."\n";
|
449 |
+
|
450 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
451 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars());
|
452 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
453 |
}
|
|
|
454 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
|
455 |
{
|
456 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
|
457 |
+
|
458 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
459 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars());
|
460 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
461 |
+
|
462 |
echo '<p>'."\n";
|
463 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'."\n";
|
464 |
echo '<span>'._x("First Name", "s2member-front", "s2member").' *</span><br />'."\n";
|
465 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
466 |
echo '</label>'."\n";
|
467 |
echo '</p>'."\n";
|
468 |
+
|
469 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
470 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars());
|
471 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
472 |
+
|
473 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
474 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars());
|
475 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
476 |
+
|
477 |
echo '<p>'."\n";
|
478 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'."\n";
|
479 |
echo '<span>'._x("Last Name", "s2member-front", "s2member").' *</span><br />'."\n";
|
480 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
481 |
echo '</label>'."\n";
|
482 |
echo '</p>'."\n";
|
483 |
+
|
484 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
485 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars());
|
486 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
487 |
}
|
|
|
488 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
489 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
|
490 |
{
|
491 |
+
$tabindex = /* Start tabindex at +9 ( +1 below ). */ $tabindex + 9;
|
492 |
+
|
493 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
494 |
{
|
495 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
496 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars());
|
497 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
498 |
+
|
499 |
+
if /* Field applicable? */(in_array($field["id"], $fields_applicable))
|
500 |
{
|
501 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
|
502 |
$field_id_class = preg_replace("/_/", "-", $field_var);
|
503 |
+
|
504 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
505 |
if(apply_filters("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
|
506 |
{
|
507 |
+
if /* Starts a new section? */(!empty($field["section"]) && $field["section"] === "yes")
|
508 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
|
509 |
+
|
510 |
echo '<p>'."\n";
|
511 |
echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'">'."\n";
|
512 |
echo '<span'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</span></label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />')."\n";
|
513 |
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 + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
514 |
echo '</p>'."\n";
|
515 |
}
|
516 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
517 |
}
|
518 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
519 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars());
|
520 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
521 |
}
|
522 |
}
|
|
|
523 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
|
524 |
{
|
525 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
526 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars());
|
527 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
528 |
+
|
529 |
echo '<p>'."\n";
|
530 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
|
531 |
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
|
532 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
|
533 |
echo '</label>'."\n";
|
534 |
echo '</p>'."\n";
|
535 |
+
|
536 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
537 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars());
|
538 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
539 |
}
|
540 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
541 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars());
|
542 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
543 |
+
|
544 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
545 |
do_action("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars());
|
546 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
547 |
+
|
548 |
+
return /* Return for uniformity. */;
|
549 |
}
|
550 |
}
|
551 |
}
|
includes/classes/email-configs.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
21 |
{
|
22 |
/**
|
@@ -40,15 +40,15 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
40 |
public static function email_config ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_email_config", get_defined_vars ());
|
43 |
-
|
44 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
45 |
-
|
46 |
add_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
47 |
add_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
48 |
-
|
49 |
do_action ("ws_plugin__s2member_after_email_config", get_defined_vars ());
|
50 |
-
|
51 |
-
return
|
52 |
}
|
53 |
/**
|
54 |
* A sort of callback function that applies the email Filter.
|
@@ -64,7 +64,7 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
64 |
public static function _email_config_email ($email = FALSE)
|
65 |
{
|
66 |
do_action ("_ws_plugin__s2member_before_email_config_email", get_defined_vars ());
|
67 |
-
|
68 |
return apply_filters ("_ws_plugin__s2member_email_config_email", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"], get_defined_vars ());
|
69 |
}
|
70 |
/**
|
@@ -81,7 +81,7 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
81 |
public static function _email_config_name ($name = FALSE)
|
82 |
{
|
83 |
do_action ("_ws_plugin__s2member_before_email_config_name", get_defined_vars ());
|
84 |
-
|
85 |
return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
|
86 |
}
|
87 |
/**
|
@@ -96,13 +96,13 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
96 |
public static function email_config_status ($any = FALSE)
|
97 |
{
|
98 |
do_action ("ws_plugin__s2member_before_email_config_status", get_defined_vars ());
|
99 |
-
|
100 |
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"))
|
101 |
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
102 |
-
|
103 |
else if ($any && (has_filter ("wp_mail_from") || has_filter ("wp_mail_from_name")))
|
104 |
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
105 |
-
|
106 |
return apply_filters ("ws_plugin__s2member_email_config_status", false, get_defined_vars ());
|
107 |
}
|
108 |
/**
|
@@ -117,16 +117,16 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
117 |
public static function email_config_release ($all = FALSE)
|
118 |
{
|
119 |
do_action ("ws_plugin__s2member_before_email_config_release", get_defined_vars ());
|
120 |
-
|
121 |
remove_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
122 |
remove_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
123 |
-
|
124 |
-
if
|
125 |
remove_all_filters ("wp_mail_from") . remove_all_filters ("wp_mail_from_name");
|
126 |
-
|
127 |
do_action ("ws_plugin__s2member_after_email_config_release", get_defined_vars ());
|
128 |
-
|
129 |
-
return
|
130 |
}
|
131 |
/**
|
132 |
* Converts primitive Role names in emails sent by WordPress®.
|
@@ -143,12 +143,12 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
143 |
*/
|
144 |
public static function ms_nice_email_roles ($message = FALSE)
|
145 |
{
|
146 |
-
|
147 |
do_action ("ws_plugin__s2member_before_ms_nice_email_roles", get_defined_vars ());
|
148 |
-
unset
|
149 |
-
|
150 |
$message = preg_replace ("/ as a (subscriber|s2member_level[0-9]+)/i", " " . _x ("as a Member", "s2member-front", "s2member"), $message);
|
151 |
-
|
152 |
return apply_filters ("ws_plugin__s2member_ms_nice_email_roles", $message, get_defined_vars ());
|
153 |
}
|
154 |
/**
|
@@ -165,12 +165,12 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
165 |
*/
|
166 |
public static function email_filter ($array = FALSE)
|
167 |
{
|
168 |
-
if (isset ($array["to"]) && !empty ($array["to"]))
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
$array["to"] = implode (",", c_ws_plugin__s2member_utils_strings::parse_emails ($array["to"]));
|
173 |
-
|
174 |
return apply_filters ("ws_plugin__s2member_after_email_filter", $array, get_defined_vars ());
|
175 |
}
|
176 |
/**
|
@@ -187,22 +187,22 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
187 |
*/
|
188 |
public static function new_user_notification ($user_id = FALSE, $user_pass = FALSE, $notify = array ("user", "admin"))
|
189 |
{
|
190 |
-
|
191 |
do_action ("ws_plugin__s2member_before_new_user_notification", get_defined_vars ());
|
192 |
-
unset
|
193 |
-
|
194 |
if ($user_id && ($user = new WP_User ($user_id)) && !empty ($user->ID) && ($user_id = $user->ID) && is_array ($notify) && !empty ($notify))
|
195 |
{
|
196 |
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
|
197 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
198 |
-
|
199 |
-
if (in_array ("user", $notify) && $user_pass)
|
200 |
{
|
201 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
202 |
$cv = preg_split ("/\|/", get_user_option ("s2member_custom", $user_id));
|
203 |
$user_full_name = trim ($user->first_name . " " . $user->last_name);
|
204 |
$user_ip = $_SERVER["REMOTE_ADDR"];
|
205 |
-
|
206 |
if (($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_subject"]))
|
207 |
if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)))
|
208 |
if (($sbj = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $sbj)))
|
@@ -216,10 +216,10 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
216 |
if (($sbj = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $sbj)))
|
217 |
{
|
218 |
if (is_array ($fields) && !empty ($fields))
|
219 |
-
foreach ($fields as $var => $val)
|
220 |
if (!($sbj = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $sbj)))
|
221 |
break;
|
222 |
-
|
223 |
if (($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_message"]))
|
224 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
225 |
if (($msg = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $msg)))
|
@@ -233,25 +233,25 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
233 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
234 |
{
|
235 |
if (is_array ($fields) && !empty ($fields))
|
236 |
-
foreach ($fields as $var => $val)
|
237 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
238 |
break;
|
239 |
-
|
240 |
-
if (($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
241 |
-
|
242 |
-
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($user->user_email, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=
|
243 |
}
|
244 |
}
|
245 |
}
|
246 |
-
|
247 |
-
if
|
248 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"])
|
249 |
{
|
250 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
251 |
$cv = preg_split ("/\|/", get_user_option ("s2member_custom", $user_id));
|
252 |
$user_full_name = trim ($user->first_name . " " . $user->last_name);
|
253 |
$user_ip = $_SERVER["REMOTE_ADDR"];
|
254 |
-
|
255 |
if (($rec = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]))
|
256 |
if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)))
|
257 |
if (($rec = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $rec)))
|
@@ -265,10 +265,10 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
265 |
if (($rec = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $rec)))
|
266 |
{
|
267 |
if (is_array ($fields) && !empty ($fields))
|
268 |
-
foreach ($fields as $var => $val)
|
269 |
if (!($rec = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $rec)))
|
270 |
break;
|
271 |
-
|
272 |
if (($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_subject"]))
|
273 |
if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)))
|
274 |
if (($sbj = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $sbj)))
|
@@ -282,10 +282,10 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
282 |
if (($sbj = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $sbj)))
|
283 |
{
|
284 |
if (is_array ($fields) && !empty ($fields))
|
285 |
-
foreach ($fields as $var => $val)
|
286 |
if (!($sbj = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $sbj)))
|
287 |
break;
|
288 |
-
|
289 |
if (($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_message"]))
|
290 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
291 |
if (($msg = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $msg)))
|
@@ -299,27 +299,26 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
|
299 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
300 |
{
|
301 |
if (is_array ($fields) && !empty ($fields))
|
302 |
-
foreach ($fields as $var => $val)
|
303 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
304 |
break;
|
305 |
-
|
306 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
307 |
{
|
308 |
-
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($rec) as $recipient)
|
309 |
-
wp_mail ($recipient, $sbj, $msg, "Content-Type: text/plain; charset=
|
310 |
}
|
311 |
}
|
312 |
}
|
313 |
}
|
314 |
}
|
315 |
-
|
316 |
-
if
|
317 |
c_ws_plugin__s2member_email_configs::email_config ();
|
318 |
-
|
319 |
return apply_filters ("ws_plugin__s2member_new_user_notification", true, get_defined_vars ());
|
320 |
}
|
321 |
-
else
|
322 |
-
return apply_filters ("ws_plugin__s2member_new_user_notification", false, get_defined_vars ());
|
323 |
}
|
324 |
}
|
325 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_email_configs"))
|
21 |
{
|
22 |
/**
|
40 |
public static function email_config ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_email_config", get_defined_vars ());
|
43 |
+
|
44 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
45 |
+
|
46 |
add_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
47 |
add_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
48 |
+
|
49 |
do_action ("ws_plugin__s2member_after_email_config", get_defined_vars ());
|
50 |
+
|
51 |
+
return /* Return for uniformity. */;
|
52 |
}
|
53 |
/**
|
54 |
* A sort of callback function that applies the email Filter.
|
64 |
public static function _email_config_email ($email = FALSE)
|
65 |
{
|
66 |
do_action ("_ws_plugin__s2member_before_email_config_email", get_defined_vars ());
|
67 |
+
|
68 |
return apply_filters ("_ws_plugin__s2member_email_config_email", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"], get_defined_vars ());
|
69 |
}
|
70 |
/**
|
81 |
public static function _email_config_name ($name = FALSE)
|
82 |
{
|
83 |
do_action ("_ws_plugin__s2member_before_email_config_name", get_defined_vars ());
|
84 |
+
|
85 |
return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
|
86 |
}
|
87 |
/**
|
96 |
public static function email_config_status ($any = FALSE)
|
97 |
{
|
98 |
do_action ("ws_plugin__s2member_before_email_config_status", get_defined_vars ());
|
99 |
+
|
100 |
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"))
|
101 |
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
102 |
+
|
103 |
else if ($any && (has_filter ("wp_mail_from") || has_filter ("wp_mail_from_name")))
|
104 |
return apply_filters ("ws_plugin__s2member_email_config_status", true, get_defined_vars ());
|
105 |
+
|
106 |
return apply_filters ("ws_plugin__s2member_email_config_status", false, get_defined_vars ());
|
107 |
}
|
108 |
/**
|
117 |
public static function email_config_release ($all = FALSE)
|
118 |
{
|
119 |
do_action ("ws_plugin__s2member_before_email_config_release", get_defined_vars ());
|
120 |
+
|
121 |
remove_filter ("wp_mail_from", "c_ws_plugin__s2member_email_configs::_email_config_email");
|
122 |
remove_filter ("wp_mail_from_name", "c_ws_plugin__s2member_email_configs::_email_config_name");
|
123 |
+
|
124 |
+
if /* If ``$all`` is true, remove ALL attached WordPress® Filters. */ ($all)
|
125 |
remove_all_filters ("wp_mail_from") . remove_all_filters ("wp_mail_from_name");
|
126 |
+
|
127 |
do_action ("ws_plugin__s2member_after_email_config_release", get_defined_vars ());
|
128 |
+
|
129 |
+
return /* Return for uniformity. */;
|
130 |
}
|
131 |
/**
|
132 |
* Converts primitive Role names in emails sent by WordPress®.
|
143 |
*/
|
144 |
public static function ms_nice_email_roles ($message = FALSE)
|
145 |
{
|
146 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
147 |
do_action ("ws_plugin__s2member_before_ms_nice_email_roles", get_defined_vars ());
|
148 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
149 |
+
|
150 |
$message = preg_replace ("/ as a (subscriber|s2member_level[0-9]+)/i", " " . _x ("as a Member", "s2member-front", "s2member"), $message);
|
151 |
+
|
152 |
return apply_filters ("ws_plugin__s2member_ms_nice_email_roles", $message, get_defined_vars ());
|
153 |
}
|
154 |
/**
|
165 |
*/
|
166 |
public static function email_filter ($array = FALSE)
|
167 |
{
|
168 |
+
if (isset ($array["to"]) && !empty ($array["to"])) // Filter list of recipients?
|
169 |
+
// Reduces `"Name" <email>`, to just an email address *(for best cross-platform compatibility across various MTAs)*.
|
170 |
+
// Also works around bug in PHP versions prior to fix in 5.2.11. See bug report: <https://bugs.php.net/bug.php?id=28038>.
|
171 |
+
// Also supplements WordPress®. WordPress® currently does NOT support semicolon `;` delimitation, s2Member does.
|
172 |
$array["to"] = implode (",", c_ws_plugin__s2member_utils_strings::parse_emails ($array["to"]));
|
173 |
+
|
174 |
return apply_filters ("ws_plugin__s2member_after_email_filter", $array, get_defined_vars ());
|
175 |
}
|
176 |
/**
|
187 |
*/
|
188 |
public static function new_user_notification ($user_id = FALSE, $user_pass = FALSE, $notify = array ("user", "admin"))
|
189 |
{
|
190 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
191 |
do_action ("ws_plugin__s2member_before_new_user_notification", get_defined_vars ());
|
192 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
193 |
+
|
194 |
if ($user_id && ($user = new WP_User ($user_id)) && !empty ($user->ID) && ($user_id = $user->ID) && is_array ($notify) && !empty ($notify))
|
195 |
{
|
196 |
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
|
197 |
c_ws_plugin__s2member_email_configs::email_config_release ();
|
198 |
+
|
199 |
+
if /* Send User a notification? */ (in_array ("user", $notify) && $user_pass)
|
200 |
{
|
201 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
202 |
$cv = preg_split ("/\|/", get_user_option ("s2member_custom", $user_id));
|
203 |
$user_full_name = trim ($user->first_name . " " . $user->last_name);
|
204 |
$user_ip = $_SERVER["REMOTE_ADDR"];
|
205 |
+
|
206 |
if (($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_subject"]))
|
207 |
if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)))
|
208 |
if (($sbj = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $sbj)))
|
216 |
if (($sbj = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $sbj)))
|
217 |
{
|
218 |
if (is_array ($fields) && !empty ($fields))
|
219 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
220 |
if (!($sbj = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $sbj)))
|
221 |
break;
|
222 |
+
|
223 |
if (($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_message"]))
|
224 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
225 |
if (($msg = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $msg)))
|
233 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
234 |
{
|
235 |
if (is_array ($fields) && !empty ($fields))
|
236 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
237 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
238 |
break;
|
239 |
+
|
240 |
+
if (($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
241 |
+
|
242 |
+
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($user->user_email, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=UTF-8") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
243 |
}
|
244 |
}
|
245 |
}
|
246 |
+
|
247 |
+
if /* Send Admin(s) a notification? */ (in_array ("admin", $notify))
|
248 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"])
|
249 |
{
|
250 |
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
251 |
$cv = preg_split ("/\|/", get_user_option ("s2member_custom", $user_id));
|
252 |
$user_full_name = trim ($user->first_name . " " . $user->last_name);
|
253 |
$user_ip = $_SERVER["REMOTE_ADDR"];
|
254 |
+
|
255 |
if (($rec = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]))
|
256 |
if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)))
|
257 |
if (($rec = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $rec)))
|
265 |
if (($rec = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $rec)))
|
266 |
{
|
267 |
if (is_array ($fields) && !empty ($fields))
|
268 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
269 |
if (!($rec = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $rec)))
|
270 |
break;
|
271 |
+
|
272 |
if (($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_subject"]))
|
273 |
if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)))
|
274 |
if (($sbj = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $sbj)))
|
282 |
if (($sbj = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $sbj)))
|
283 |
{
|
284 |
if (is_array ($fields) && !empty ($fields))
|
285 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
286 |
if (!($sbj = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $sbj)))
|
287 |
break;
|
288 |
+
|
289 |
if (($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_message"]))
|
290 |
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
291 |
if (($msg = preg_replace ("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (wp_login_url ()), $msg)))
|
299 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
300 |
{
|
301 |
if (is_array ($fields) && !empty ($fields))
|
302 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
303 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
304 |
break;
|
305 |
+
|
306 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
307 |
{
|
308 |
+
foreach /* A possible list of recipients. */ (c_ws_plugin__s2member_utils_strings::parse_emails ($rec) as $recipient)
|
309 |
+
wp_mail ($recipient, $sbj, $msg, "Content-Type: text/plain; charset=UTF-8");
|
310 |
}
|
311 |
}
|
312 |
}
|
313 |
}
|
314 |
}
|
315 |
+
|
316 |
+
if /* Back on? */ ($email_configs_were_on)
|
317 |
c_ws_plugin__s2member_email_configs::email_config ();
|
318 |
+
|
319 |
return apply_filters ("ws_plugin__s2member_new_user_notification", true, get_defined_vars ());
|
320 |
}
|
321 |
+
else return apply_filters ("ws_plugin__s2member_new_user_notification", false, get_defined_vars ());
|
|
|
322 |
}
|
323 |
}
|
324 |
}
|
includes/classes/files-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* File Download routines for s2Member (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_files_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* File Download routines for s2Member (
|
24 |
*
|
25 |
* @package s2Member\Files
|
26 |
* @since 3.5
|
@@ -43,13 +43,13 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
43 |
*/
|
44 |
public static function check_file_download_access($create_file_download_url = FALSE)
|
45 |
{
|
46 |
-
|
47 |
do_action("ws_plugin__s2member_before_file_download_access", get_defined_vars());
|
48 |
-
unset
|
49 |
-
|
50 |
$_g = !empty($_GET) ? $_GET : array();
|
51 |
$_g = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_g));
|
52 |
-
|
53 |
$creating = /* Creating URL? */ (is_array($create = $create_file_download_url)) ? true : false;
|
54 |
$serving = /* If NOT creating a File Download URL, we're serving one. */ (!$creating) ? true : false;
|
55 |
$serving_range = $range = /* Default values (so these variables DO get defined at all times). */ false;
|
@@ -57,7 +57,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
57 |
{
|
58 |
$range = (string)@$_SERVER["HTTP_RANGE"];
|
59 |
if(!$range && function_exists("apache_request_headers"))
|
60 |
-
|
61 |
foreach((array)apache_request_headers() as $_header => $_value)
|
62 |
if(is_string($_header) && strcasecmp($_header, "range") === 0)
|
63 |
$range = $_value;
|
@@ -65,135 +65,144 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
65 |
$serving_range = true;
|
66 |
unset($_header, $_value);
|
67 |
}
|
68 |
-
|
69 |
$req["file_download"] = ($creating) ? @$create["file_download"] : @$_g["s2member_file_download"];
|
70 |
$req["file_download_key"] = ($creating) ? @$create["file_download_key"] : @$_g["s2member_file_download_key"];
|
71 |
-
|
72 |
$req["file_stream"] = ($creating) ? @$create["file_stream"] : @$_g["s2member_file_stream"];
|
73 |
$req["file_inline"] = ($creating) ? @$create["file_inline"] : @$_g["s2member_file_inline"];
|
74 |
$req["file_storage"] = ($creating) ? @$create["file_storage"] : @$_g["s2member_file_storage"];
|
75 |
$req["file_remote"] = ($creating) ? @$create["file_remote"] : @$_g["s2member_file_remote"];
|
76 |
$req["file_ssl"] = ($creating) ? @$create["file_ssl"] : @$_g["s2member_file_ssl"];
|
77 |
-
|
78 |
$req["file_rewrite"] = ($creating) ? @$create["file_rewrite"] : /* N/A. */ null;
|
79 |
$req["file_rewrite_base"] = ($creating) ? @$create["file_rewrite_base"] : /* N/A. */ null;
|
80 |
-
|
81 |
$req["skip_confirmation"] = ($creating) ? @$create["skip_confirmation"] : /* N/A. */ null;
|
82 |
$req["url_to_storage_source"] = ($creating) ? @$create["url_to_storage_source"] : /* N/A. */ null;
|
83 |
$req["count_against_user"] = ($creating) ? @$create["count_against_user"] : /* N/A. */ null;
|
84 |
$req["check_user"] = ($creating) ? @$create["check_user"] : /* N/A. */ null;
|
85 |
-
|
86 |
if($req["file_download"] && is_string($req["file_download"]) && ($req["file_download"] = trim($req["file_download"], "/")))
|
87 |
if(strpos($req["file_download"], "..") === false && strpos(basename($req["file_download"]), ".") !== 0)
|
88 |
{
|
89 |
$using_amazon_cf_storage = ((!$req["file_storage"] || strcasecmp((string)$req["file_storage"], "cf") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_cf_storage()) ? true : false;
|
90 |
$using_amazon_s3_storage = ((!$req["file_storage"] || strcasecmp((string)$req["file_storage"], "s3") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_s3_storage()) ? true : false;
|
91 |
$using_amazon_storage = /* Either? */ ($using_amazon_cf_storage || $using_amazon_s3_storage) ? true : false;
|
92 |
-
|
93 |
$excluded = apply_filters("ws_plugin__s2member_check_file_download_access_excluded", false, get_defined_vars());
|
94 |
$valid_file_download_key = ($req["file_download_key"] && is_string($req["file_download_key"]) && $creating && (!isset($req["check_user"]) || !filter_var($req["check_user"], FILTER_VALIDATE_BOOLEAN)) && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN))) ? true : false;
|
95 |
$valid_file_download_key = (!$valid_file_download_key && $req["file_download_key"] && is_string($req["file_download_key"])) ? c_ws_plugin__s2member_files_in::check_file_download_key($req["file_download"], $req["file_download_key"]) : false;
|
96 |
$checking_user = ($excluded || $valid_file_download_key || ($creating && (!isset($req["check_user"]) || !filter_var($req["check_user"], FILTER_VALIDATE_BOOLEAN)) && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
|
97 |
$updating_user_counter = ($serving_range || !$checking_user || ($creating && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
|
98 |
-
|
99 |
if( /* In either case, the following routines apply whenever we ARE ``$checking_user``. */($serving || $creating) && $checking_user)
|
100 |
{
|
101 |
if(!$using_amazon_storage && !file_exists($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"]))
|
102 |
{
|
103 |
if /* We only need this section when/if we're actually serving. */($serving)
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
return false;
|
109 |
}
|
110 |
-
|
111 |
else if($req["file_download_key"] && is_string($req["file_download_key"]) && !$valid_file_download_key)
|
112 |
{
|
113 |
if /* We only need this section when/if we're actually serving. */($serving)
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
118 |
return false;
|
119 |
}
|
120 |
-
|
121 |
else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads()) === false)
|
122 |
{
|
123 |
if /* We only need remote functionality when/if we're actually serving. */($serving)
|
124 |
if(!has_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
|
125 |
add_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
|
126 |
-
|
127 |
if /* We only need remote functionality when/if we're actually serving. */($creating)
|
128 |
if(has_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
|
129 |
remove_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
|
130 |
-
|
131 |
if((isset($file_downloads_enabled_by_site_owner, $min_level_4_downloads) && $file_downloads_enabled_by_site_owner === false) || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads()) === false)
|
132 |
{
|
133 |
if /* We only need this section when/if we're actually serving. */($serving)
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
138 |
return false;
|
139 |
}
|
140 |
-
|
141 |
else if(!is_object($user = apply_filters("ws_plugin__s2member_check_file_download_access_user", ((is_user_logged_in()) ? wp_get_current_user() : false), get_defined_vars())) || empty($user->ID) || !($user_id = $user->ID) || !is_array($user_file_downloads = c_ws_plugin__s2member_files::user_downloads($user)) || (!$user->has_cap("administrator") && (!$user_file_downloads["allowed"] || !$user_file_downloads["allowed_days"])))
|
142 |
{
|
143 |
if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen($req_level = $m[1]) && (!is_object($user) || empty($user->ID) || !$user->has_cap("access_s2member_level".$req_level)))
|
144 |
{
|
145 |
if /* We only need this section when/if we're actually serving. */($serving)
|
146 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]).exit();
|
147 |
-
|
148 |
-
else
|
149 |
return false;
|
150 |
}
|
151 |
-
|
152 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen($req_ccap = preg_replace("/-/", "_", $m[1])) && (!is_object($user) || empty($user->ID) || !$user->has_cap("access_s2member_ccap_".$req_ccap)))
|
153 |
{
|
154 |
if /* We only need this section when/if we're actually serving. */($serving)
|
155 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]).exit();
|
156 |
-
|
157 |
-
else
|
158 |
return false;
|
159 |
}
|
160 |
-
|
161 |
else if /* We only need this section when/if we're actually serving. */($serving)
|
162 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $min_level_4_downloads, $_SERVER["REQUEST_URI"]).exit();
|
163 |
-
|
164 |
-
else
|
165 |
return false;
|
166 |
}
|
167 |
-
|
168 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen($req_level = $m[1]) && !$user->has_cap("access_s2member_level".$req_level))
|
169 |
{
|
170 |
if /* We only need this section when/if we're actually serving. */($serving)
|
171 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]).exit();
|
172 |
-
|
173 |
-
else
|
174 |
return false;
|
175 |
}
|
176 |
-
|
177 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen($req_ccap = preg_replace("/-/", "_", $m[1])) && !$user->has_cap("access_s2member_ccap_".$req_ccap))
|
178 |
{
|
179 |
if /* We only need this section when/if we're actually serving. */($serving)
|
180 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]).exit();
|
181 |
-
|
182 |
-
else
|
183 |
return false;
|
184 |
}
|
185 |
-
|
186 |
else if /* In either case, the following routines apply. */($serving || $creating)
|
187 |
{
|
188 |
$user_previous_file_downloads = /* Downloads the User has already; in current period/cycle. */ 0;
|
189 |
$user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = false;
|
190 |
-
|
191 |
$user_file_download_access_log = (is_array($user_file_download_access_log = get_user_option("s2member_file_download_access_log", $user_id))) ? $user_file_download_access_log : array();
|
192 |
$user_file_download_access_arc = (is_array($user_file_download_access_arc = get_user_option("s2member_file_download_access_arc", $user_id))) ? $user_file_download_access_arc : array();
|
193 |
-
|
194 |
$streaming_file_extns = c_ws_plugin__s2member_utils_strings::preg_quote_deep($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["streaming_file_extns"], "/");
|
195 |
$streaming_variations = /* Only count one streaming media file variation. */ "/\.(".implode("|", $streaming_file_extns).")$/i";
|
196 |
-
|
197 |
foreach($user_file_download_access_log as $user_file_download_access_log_entry_key => $user_file_download_access_log_entry)
|
198 |
{
|
199 |
if( /* Weed out corrupt/empty log entries. */isset($user_file_download_access_log_entry["date"], $user_file_download_access_log_entry["file"]))
|
@@ -205,40 +214,40 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
205 |
}
|
206 |
else if(strtotime($user_file_download_access_log_entry["date"]) >= strtotime("-".$user_file_downloads["allowed_days"]." days"))
|
207 |
{
|
208 |
-
$user_previous_file_downloads++;
|
209 |
-
|
210 |
$_user_file_download_access_log_entry = &$user_file_download_access_log[$user_file_download_access_log_entry_key];
|
211 |
$_user_already_downloaded_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = false;
|
212 |
-
|
213 |
if /* Already downloaded this file? If yes, mark this flag as true. */($user_file_download_access_log_entry["file"] === $req["file_download"])
|
214 |
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = /* Already downloaded this file? If yes, mark as true. */ true;
|
215 |
-
|
216 |
else if(preg_replace($streaming_variations, "", $user_file_download_access_log_entry["file"]) === preg_replace($streaming_variations, "", $req["file_download"]))
|
217 |
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = true;
|
218 |
-
|
219 |
if( /* Updating counter? */$updating_user_counter && ($_user_already_downloaded_this_file || $_user_already_downloaded_a_streaming_variation_of_this_file))
|
220 |
{
|
221 |
$_user_file_download_access_log_entry /* First, we update the last download time for this file. */["ltime"] = time();
|
222 |
-
|
223 |
-
if( /* Backward
|
224 |
$_user_file_download_access_log_entry["counter"] = (int)$user_file_download_access_log_entry["counter"] + 1;
|
225 |
-
else
|
226 |
$_user_file_download_access_log_entry["counter"] = 1 + 1;
|
227 |
}
|
228 |
}
|
229 |
}
|
230 |
-
else
|
231 |
-
unset($user_file_download_access_log[$user_file_download_access_log_entry_key]);
|
232 |
}
|
233 |
if( /* Updating counter? */$updating_user_counter && /* Do we need a new log entry for this file? */ !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file)
|
234 |
$user_file_download_access_log[] = array("date" => date("Y-m-d"), "time" => time(), "ltime" => time(), "file" => $req["file_download"], "counter" => 1);
|
235 |
-
|
236 |
if($user_previous_file_downloads >= $user_file_downloads["allowed"] && !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file && !$user->has_cap("administrator"))
|
237 |
{
|
238 |
if /* We only need this section when/if we're actually serving. */($serving)
|
239 |
wp_redirect(add_query_arg(urlencode_deep(array("_s2member_seeking" => array("type" => "file", "file" => $req["file_download"], "_uri" => base64_encode($_SERVER["REQUEST_URI"])), "s2member_seeking" => "file-".$req["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())).exit();
|
240 |
-
|
241 |
-
else
|
242 |
return false;
|
243 |
}
|
244 |
else if /* Save/update counter? By default, we do NOT update the counter when a URL is simply being created for access. */($updating_user_counter)
|
@@ -246,75 +255,78 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
246 |
}
|
247 |
}
|
248 |
}
|
249 |
-
else
|
250 |
{
|
251 |
if(!$using_amazon_storage && !file_exists($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"]))
|
252 |
{
|
253 |
if /* We only need this section when/if we're actually serving. */($serving)
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
|
|
|
|
258 |
return false;
|
259 |
}
|
260 |
}
|
261 |
-
|
262 |
if /* In either case, the following routines apply. */($serving || $creating)
|
263 |
{
|
264 |
$basename = basename($req["file_download"]);
|
265 |
$mimetypes = parse_ini_file(dirname(dirname(dirname(__FILE__)))."/includes/mime-types.ini");
|
266 |
$extension = strtolower(substr($req["file_download"], strrpos($req["file_download"], ".") + 1));
|
267 |
-
|
268 |
$key = ($req["file_download_key"] && is_string($req["file_download_key"])) ? $req["file_download_key"] : false;
|
269 |
-
|
270 |
$stream = (isset($req["file_stream"])) ? filter_var($req["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
|
271 |
$inline = (!$stream && isset($req["file_inline"])) ? filter_var($req["file_inline"], FILTER_VALIDATE_BOOLEAN) : (($stream || in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]))) ? true : false);
|
272 |
$ssl = (isset($req["file_ssl"])) ? filter_var($req["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl()) ? true : false);
|
273 |
$storage = ($req["file_storage"] && is_string($req["file_storage"])) ? strtolower($req["file_storage"]) : false;
|
274 |
$remote = (isset($req["file_remote"])) ? filter_var($req["file_remote"], FILTER_VALIDATE_BOOLEAN) : false;
|
275 |
-
|
276 |
$_basename_dir_app_data = c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]);
|
277 |
$rewrite_base_guess = (is_dir(dirname($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir"])."/".$_basename_dir_app_data)) ? dirname($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"])."/".$_basename_dir_app_data : content_url("/".$_basename_dir_app_data);
|
278 |
$rewrite_base = ($req["file_rewrite_base"] && is_string($req["file_rewrite_base"])) ? $req["file_rewrite_base"] : false;
|
279 |
$rewrite = $rewriting = (!$rewrite_base && isset($req["file_rewrite"])) ? filter_var($req["file_rewrite"], FILTER_VALIDATE_BOOLEAN) : (($rewrite_base) ? true : false);
|
280 |
unset /* A little housekeeping here. */($_basename_dir_app_data);
|
281 |
-
|
282 |
$skip_confirmation = (isset($req["skip_confirmation"])) ? filter_var($req["skip_confirmation"], FILTER_VALIDATE_BOOLEAN) : false;
|
283 |
$url_to_storage_source = (isset($req["url_to_storage_source"])) ? filter_var($req["url_to_storage_source"], FILTER_VALIDATE_BOOLEAN) : false;
|
284 |
-
|
285 |
$pathinfo = (!$using_amazon_storage) ? pathinfo(($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"])) : array();
|
286 |
$mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream";
|
287 |
$disposition = (($inline) ? "inline" : "attachment")."; filename=\"".c_ws_plugin__s2member_utils_strings::esc_dq($basename)."\"; filename*=UTF-8''".rawurlencode($basename);
|
288 |
$length = (!$using_amazon_storage && $file) ? filesize($file) : -1;
|
289 |
-
|
290 |
-
|
291 |
do_action("ws_plugin__s2member_during_file_download_access", get_defined_vars());
|
292 |
-
unset
|
293 |
-
|
294 |
if($using_amazon_storage && $using_amazon_cf_storage && ($serving || ($creating && $url_to_storage_source)))
|
295 |
{
|
296 |
if /* We only need this section when/if we're actually serving. */($serving)
|
297 |
wp_redirect(c_ws_plugin__s2member_files_in::amazon_cf_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)).exit();
|
298 |
-
|
299 |
-
else
|
300 |
return apply_filters("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_cf_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars());
|
301 |
}
|
302 |
-
|
303 |
else if($using_amazon_storage && $using_amazon_s3_storage && ($serving || ($creating && $url_to_storage_source)))
|
304 |
{
|
305 |
if /* We only need this section when/if we're actually serving. */($serving)
|
306 |
wp_redirect(c_ws_plugin__s2member_files_in::amazon_s3_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)).exit();
|
307 |
-
|
308 |
-
else
|
309 |
return apply_filters("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_s3_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars());
|
310 |
}
|
311 |
-
|
312 |
else if /* Creating a rewrite URL, pointing to local storage. */($creating && $rewriting)
|
313 |
-
{
|
314 |
$_url_e_key = ($key) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($key)) : "";
|
315 |
$_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($storage)) : "";
|
316 |
$_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($req["file_download"]));
|
317 |
-
|
318 |
$url = ($rewrite_base) ? rtrim($rewrite_base, "/") : rtrim($rewrite_base_guess, "/");
|
319 |
$url .= (isset($req["file_download_key"])) ? (($key && $_url_e_key) ? "/s2member-file-download-key-".$_url_e_key : "") : "";
|
320 |
$url .= (isset($req["file_stream"])) ? (($stream) ? "/s2member-file-stream" : "/s2member-file-stream-no") : "";
|
@@ -322,41 +334,42 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
322 |
$url .= (isset($req["file_storage"])) ? (($storage && $_url_e_storage) ? "/s2member-file-storage-".$_url_e_storage : "") : "";
|
323 |
$url .= (isset($req["file_remote"])) ? (($remote) ? "/s2member-file-remote" : "/s2member-file-remote-no") : "";
|
324 |
$url .= (isset($req["skip_confirmation"])) ? (($skip_confirmation) ? "/s2member-skip-confirmation" : "/s2member-skip-confirmation-no") : "";
|
325 |
-
|
326 |
$url = /* File Download Access URL via `mod_rewrite` functionality. */ $url."/".$_url_e_file;
|
327 |
$url = ($ssl) ? preg_replace("/^https?/", "https", $url) : preg_replace("/^https?/", "http", $url);
|
328 |
-
|
329 |
return apply_filters("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars());
|
330 |
}
|
331 |
-
|
332 |
else if /* Else we're creating a URL w/ a query-string; w/ local storage. */($creating)
|
333 |
-
{
|
334 |
$_url_e_key = ($key) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($key)) : "";
|
335 |
$_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($storage)) : "";
|
336 |
$_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($req["file_download"]));
|
337 |
-
|
338 |
$url = (isset($req["file_download_key"])) ? (($key && $_url_e_key) ? "&s2member_file_download_key=".$_url_e_key : "") : "";
|
339 |
$url .= (isset($req["file_stream"])) ? (($stream) ? "&s2member_file_stream=yes" : "&s2member_file_stream=no") : "";
|
340 |
$url .= (isset($req["file_inline"])) ? (($inline) ? "&s2member_file_inline=yes" : "&s2member_file_inline=no") : "";
|
341 |
$url .= (isset($req["file_storage"])) ? (($storage && $_url_e_storage) ? "&s2member_file_storage=".$_url_e_storage : "") : "";
|
342 |
$url .= (isset($req["file_remote"])) ? (($remote) ? "&s2member_file_remote=yes" : "&s2member_file_remote=no") : "";
|
343 |
$url .= (isset($req["skip_confirmation"])) ? (($skip_confirmation) ? "&s2member_skip_confirmation=yes" : "&s2member_skip_confirmation=no") : "";
|
344 |
-
|
345 |
$url = site_url("/?".ltrim($url."&s2member_file_download=/".$_url_e_file, "&"));
|
346 |
$url = ($ssl) ? preg_replace("/^https?/", "https", $url) : preg_replace("/^https?/", "http", $url);
|
347 |
-
|
348 |
return apply_filters("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars());
|
349 |
}
|
350 |
-
|
351 |
else if /* Else, ``if ($serving)``, use local storage. */($serving)
|
352 |
{
|
353 |
@set_time_limit(0);
|
354 |
-
|
355 |
@ini_set("zlib.output_compression", 0);
|
356 |
if(function_exists("apache_setenv"))
|
357 |
@apache_setenv("no-gzip", "1");
|
|
|
358 |
while /* Cleans existing output buffers. */(@ob_end_clean());
|
359 |
-
|
360 |
if /* Requesting a specific byte range? */($range)
|
361 |
{
|
362 |
if /* Invalid range? */(strpos($range, "=") === FALSE)
|
@@ -371,10 +384,10 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
371 |
exit /* Stop here (invalid). */();
|
372 |
}
|
373 |
list($range_type, $byte_range) = preg_split("/\s*\=\s*/", $range, 2);
|
374 |
-
|
375 |
$range_type = strtolower(trim($range_type));
|
376 |
$byte_range = trim($byte_range);
|
377 |
-
|
378 |
if /* Invalid range type? */($range_type !== "bytes")
|
379 |
{
|
380 |
status_header(416);
|
@@ -387,7 +400,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
387 |
exit /* Stop here (invalid). */();
|
388 |
}
|
389 |
$byte_ranges = preg_split("/\s*,\s*/", $byte_range);
|
390 |
-
|
391 |
if /* Invalid byte range? */(strpos($byte_ranges[0], "-") === FALSE)
|
392 |
{
|
393 |
status_header(416);
|
@@ -399,15 +412,16 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
399 |
header("Content-Disposition: ".$disposition);
|
400 |
exit /* Stop here (invalid). */();
|
401 |
}
|
402 |
-
|
|
|
403 |
list($byte_range_start, $byte_range_stops) = preg_split("/\s*\-\s*/", $byte_ranges[0], 2);
|
404 |
-
|
405 |
$byte_range_start = trim($byte_range_start);
|
406 |
$byte_range_stops = trim($byte_range_stops);
|
407 |
-
|
408 |
$byte_range_start = ($byte_range_start === "") ? NULL : (integer)$byte_range_start;
|
409 |
$byte_range_stops = ($byte_range_stops === "") ? NULL : (integer)$byte_range_stops;
|
410 |
-
|
411 |
if(!isset($byte_range_start) && $byte_range_stops > 0 && $byte_range_stops <= $length)
|
412 |
{
|
413 |
$byte_range_start = $length - $byte_range_stops;
|
@@ -418,9 +432,9 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
418 |
$byte_range_stops = /* To the end of the file in this case. */ $length - 1;
|
419 |
}
|
420 |
else if(isset($byte_range_start, $byte_range_stops) && $byte_range_start >= 0 && $byte_range_start < $length - 1 && $byte_range_stops > $byte_range_start && $byte_range_stops <= $length - 1) {
|
421 |
-
|
422 |
}
|
423 |
-
else
|
424 |
{
|
425 |
status_header(416);
|
426 |
nocache_headers();
|
@@ -431,7 +445,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
431 |
header("Content-Disposition: ".$disposition);
|
432 |
exit /* Stop here (invalid). */();
|
433 |
}
|
434 |
-
|
435 |
status_header(206);
|
436 |
nocache_headers();
|
437 |
header("Content-Encoding:");
|
@@ -442,7 +456,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
442 |
header("Content-Length: ".$byte_range_size);
|
443 |
header("Content-Disposition: ".$disposition);
|
444 |
}
|
445 |
-
else
|
446 |
{
|
447 |
status_header(200);
|
448 |
nocache_headers();
|
@@ -459,11 +473,11 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
459 |
$_bytes_to_read = $byte_range_size;
|
460 |
fseek($resource, $byte_range_start);
|
461 |
}
|
462 |
-
else
|
463 |
$_bytes_to_read = $length;
|
464 |
-
|
465 |
$chunk_size = apply_filters("ws_plugin__s2member_file_downloads_chunk_size", 2097152, get_defined_vars());
|
466 |
-
|
467 |
while /* We have bytes to read here. */($_bytes_to_read)
|
468 |
{
|
469 |
$_bytes_to_read -= ($_reading = ($_bytes_to_read > $chunk_size) ? $chunk_size : $_bytes_to_read);
|
@@ -477,16 +491,19 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
477 |
}
|
478 |
}
|
479 |
}
|
480 |
-
|
481 |
else if /* We only need this section when/if we're actually serving. */($serving && $req["file_download"])
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
|
|
|
|
485 |
else if /* We only need this section when/if we're creating a URL. */($creating)
|
486 |
return false;
|
487 |
-
|
488 |
do_action("ws_plugin__s2member_after_file_download_access", get_defined_vars());
|
489 |
-
|
490 |
return ($creating) ? /* If creating, false. */ false : null;
|
491 |
}
|
492 |
/**
|
@@ -497,48 +514,48 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
497 |
*
|
498 |
* @param array $config Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine.
|
499 |
* Possible ``$config`` array elements: `file_download` *(required)*, `file_download_key`, `file_stream`, `file_inline`, `file_storage`, `file_remote`, `file_ssl`, `file_rewrite`, `file_rewrite_base`, `skip_confirmation`, `url_to_storage_source`, `count_against_user`, `check_user`.
|
500 |
-
* @param bool $get_streamer_array Optional. Defaults to `false`. If `true`, this function will return an array with the following elements: `streamer`, `file`, `url`. For further details, please review this section in your Dashboard: `s2Member
|
501 |
* @return str A File Download URL string on success; or an array on success, with elements `streamer`, `file`, `url` when/if ``$get_streamer_array`` is true; else false on any type of failure.
|
502 |
*
|
503 |
* @see s2Member\API_Functions\s2member_file_download_url()
|
504 |
*/
|
505 |
public static function create_file_download_url($config = FALSE, $get_streamer_array = FALSE)
|
506 |
{
|
507 |
-
|
508 |
do_action("ws_plugin__s2member_before_create_file_download_url", get_defined_vars());
|
509 |
-
unset
|
510 |
-
|
511 |
$config = (is_array($config)) ? $config : /* This absolutely MUST be an array. */ array();
|
512 |
-
|
513 |
$config["file_download"] = (isset($config["file_download"]) && is_string($config["file_download"])) ? trim($config["file_download"], "/") : @$config["file_download"];
|
514 |
$config["file_download_key"] = (isset($config["file_download"]) && is_string($config["file_download"]) && !empty($config["file_download_key"])) ? c_ws_plugin__s2member_files::file_download_key($config["file_download"], ((in_array($config["file_download_key"], array("ip-forever", "universal", "cache-compatible"))) ? $config["file_download_key"] : false)) : @$config["file_download_key"];
|
515 |
-
|
516 |
$config["url_to_storage_source"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["url_to_storage_source"];
|
517 |
$config["file_stream"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["file_stream"];
|
518 |
-
|
519 |
if(($_url = c_ws_plugin__s2member_files_in::check_file_download_access /* Successfully created a URL to the file? */(($create_file_download_url = $config))))
|
520 |
{
|
521 |
-
|
522 |
do_action("ws_plugin__s2member_during_create_file_download_url", get_defined_vars());
|
523 |
-
unset
|
524 |
-
|
525 |
$extension = strtolower(substr($config["file_download"], strrpos($config["file_download"], ".") + 1));
|
526 |
$streaming = (isset($config["file_stream"])) ? filter_var($config["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
|
527 |
$ssl = (isset($config["file_ssl"])) ? filter_var($config["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl()) ? true : false);
|
528 |
-
|
529 |
if($get_streamer_array && $streaming && ($cfx = "/cfx/st") && ($cfx_pos = strpos($_url, $cfx)) !== false && ($streamer = substr($_url, 0, $cfx_pos + strlen($cfx))) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
|
530 |
$return = array("streamer" => $streamer, "prefix" => $extension.":", "file" => preg_replace("/^".preg_quote($streamer, "/")."\//", "", $_url), "url" => preg_replace("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
|
531 |
-
|
532 |
else if($get_streamer_array && $streaming && is_array($ups = c_ws_plugin__s2member_utils_urls::parse_url($_url)) && isset($ups["scheme"], $ups["host"]) && ($streamer = $ups["scheme"]."://".$ups["host"].((!empty($ups["port"])) ? ":".$ups["port"] : "")) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
|
533 |
$return = array("streamer" => $streamer, "prefix" => $extension.":", "file" => preg_replace("/^".preg_quote($streamer, "/")."\//", "", $_url), "url" => preg_replace("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
|
534 |
-
|
535 |
else if /* If streamer, we MUST return false here; unable to acquire streamer/file. */($get_streamer_array)
|
536 |
$return = /* We MUST return false here, unable to acquire streamer/file. */ false;
|
537 |
-
|
538 |
-
else
|
539 |
$return = /* Else return URL string. */ $_url;
|
540 |
}
|
541 |
-
|
542 |
return apply_filters("ws_plugin__s2member_create_file_download_url", ((isset($return)) ? $return : false), get_defined_vars());
|
543 |
}
|
544 |
/**
|
@@ -554,29 +571,29 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
554 |
*/
|
555 |
public static function check_file_remote_authorization($user = FALSE)
|
556 |
{
|
557 |
-
|
558 |
do_action("ws_plugin__s2member_before_check_file_remote_authorization", get_defined_vars());
|
559 |
-
unset
|
560 |
-
|
561 |
$_g = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep(((!empty($_GET)) ? $_GET : array())));
|
562 |
-
|
563 |
if(!is_object($user) && isset($_g["s2member_file_remote"]) && filter_var($_g["s2member_file_remote"], FILTER_VALIDATE_BOOLEAN))
|
564 |
{
|
565 |
do_action("ws_plugin__s2member_during_check_file_remote_authorization_before", get_defined_vars());
|
566 |
-
|
567 |
if(empty($_SERVER["PHP_AUTH_USER"]) || empty($_SERVER["PHP_AUTH_PW"]) || !user_pass_ok($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
|
568 |
{
|
569 |
header('WWW-Authenticate: Basic realm="'.c_ws_plugin__s2member_utils_strings::esc_dq(strip_tags(_x("Members Only", "s2member-front", "s2member"))).'"');
|
570 |
-
|
571 |
status_header /* Send an unauthorized 401 status header now. */(401);
|
572 |
-
header /* Content-Type with UTF-8. */("Content-Type: text/html; charset=
|
573 |
-
|
574 |
-
|
575 |
exit(_x('<strong>401:</strong> Sorry, access denied.', "s2member-front", "s2member"));
|
576 |
}
|
577 |
else if(is_object($_user = new WP_User($_SERVER["PHP_AUTH_USER"])) && !empty($_user->ID))
|
578 |
$user = /* Now assign ``$user``. */ $_user;
|
579 |
-
|
580 |
do_action("ws_plugin__s2member_during_check_file_remote_authorization_after", get_defined_vars());
|
581 |
}
|
582 |
return apply_filters("ws_plugin__s2member_check_file_remote_authorization", $user, get_defined_vars());
|
@@ -593,10 +610,10 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
593 |
*/
|
594 |
public static function check_file_download_key($file = FALSE, $key = FALSE)
|
595 |
{
|
596 |
-
|
597 |
do_action("_ws_plugin__s2member_before_check_file_download_key", get_defined_vars());
|
598 |
-
unset
|
599 |
-
|
600 |
if($file && is_string($file) && ($file = trim($file, "/")) && $key && is_string($key))
|
601 |
{
|
602 |
if($key === c_ws_plugin__s2member_files::file_download_key($file) || $key === c_ws_plugin__s2member_files::file_download_key("/".$file))
|
@@ -620,7 +637,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
620 |
public static function amazon_s3_sign($string = FALSE)
|
621 |
{
|
622 |
$s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
623 |
-
|
624 |
return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign((string)$string, $s3c["secret_key"]);
|
625 |
}
|
626 |
/**
|
@@ -641,19 +658,19 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
641 |
{
|
642 |
$file = /* Trim / force string. */ trim((string)$file, "/");
|
643 |
$url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($file));
|
644 |
-
|
645 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
646 |
if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
|
647 |
$s3c[$option] = $option_value;
|
648 |
-
|
649 |
$s3c["expires"] = strtotime("+".apply_filters("ws_plugin__s2member_amazon_s3_file_expires_time", "24 hours", get_defined_vars()));
|
650 |
-
|
651 |
$s3_file = add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode_deep(array("response-cache-control" => ($s3_cache_control = "no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"), "response-content-disposition" => ($s3_content_disposition = (((bool)$inline) ? "inline" : "attachment").'; filename="'.(string)$basename.'"'), "response-content-type" => ($s3_content_type = (string)$mimetype), "response-expires" => ($s3_expires = gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT")))), "/".$url_e_file);
|
652 |
$s3_raw_file = add_query_arg(array("response-cache-control" => $s3_cache_control, "response-content-disposition" => $s3_content_disposition, "response-content-type" => $s3_content_type, "response-expires" => $s3_expires), "/".$url_e_file);
|
653 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("GET\n\n\n".$s3c["expires"]."\n"."/".$s3c["bucket"].$s3_raw_file));
|
654 |
-
|
655 |
$s3_url = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "http".(($ssl) ? "s" : "")."://s3.amazonaws.com/".$s3c["bucket"].$s3_file : "http".(($ssl) ? "s" : "")."://".$s3c["bucket"].".s3.amazonaws.com".$s3_file;
|
656 |
-
|
657 |
return add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode_deep(array("AWSAccessKeyId" => $s3c["access_key"], "Expires" => $s3c["expires"], "Signature" => $s3_signature))), $s3_url);
|
658 |
}
|
659 |
/**
|
@@ -670,9 +687,9 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
670 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
671 |
if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
|
672 |
$s3c[$option] = $option_value;
|
673 |
-
|
674 |
$cfc["distros_s3_access_id"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_s3_access_id"];
|
675 |
-
|
676 |
if /* Must have Amazon® S3 Bucket/Keys. */($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
|
677 |
{
|
678 |
$s3_date = gmdate("D, d M Y H:i:s")." GMT";
|
@@ -680,7 +697,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
680 |
$s3_domain = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "s3.amazonaws.com" : $s3c["bucket"].".s3.amazonaws.com";
|
681 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("GET\n\n\n".$s3_date."\n/".$s3c["bucket"]."/?acl"));
|
682 |
$s3_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $s3_domain, "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
683 |
-
|
684 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
685 |
{
|
686 |
if(preg_match("/\<Owner\>(.+?)\<\/Owner\>/is", $s3_response["body"], $s3_owner_tag) && preg_match("/\<ID\>(.+?)\<\/ID\>/is", $s3_owner_tag[1], $s3_owner_id_tag) && (preg_match("/\<DisplayName\>(.*?)\<\/DisplayName\>/is", $s3_owner_tag[1], $s3_owner_display_name_tag) || ($s3_owner_display_name_tag = array("-", "Owner"))))
|
@@ -689,7 +706,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
689 |
$s3_acls_xml = '<AccessControlPolicy><Owner><ID>'.esc_html($s3_owner["access_id"]).'</ID><DisplayName>'.esc_html($s3_owner["display_name"]).'</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>'.esc_html($s3_owner["access_id"]).'</ID><DisplayName>'.esc_html($s3_owner["display_name"]).'</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant>'.(($cfc["distros_s3_access_id"]) ? '<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>'.esc_html($cfc["distros_s3_access_id"]).'</ID><DisplayName>s2Member/CloudFront</DisplayName></Grantee><Permission>READ</Permission></Grant>' : '').'</AccessControlList></AccessControlPolicy>';
|
690 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\napplication/xml\n".$s3_date."\n/".$s3c["bucket"]."/?acl"));
|
691 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_acls_xml, "headers" => array("Host" => $s3_domain, "Content-Type" => "application/xml", "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
692 |
-
|
693 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
694 |
{
|
695 |
$s3_location = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "/".$s3c["bucket"]."/?policy" : "/?policy";
|
@@ -697,49 +714,49 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
697 |
$s3_policy_json = '{"Version":"2008-10-17","Id":"'.c_ws_plugin__s2member_utils_strings::esc_dq($s3_policy_id).'","Statement":[{"Sid":"'.c_ws_plugin__s2member_utils_strings::esc_dq($s3_policy_sid).'","Effect":"Allow","Principal":{"CanonicalUser":"'.c_ws_plugin__s2member_utils_strings::esc_dq($cfc["distros_s3_access_id"]).'"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::'.c_ws_plugin__s2member_utils_strings::esc_dq($s3c["bucket"]).'/*"}]}';
|
698 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\napplication/json\n".$s3_date."\n/".$s3c["bucket"]."/?policy"));
|
699 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_policy_json, "headers" => array("Host" => $s3_domain, "Content-Type" => "application/json", "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
700 |
-
|
701 |
if(!$cfc["distros_s3_access_id"] || (($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && ($s3_response["code"] === 200 || $s3_response["code"] === 204 /* Also OK. */)))
|
702 |
{
|
703 |
$s3_location = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "/".$s3c["bucket"]."/crossdomain.xml" : "/crossdomain.xml";
|
704 |
$s3_policy_xml = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__))."/templates/cfg-files/s2-cross-xml.php")));
|
705 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\ntext/xml\n".$s3_date."\nx-amz-acl:public-read\n/".$s3c["bucket"]."/crossdomain.xml"));
|
706 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_policy_xml, "headers" => array("Host" => $s3_domain, "Content-Type" => "text/xml", "Date" => $s3_date, "X-Amz-Acl" => "public-read", "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
707 |
-
|
708 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
709 |
return /* Successfully configured Amazon® S3 Bucket ACLs and Policy. */ array("success" => true, "code" => null, "message" => null);
|
710 |
-
|
711 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
712 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
713 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Cross-Domain Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
714 |
-
|
715 |
-
else
|
716 |
return array("success" => false, "code" => -94, "message" => _x("Unable to update existing Amazon® S3 Cross-Domain Policy. Connection failed.", "s2member-admin", "s2member"));
|
717 |
}
|
718 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
719 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
720 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Bucket Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
721 |
-
|
722 |
-
else
|
723 |
return array("success" => false, "code" => -95, "message" => _x("Unable to update existing Amazon® S3 Bucket Policy. Connection failed.", "s2member-admin", "s2member"));
|
724 |
}
|
725 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
726 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
727 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
728 |
-
|
729 |
-
else
|
730 |
return array("success" => false, "code" => -96, "message" => _x("Unable to update existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
|
731 |
}
|
732 |
-
else
|
733 |
return array("success" => false, "code" => -97, "message" => _x("Unable to acquire/read existing Amazon® S3 Bucket ACLs. Unexpected response.", "s2member-admin", "s2member"));
|
734 |
}
|
735 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
736 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
737 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
738 |
-
|
739 |
-
else
|
740 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
|
741 |
}
|
742 |
-
else
|
743 |
return array("success" => false, "code" => -99, "message" => _x("Unable to auto-configure existing Amazon® S3 Bucket ACLs. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key.", "s2member-admin", "s2member"));
|
744 |
}
|
745 |
/**
|
@@ -754,7 +771,7 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
754 |
public static function amazon_cf_sign($string = FALSE)
|
755 |
{
|
756 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
757 |
-
|
758 |
return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign((string)$string, ($cfc["secret_key"] = $s3c["secret_key"]));
|
759 |
}
|
760 |
/**
|
@@ -765,14 +782,11 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
765 |
*
|
766 |
* @param str $string Input string/data, to be signed by this routine.
|
767 |
* @return str|bool An RSA-SHA1 signature for Amazon® CloudFront, else false on failure.
|
768 |
-
*
|
769 |
-
* @todo Double underscores *( i.e. base64 padding chars )* in the signature seem to cause issues for Amazon® CloudFront?
|
770 |
-
* See ticket: {@link https://forums.aws.amazon.com/thread.jspa?messageID=286182񅷦}
|
771 |
*/
|
772 |
public static function amazon_cf_rsa_sign($string = FALSE)
|
773 |
{
|
774 |
$cfc["private_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"];
|
775 |
-
|
776 |
return c_ws_plugin__s2member_utils_strings::rsa_sha1_sign((string)$string, $cfc["private_key"]);
|
777 |
}
|
778 |
/**
|
@@ -791,26 +805,26 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
791 |
*/
|
792 |
public static function amazon_cf_url($file = FALSE, $stream = FALSE, $inline = FALSE, $ssl = FALSE, $basename = FALSE, $mimetype = FALSE)
|
793 |
{
|
794 |
-
$file = /* Trim
|
795 |
$url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($file));
|
796 |
-
|
797 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
798 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
799 |
$cfc[$option] = $option_value;
|
800 |
-
|
801 |
$cfc["expires"] = strtotime("+".apply_filters("ws_plugin__s2member_amazon_cf_file_expires_time", "24 hours", get_defined_vars()));
|
802 |
-
|
803 |
$cf_extn = /* Parses the file extension out so we can scan it in some special scenarios. */ strtolower(substr($file, strrpos($file, ".") + 1));
|
804 |
$cf_ip_res = /* Do NOT restrict access to a particular IP during `localhost` development. The IP may NOT be the same one Amazon® CloudFront sees. */ (c_ws_plugin__s2member_utils_conds::is_localhost()) ? false : true;
|
805 |
$cf_stream_extn_resource_exclusions = array_unique((array)apply_filters("ws_plugin__s2member_amazon_cf_file_streaming_extension_resource_exclusions", array("mp3" /* MP3 files should NOT include an extension in their resource reference. */), get_defined_vars()));
|
806 |
$cf_resource = ($stream) ? ((in_array($cf_extn, $cf_stream_extn_resource_exclusions)) ? substr($file, 0, strrpos($file, ".")) : $file) : "http".(($ssl) ? "s" : "")."://".(($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"])."/".$url_e_file;
|
807 |
$cf_url = ($stream) ? "rtmp".(($ssl) ? "e" : "")."://".(($cfc["distro_streaming_cname"]) ? $cfc["distro_streaming_cname"] : $cfc["distro_streaming_dname"])."/cfx/st/".$file : "http".(($ssl) ? "s" : "")."://".(($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"])."/".$url_e_file;
|
808 |
$cf_policy = '{"Statement":[{"Resource":"'.c_ws_plugin__s2member_utils_strings::esc_dq($cf_resource).'","Condition":{'.(($cf_ip_res) ? '"IpAddress":{"AWS:SourceIp":"'.c_ws_plugin__s2member_utils_strings::esc_dq($_SERVER["REMOTE_ADDR"]).'/32"},' : '').'"DateLessThan":{"AWS:EpochTime":'.(int)$cfc["expires"].'}}}]}';
|
809 |
-
|
810 |
$cf_signature = c_ws_plugin__s2member_files_in::amazon_cf_rsa_sign($cf_policy);
|
811 |
$cf_base64_url_safe_policy = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($cf_policy, array("+", "=", "/"), array("-", "_", "~"), false);
|
812 |
$cf_base64_url_safe_signature = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($cf_signature, array("+", "=", "/"), array("-", "_", "~"), false);
|
813 |
-
|
814 |
return add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode_deep(array("Policy" => $cf_base64_url_safe_policy, "Signature" => $cf_base64_url_safe_signature, "Key-Pair-Id" => $cfc["private_key_id"]))), $cf_url);
|
815 |
}
|
816 |
/**
|
@@ -827,11 +841,11 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
827 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
828 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
829 |
$cfc[$option] = $option_value;
|
830 |
-
|
831 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
832 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
833 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
834 |
-
|
835 |
if /* We MUST have an Amazon® S3 Bucket and Keys. */($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
|
836 |
{
|
837 |
if /* We MUST have Amazon® CloudFront Keys in order to auto-configure. */($cfc["private_key"] && $cfc["private_key_id"])
|
@@ -840,78 +854,78 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
840 |
{
|
841 |
if(!$cfc["distro_downloads_id"] || ($cfc["distro_downloads_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
842 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
843 |
-
|
844 |
else if($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
|
845 |
return array("success" => false, "code" => -86, "message" => _x("Unable to delete existing Amazon® CloudFront Downloads Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
846 |
-
|
847 |
else if($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro($cfc["distro_downloads_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
848 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
849 |
-
|
850 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
851 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
852 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
853 |
-
|
854 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distro_downloads_clear) && $cf_distro_downloads_clear)
|
855 |
{
|
856 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
857 |
-
|
858 |
if(!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_distro($cfc["distro_streaming_id"], "streaming")) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
|
859 |
{
|
860 |
if(!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
861 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
862 |
-
|
863 |
else if($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
|
864 |
return array("success" => false, "code" => -87, "message" => _x("Unable to delete existing Amazon® CloudFront Streaming Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
865 |
-
|
866 |
else if($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro($cfc["distro_streaming_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
867 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
868 |
-
|
869 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
870 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
871 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
872 |
-
|
873 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distro_streaming_clear) && $cf_distro_streaming_clear)
|
874 |
{
|
875 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
876 |
-
|
877 |
if(!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_access_origin_identity($cfc["distros_access_id"])) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
|
878 |
{
|
879 |
if(!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
880 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
881 |
-
|
882 |
else if($cfc["distros_access_id"] && $cf_get_response && $cf_get_response["success"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_access_origin_identity($cfc["distros_access_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
883 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
884 |
-
|
885 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
886 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
887 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
888 |
-
|
889 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distros_access_clear) && $cf_distros_access_clear)
|
890 |
{
|
891 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
892 |
-
|
893 |
$cfc = array_merge($cfc, array("distros_access_id" => "", "distros_s3_access_id" => "", "distro_downloads_id" => "", "distro_downloads_dname" => "", "distro_streaming_id" => "", "distro_streaming_dname" => "", "distros_auto_config_status" => ""));
|
894 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distros_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => "", "ws_plugin__s2member_amazon_cf_files_distros_auto_config_status" => "");
|
895 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
896 |
-
|
897 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distros_access_origin_identity()) && $cf_response["success"])
|
898 |
{
|
899 |
$cfc = array_merge($cfc, array("distros_access_id" => $cf_response["distros_access_id"], "distros_s3_access_id" => $cf_response["distros_s3_access_id"]));
|
900 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distros_access_id" => $cf_response["distros_access_id"], "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => $cf_response["distros_s3_access_id"]);
|
901 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
902 |
-
|
903 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro("downloads")) && $cf_response["success"])
|
904 |
{
|
905 |
$cfc = array_merge($cfc, array("distro_downloads_id" => $cf_response["distro_downloads_id"], "distro_downloads_dname" => $cf_response["distro_downloads_dname"]));
|
906 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => $cf_response["distro_downloads_id"], "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => $cf_response["distro_downloads_dname"]);
|
907 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
908 |
-
|
909 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro("streaming")) && $cf_response["success"])
|
910 |
{
|
911 |
$cfc = array_merge($cfc, array("distro_streaming_id" => $cf_response["distro_streaming_id"], "distro_streaming_dname" => $cf_response["distro_streaming_dname"]));
|
912 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => $cf_response["distro_streaming_id"], "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => $cf_response["distro_streaming_dname"]);
|
913 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
914 |
-
|
915 |
for($a = 1, $attempts = 4, $sleep = 2, sleep($sleep); $a <= $attempts; $a++, (($a <= $attempts) ? sleep($sleep) : null))
|
916 |
/* Allow a generous propagation time here. Amazon's high-availability services do NOT guarantee real-time updates.
|
917 |
Since we DO need a fully propagated Origin Access Identity now, we need to make several attempts at success.
|
@@ -926,65 +940,65 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
926 |
if(isset($s3_response["code"], $s3_response["message"]))
|
927 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
928 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
929 |
-
|
930 |
-
else
|
931 |
return array("success" => false, "code" => -88, "message" => _x("Unable to update existing Amazon® S3 ACLs. Connection failed.", "s2member-admin", "s2member"));
|
932 |
}
|
933 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
934 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
935 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
936 |
-
|
937 |
-
else
|
938 |
return array("success" => false, "code" => -89, "message" => _x("Unable to create Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
939 |
}
|
940 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
941 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
942 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
943 |
-
|
944 |
-
else
|
945 |
return array("success" => false, "code" => -90, "message" => _x("Unable to create Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
946 |
}
|
947 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
948 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
949 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
950 |
-
|
951 |
-
else
|
952 |
return array("success" => false, "code" => -91, "message" => _x("Unable to create Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
953 |
}
|
954 |
-
else
|
955 |
return array("success" => false, "code" => -92, "message" => _x("Unable to clear existing Amazon® CloudFront Origin Access Identity.", "s2member-admin", "s2member"));
|
956 |
}
|
957 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
958 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
959 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
960 |
-
|
961 |
-
else
|
962 |
return array("success" => false, "code" => -93, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
963 |
}
|
964 |
-
else
|
965 |
return array("success" => false, "code" => -94, "message" => _x("Unable to clear existing Amazon® CloudFront Streaming Distro.", "s2member-admin", "s2member"));
|
966 |
}
|
967 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
968 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
969 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
970 |
-
|
971 |
-
else
|
972 |
return array("success" => false, "code" => -95, "message" => _x("Unable to acquire existing Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
973 |
}
|
974 |
-
else
|
975 |
return array("success" => false, "code" => -96, "message" => _x("Unable to clear existing Amazon® CloudFront Downloads Distro.", "s2member-admin", "s2member"));
|
976 |
}
|
977 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
978 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
979 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
980 |
-
|
981 |
-
else
|
982 |
return array("success" => false, "code" => -97, "message" => _x("Unable to acquire existing Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
983 |
}
|
984 |
-
else
|
985 |
return array("success" => false, "code" => -98, "message" => _x("Unable to auto-configure Amazon® CloudFront Distros. Incomplete Amazon® CloudFront configuration options. Missing of one: Amazon® CloudFront Private Key-Pair-ID, or Private Key file contents.", "s2member-admin", "s2member"));
|
986 |
}
|
987 |
-
else
|
988 |
return array("success" => false, "code" => -99, "message" => _x("Unable to auto-configure Amazon® S3/CloudFront Distros. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key. You must provide s2Member with an Amazon® S3 configuration before enabling CloudFront.", "s2member-admin", "s2member"));
|
989 |
}
|
990 |
/**
|
@@ -1004,33 +1018,33 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1004 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1005 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1006 |
$cfc[$option] = $option_value;
|
1007 |
-
|
1008 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1009 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1010 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1011 |
-
|
1012 |
$cf_domain = "cloudfront.amazonaws.com";
|
1013 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1014 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/".$access_id;
|
1015 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1016 |
$cf_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1017 |
-
|
1018 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && (($cf_response["code"] === 404 && $cf_response["message"]) || ($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))))
|
1019 |
{
|
1020 |
if($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1021 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]));
|
1022 |
-
|
1023 |
else /* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1024 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Existing Amazon® CloudFront Origin Access Identity NOT found. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1025 |
}
|
1026 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1027 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1028 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1029 |
-
|
1030 |
-
else
|
1031 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1032 |
}
|
1033 |
-
else
|
1034 |
return array("success" => false, "code" => -99, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Invalid Access ID.", "s2member-admin", "s2member"));
|
1035 |
}
|
1036 |
/**
|
@@ -1052,28 +1066,28 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1052 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1053 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1054 |
$cfc[$option] = $option_value;
|
1055 |
-
|
1056 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1057 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1058 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1059 |
-
|
1060 |
$cf_domain = "cloudfront.amazonaws.com";
|
1061 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1062 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/".$access_id;
|
1063 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1064 |
$cf_args = array("method" => "DELETE", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "If-Match" => $access_id_etag, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1065 |
-
|
1066 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 204 /* Deleted. */))
|
1067 |
return /* Deleted successfully. */ array("success" => true, "code" => null, "message" => null);
|
1068 |
-
|
1069 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1070 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1071 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1072 |
-
|
1073 |
-
else
|
1074 |
return array("success" => false, "code" => -98, "message" => _x("Unable to delete existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1075 |
}
|
1076 |
-
else
|
1077 |
return array("success" => false, "code" => -99, "message" => _x("Unable to delete existing Amazon® CloudFront Origin Access Identity. Invalid Access ID, ETag, or XML config.", "s2member-admin", "s2member"));
|
1078 |
}
|
1079 |
/**
|
@@ -1090,11 +1104,11 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1090 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1091 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1092 |
$cfc[$option] = $option_value;
|
1093 |
-
|
1094 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1095 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1096 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1097 |
-
|
1098 |
$cf_domain = "cloudfront.amazonaws.com";
|
1099 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1100 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront";
|
@@ -1102,20 +1116,20 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1102 |
$cf_distros_access_reference = time().".".md5("access".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"]);
|
1103 |
$cf_distros_access_xml = '<?xml version="1.0" encoding="UTF-8"?><CloudFrontOriginAccessIdentityConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><CallerReference>'.esc_html($cf_distros_access_reference).'</CallerReference><Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment></CloudFrontOriginAccessIdentityConfig>';
|
1104 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distros_access_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1105 |
-
|
1106 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1107 |
{
|
1108 |
if(preg_match("/\<CloudFrontOriginAccessIdentity.*?\>(.+?)\<\/CloudFrontOriginAccessIdentity\>/is", $cf_response["body"], $cf_distros_access_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distros_access_tag[1], $cf_distros_access_id_tag) && preg_match("/\<S3CanonicalUserId\>(.+?)\<\/S3CanonicalUserId\>/is", $cf_distros_access_tag[1], $cf_distros_s3_access_id_tag))
|
1109 |
return array("success" => true, "code" => null, "message" => null, "distros_access_id" => trim($cf_distros_access_id_tag[1]), "distros_s3_access_id" => trim($cf_distros_s3_access_id_tag[1]));
|
1110 |
-
|
1111 |
-
else
|
1112 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create/read Amazon® CloudFront Origin Access Identity. Unexpected response.", "s2member-admin", "s2member"));
|
1113 |
}
|
1114 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1115 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1116 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1117 |
-
|
1118 |
-
else
|
1119 |
return array("success" => false, "code" => -99, "message" => _x("Unable to create Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1120 |
}
|
1121 |
/**
|
@@ -1136,33 +1150,33 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1136 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1137 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1138 |
$cfc[$option] = $option_value;
|
1139 |
-
|
1140 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1141 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1142 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1143 |
-
|
1144 |
$cf_domain = "cloudfront.amazonaws.com";
|
1145 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1146 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1147 |
$cf_location = ($distro_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id : "/2010-11-01/distribution/".$distro_id;
|
1148 |
$cf_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1149 |
-
|
1150 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && (($cf_response["code"] === 404 && $cf_response["message"]) || ($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))))
|
1151 |
{
|
1152 |
if($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1153 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]), "deployed" => ((stripos($cf_response["body"], "<Status>Deployed</Status>") !== false) ? true : false));
|
1154 |
-
|
1155 |
else /* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1156 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Existing Amazon® CloudFront Distro NOT found. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1157 |
}
|
1158 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1159 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1160 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1161 |
-
|
1162 |
-
else
|
1163 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1164 |
}
|
1165 |
-
else
|
1166 |
return array("success" => false, "code" => -99, "message" => _x("Unable to acquire existing Amazon® CloudFront Distro. Invalid Distro ID and/or Distro type.", "s2member-admin", "s2member"));
|
1167 |
}
|
1168 |
/**
|
@@ -1188,35 +1202,35 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1188 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1189 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1190 |
$cfc[$option] = $option_value;
|
1191 |
-
|
1192 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1193 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1194 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1195 |
-
|
1196 |
$cf_domain = "cloudfront.amazonaws.com";
|
1197 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1198 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1199 |
$cf_location = ($distro_id_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id."/config" : "/2010-11-01/distribution/".$distro_id."/config";
|
1200 |
$cf_distro_xml = ($distro_id_type === "streaming") ? '<?xml version="1.0" encoding="UTF-8"?><StreamingDistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName></S3Origin><CallerReference>'.esc_html($distro_id_reference).'</CallerReference><Enabled>false</Enabled><TrustedSigners><Self/></TrustedSigners></StreamingDistributionConfig>' : '<?xml version="1.0" encoding="UTF-8"?><DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName></S3Origin><CallerReference>'.esc_html($distro_id_reference).'</CallerReference><Enabled>false</Enabled><TrustedSigners><Self/></TrustedSigners></DistributionConfig>';
|
1201 |
$cf_args = array("method" => "PUT", "redirection" => 0, "body" => $cf_distro_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "If-Match" => $distro_id_etag, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1202 |
-
|
1203 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && $cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1204 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]), "deployed" => ((stripos($cf_response["body"], "<Status>Deployed</Status>") !== false) ? true : false));
|
1205 |
-
|
1206 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1207 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1208 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to disable existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1209 |
-
|
1210 |
-
else
|
1211 |
return array("success" => false, "code" => -97, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1212 |
}
|
1213 |
-
else
|
1214 |
return array("success" => false, "code" => -98, "message" => _x("Existing Amazon® CloudFront Distro cannot be disabled at this time. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1215 |
}
|
1216 |
-
else
|
1217 |
return array("success" => true, "code" => null, "message" => null, "etag" => $distro_id_etag, "xml" => $distro_id_xml, "deployed" => ((stripos($distro_id_xml, "<Status>Deployed</Status>") !== false) ? true : false));
|
1218 |
}
|
1219 |
-
else
|
1220 |
return array("success" => false, "code" => -99, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Invalid Distro ID, ETag, or XML config.", "s2member-admin", "s2member"));
|
1221 |
}
|
1222 |
/**
|
@@ -1244,49 +1258,49 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1244 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1245 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1246 |
$cfc[$option] = $option_value;
|
1247 |
-
|
1248 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1249 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1250 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1251 |
-
|
1252 |
$cf_domain = "cloudfront.amazonaws.com";
|
1253 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1254 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1255 |
$cf_location = ($distro_id_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id : "/2010-11-01/distribution/".$distro_id;
|
1256 |
$cf_args = array("method" => "DELETE", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "If-Match" => $cf_response["etag"], "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1257 |
-
|
1258 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 204 /* Deleted. */))
|
1259 |
return /* Deleted successfully. */ array("success" => true, "code" => null, "message" => null);
|
1260 |
-
|
1261 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1262 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1263 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1264 |
-
|
1265 |
-
else
|
1266 |
return array("success" => false, "code" => -94, "message" => _x("Unable to delete existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1267 |
}
|
1268 |
else if(isset($cf_response["success"], $cf_response["deployed"]) && $cf_response["success"] && !$cf_response["deployed"])
|
1269 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1270 |
return array("success" => false, "code" => -95, "message" => _x("Existing Amazon® CloudFront Distro cannot be deleted at this time. Still in a `pending` state after having been disabled by s2Member. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1271 |
-
|
1272 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1273 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1274 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to check status of existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1275 |
-
|
1276 |
-
else
|
1277 |
return array("success" => false, "code" => -96, "message" => _x("Unable to check status of existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1278 |
}
|
1279 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1280 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1281 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to disable existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1282 |
-
|
1283 |
-
else
|
1284 |
return array("success" => false, "code" => -97, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1285 |
}
|
1286 |
-
else
|
1287 |
return array("success" => false, "code" => -98, "message" => _x("Existing Amazon® CloudFront Distro cannot be deleted at this time. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1288 |
}
|
1289 |
-
else
|
1290 |
return array("success" => false, "code" => -99, "message" => _x("Unable to delete existing Amazon® CloudFront Distro. Invalid Distro ID or ETag.", "s2member-admin", "s2member"));
|
1291 |
}
|
1292 |
/**
|
@@ -1306,62 +1320,62 @@ if(!class_exists("c_ws_plugin__s2member_files_in"))
|
|
1306 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1307 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1308 |
$cfc[$option] = $option_value;
|
1309 |
-
|
1310 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1311 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1312 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1313 |
-
|
1314 |
$cf_domain = "cloudfront.amazonaws.com";
|
1315 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1316 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1317 |
-
|
1318 |
if /* Create a `downloads` Distro? This uses a different XML schema. */($distro_type === "downloads")
|
1319 |
{
|
1320 |
$cf_location = /* Create distro. */ "/2010-11-01/distribution";
|
1321 |
$cf_distro_downloads_reference = time().".".md5("downloads".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"].$cfc["distro_downloads_cname"]);
|
1322 |
$cf_distro_downloads_xml = '<?xml version="1.0" encoding="UTF-8"?><DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName><OriginAccessIdentity>origin-access-identity/cloudfront/'.esc_html($cfc["distros_access_id"]).'</OriginAccessIdentity></S3Origin><CallerReference>'.esc_html($cf_distro_downloads_reference).'</CallerReference>'.(($cfc["distro_downloads_cname"]) ? '<CNAME>'.esc_html($cfc["distro_downloads_cname"]).'</CNAME>' : '').'<Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment><Enabled>true</Enabled><DefaultRootObject>index.html</DefaultRootObject><TrustedSigners><Self/></TrustedSigners></DistributionConfig>';
|
1323 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distro_downloads_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1324 |
-
|
1325 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1326 |
{
|
1327 |
if(preg_match("/\<Distribution.*?\>(.+?)\<\/Distribution\>/is", $cf_response["body"], $cf_distro_downloads_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distro_downloads_tag[1], $cf_distro_downloads_id_tag) && preg_match("/\<DomainName\>(.+?)\<\/DomainName\>/is", $cf_distro_downloads_tag[1], $cf_distro_downloads_dname_tag))
|
1328 |
return array("success" => true, "code" => null, "message" => null, "distro_downloads_id" => trim($cf_distro_downloads_id_tag[1]), "distro_downloads_dname" => trim($cf_distro_downloads_dname_tag[1]));
|
1329 |
-
|
1330 |
-
else
|
1331 |
return array("success" => false, "code" => -97, "message" => _x("Unable to create/read Amazon® CloudFront Downloads Distro. Unexpected response.", "s2member-admin", "s2member"));
|
1332 |
}
|
1333 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1334 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1335 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1336 |
-
|
1337 |
-
else
|
1338 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
1339 |
}
|
1340 |
-
|
1341 |
else if /* Create a `streaming` Distro? A different XML schema. */($distro_type === "streaming")
|
1342 |
{
|
1343 |
$cf_location = /* Create streaming distro. */ "/2010-11-01/streaming-distribution";
|
1344 |
$cf_distro_streaming_reference = time().".".md5("streaming".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"].$cfc["distro_streaming_cname"]);
|
1345 |
$cf_distro_streaming_xml = '<?xml version="1.0" encoding="UTF-8"?><StreamingDistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName><OriginAccessIdentity>origin-access-identity/cloudfront/'.esc_html($cfc["distros_access_id"]).'</OriginAccessIdentity></S3Origin><CallerReference>'.esc_html($cf_distro_streaming_reference).'</CallerReference>'.(($cfc["distro_streaming_cname"]) ? '<CNAME>'.esc_html($cfc["distro_streaming_cname"]).'</CNAME>' : '').'<Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment><Enabled>true</Enabled><DefaultRootObject>index.html</DefaultRootObject><TrustedSigners><Self/></TrustedSigners></StreamingDistributionConfig>';
|
1346 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distro_streaming_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1347 |
-
|
1348 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1349 |
{
|
1350 |
if(preg_match("/\<StreamingDistribution.*?\>(.+?)\<\/StreamingDistribution\>/is", $cf_response["body"], $cf_distro_streaming_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distro_streaming_tag[1], $cf_distro_streaming_id_tag) && preg_match("/\<DomainName\>(.+?)\<\/DomainName\>/is", $cf_distro_streaming_tag[1], $cf_distro_streaming_dname_tag))
|
1351 |
return array("success" => true, "code" => null, "message" => null, "distro_streaming_id" => trim($cf_distro_streaming_id_tag[1]), "distro_streaming_dname" => trim($cf_distro_streaming_dname_tag[1]));
|
1352 |
-
|
1353 |
-
else
|
1354 |
return array("success" => false, "code" => -97, "message" => _x("Unable to create/read Amazon® CloudFront Streaming Distro. Unexpected response.", "s2member-admin", "s2member"));
|
1355 |
}
|
1356 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1357 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1358 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1359 |
-
|
1360 |
-
else
|
1361 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
1362 |
}
|
1363 |
}
|
1364 |
-
else
|
1365 |
return array("success" => false, "code" => -99, "message" => _x("Unable to create Amazon® CloudFront Distro. Invalid Distro type.", "s2member-admin", "s2member"));
|
1366 |
}
|
1367 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File Download routines for s2Member (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_files_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* File Download routines for s2Member (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\Files
|
26 |
* @since 3.5
|
43 |
*/
|
44 |
public static function check_file_download_access($create_file_download_url = FALSE)
|
45 |
{
|
46 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
47 |
do_action("ws_plugin__s2member_before_file_download_access", get_defined_vars());
|
48 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
49 |
+
|
50 |
$_g = !empty($_GET) ? $_GET : array();
|
51 |
$_g = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_g));
|
52 |
+
|
53 |
$creating = /* Creating URL? */ (is_array($create = $create_file_download_url)) ? true : false;
|
54 |
$serving = /* If NOT creating a File Download URL, we're serving one. */ (!$creating) ? true : false;
|
55 |
$serving_range = $range = /* Default values (so these variables DO get defined at all times). */ false;
|
57 |
{
|
58 |
$range = (string)@$_SERVER["HTTP_RANGE"];
|
59 |
if(!$range && function_exists("apache_request_headers"))
|
60 |
+
// Note: ``apache_request_headers()`` works in FastCGI too, starting w/ PHP v5.4.
|
61 |
foreach((array)apache_request_headers() as $_header => $_value)
|
62 |
if(is_string($_header) && strcasecmp($_header, "range") === 0)
|
63 |
$range = $_value;
|
65 |
$serving_range = true;
|
66 |
unset($_header, $_value);
|
67 |
}
|
68 |
+
|
69 |
$req["file_download"] = ($creating) ? @$create["file_download"] : @$_g["s2member_file_download"];
|
70 |
$req["file_download_key"] = ($creating) ? @$create["file_download_key"] : @$_g["s2member_file_download_key"];
|
71 |
+
|
72 |
$req["file_stream"] = ($creating) ? @$create["file_stream"] : @$_g["s2member_file_stream"];
|
73 |
$req["file_inline"] = ($creating) ? @$create["file_inline"] : @$_g["s2member_file_inline"];
|
74 |
$req["file_storage"] = ($creating) ? @$create["file_storage"] : @$_g["s2member_file_storage"];
|
75 |
$req["file_remote"] = ($creating) ? @$create["file_remote"] : @$_g["s2member_file_remote"];
|
76 |
$req["file_ssl"] = ($creating) ? @$create["file_ssl"] : @$_g["s2member_file_ssl"];
|
77 |
+
|
78 |
$req["file_rewrite"] = ($creating) ? @$create["file_rewrite"] : /* N/A. */ null;
|
79 |
$req["file_rewrite_base"] = ($creating) ? @$create["file_rewrite_base"] : /* N/A. */ null;
|
80 |
+
|
81 |
$req["skip_confirmation"] = ($creating) ? @$create["skip_confirmation"] : /* N/A. */ null;
|
82 |
$req["url_to_storage_source"] = ($creating) ? @$create["url_to_storage_source"] : /* N/A. */ null;
|
83 |
$req["count_against_user"] = ($creating) ? @$create["count_against_user"] : /* N/A. */ null;
|
84 |
$req["check_user"] = ($creating) ? @$create["check_user"] : /* N/A. */ null;
|
85 |
+
|
86 |
if($req["file_download"] && is_string($req["file_download"]) && ($req["file_download"] = trim($req["file_download"], "/")))
|
87 |
if(strpos($req["file_download"], "..") === false && strpos(basename($req["file_download"]), ".") !== 0)
|
88 |
{
|
89 |
$using_amazon_cf_storage = ((!$req["file_storage"] || strcasecmp((string)$req["file_storage"], "cf") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_cf_storage()) ? true : false;
|
90 |
$using_amazon_s3_storage = ((!$req["file_storage"] || strcasecmp((string)$req["file_storage"], "s3") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_s3_storage()) ? true : false;
|
91 |
$using_amazon_storage = /* Either? */ ($using_amazon_cf_storage || $using_amazon_s3_storage) ? true : false;
|
92 |
+
|
93 |
$excluded = apply_filters("ws_plugin__s2member_check_file_download_access_excluded", false, get_defined_vars());
|
94 |
$valid_file_download_key = ($req["file_download_key"] && is_string($req["file_download_key"]) && $creating && (!isset($req["check_user"]) || !filter_var($req["check_user"], FILTER_VALIDATE_BOOLEAN)) && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN))) ? true : false;
|
95 |
$valid_file_download_key = (!$valid_file_download_key && $req["file_download_key"] && is_string($req["file_download_key"])) ? c_ws_plugin__s2member_files_in::check_file_download_key($req["file_download"], $req["file_download_key"]) : false;
|
96 |
$checking_user = ($excluded || $valid_file_download_key || ($creating && (!isset($req["check_user"]) || !filter_var($req["check_user"], FILTER_VALIDATE_BOOLEAN)) && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
|
97 |
$updating_user_counter = ($serving_range || !$checking_user || ($creating && (!isset($req["count_against_user"]) || !filter_var($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
|
98 |
+
|
99 |
if( /* In either case, the following routines apply whenever we ARE ``$checking_user``. */($serving || $creating) && $checking_user)
|
100 |
{
|
101 |
if(!$using_amazon_storage && !file_exists($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"]))
|
102 |
{
|
103 |
if /* We only need this section when/if we're actually serving. */($serving)
|
104 |
+
{
|
105 |
+
status_header(404);
|
106 |
+
header("Content-Type: text/html; charset=UTF-8");
|
107 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
108 |
+
exit(_x('<strong>404: Sorry, file not found.</strong> Please contact Support for assistance.', "s2member-front", "s2member"));
|
109 |
+
}
|
110 |
+
else // Else return false.
|
111 |
return false;
|
112 |
}
|
113 |
+
|
114 |
else if($req["file_download_key"] && is_string($req["file_download_key"]) && !$valid_file_download_key)
|
115 |
{
|
116 |
if /* We only need this section when/if we're actually serving. */($serving)
|
117 |
+
{
|
118 |
+
status_header(503);
|
119 |
+
header("Content-Type: text/html; charset=UTF-8");
|
120 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
121 |
+
exit(_x('<strong>503 (Invalid Key):</strong> Sorry, your access to this file has expired. Please contact Support for assistance.', "s2member-front", "s2member"));
|
122 |
+
}
|
123 |
+
else // Else return false.
|
124 |
return false;
|
125 |
}
|
126 |
+
|
127 |
else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads()) === false)
|
128 |
{
|
129 |
if /* We only need remote functionality when/if we're actually serving. */($serving)
|
130 |
if(!has_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
|
131 |
add_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
|
132 |
+
|
133 |
if /* We only need remote functionality when/if we're actually serving. */($creating)
|
134 |
if(has_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
|
135 |
remove_filter("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
|
136 |
+
|
137 |
if((isset($file_downloads_enabled_by_site_owner, $min_level_4_downloads) && $file_downloads_enabled_by_site_owner === false) || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads()) === false)
|
138 |
{
|
139 |
if /* We only need this section when/if we're actually serving. */($serving)
|
140 |
+
{
|
141 |
+
status_header(503);
|
142 |
+
header("Content-Type: text/html; charset=UTF-8");
|
143 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
144 |
+
exit(_x('<strong>503: Basic File Downloads are NOT enabled yet.</strong> Please contact Support for assistance. If you are the site owner, please configure: <code>s2Member -› Download Options -› Basic Download Restrictions</code>.', "s2member-front", "s2member"));
|
145 |
+
}
|
146 |
+
else // Else return false.
|
147 |
return false;
|
148 |
}
|
149 |
+
|
150 |
else if(!is_object($user = apply_filters("ws_plugin__s2member_check_file_download_access_user", ((is_user_logged_in()) ? wp_get_current_user() : false), get_defined_vars())) || empty($user->ID) || !($user_id = $user->ID) || !is_array($user_file_downloads = c_ws_plugin__s2member_files::user_downloads($user)) || (!$user->has_cap("administrator") && (!$user_file_downloads["allowed"] || !$user_file_downloads["allowed_days"])))
|
151 |
{
|
152 |
if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen($req_level = $m[1]) && (!is_object($user) || empty($user->ID) || !$user->has_cap("access_s2member_level".$req_level)))
|
153 |
{
|
154 |
if /* We only need this section when/if we're actually serving. */($serving)
|
155 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]).exit();
|
156 |
+
|
157 |
+
else // Else return false.
|
158 |
return false;
|
159 |
}
|
160 |
+
|
161 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen($req_ccap = preg_replace("/-/", "_", $m[1])) && (!is_object($user) || empty($user->ID) || !$user->has_cap("access_s2member_ccap_".$req_ccap)))
|
162 |
{
|
163 |
if /* We only need this section when/if we're actually serving. */($serving)
|
164 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]).exit();
|
165 |
+
|
166 |
+
else // Else return false.
|
167 |
return false;
|
168 |
}
|
169 |
+
|
170 |
else if /* We only need this section when/if we're actually serving. */($serving)
|
171 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $min_level_4_downloads, $_SERVER["REQUEST_URI"]).exit();
|
172 |
+
|
173 |
+
else // Else return false.
|
174 |
return false;
|
175 |
}
|
176 |
+
|
177 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen($req_level = $m[1]) && !$user->has_cap("access_s2member_level".$req_level))
|
178 |
{
|
179 |
if /* We only need this section when/if we're actually serving. */($serving)
|
180 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]).exit();
|
181 |
+
|
182 |
+
else // Else return false.
|
183 |
return false;
|
184 |
}
|
185 |
+
|
186 |
else if(preg_match("/(?:^|\/)access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen($req_ccap = preg_replace("/-/", "_", $m[1])) && !$user->has_cap("access_s2member_ccap_".$req_ccap))
|
187 |
{
|
188 |
if /* We only need this section when/if we're actually serving. */($serving)
|
189 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]).exit();
|
190 |
+
|
191 |
+
else // Else return false.
|
192 |
return false;
|
193 |
}
|
194 |
+
|
195 |
else if /* In either case, the following routines apply. */($serving || $creating)
|
196 |
{
|
197 |
$user_previous_file_downloads = /* Downloads the User has already; in current period/cycle. */ 0;
|
198 |
$user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = false;
|
199 |
+
|
200 |
$user_file_download_access_log = (is_array($user_file_download_access_log = get_user_option("s2member_file_download_access_log", $user_id))) ? $user_file_download_access_log : array();
|
201 |
$user_file_download_access_arc = (is_array($user_file_download_access_arc = get_user_option("s2member_file_download_access_arc", $user_id))) ? $user_file_download_access_arc : array();
|
202 |
+
|
203 |
$streaming_file_extns = c_ws_plugin__s2member_utils_strings::preg_quote_deep($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["streaming_file_extns"], "/");
|
204 |
$streaming_variations = /* Only count one streaming media file variation. */ "/\.(".implode("|", $streaming_file_extns).")$/i";
|
205 |
+
|
206 |
foreach($user_file_download_access_log as $user_file_download_access_log_entry_key => $user_file_download_access_log_entry)
|
207 |
{
|
208 |
if( /* Weed out corrupt/empty log entries. */isset($user_file_download_access_log_entry["date"], $user_file_download_access_log_entry["file"]))
|
214 |
}
|
215 |
else if(strtotime($user_file_download_access_log_entry["date"]) >= strtotime("-".$user_file_downloads["allowed_days"]." days"))
|
216 |
{
|
217 |
+
$user_previous_file_downloads++; // Previous files always count against this User/Member.
|
218 |
+
|
219 |
$_user_file_download_access_log_entry = &$user_file_download_access_log[$user_file_download_access_log_entry_key];
|
220 |
$_user_already_downloaded_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = false;
|
221 |
+
|
222 |
if /* Already downloaded this file? If yes, mark this flag as true. */($user_file_download_access_log_entry["file"] === $req["file_download"])
|
223 |
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = /* Already downloaded this file? If yes, mark as true. */ true;
|
224 |
+
|
225 |
else if(preg_replace($streaming_variations, "", $user_file_download_access_log_entry["file"]) === preg_replace($streaming_variations, "", $req["file_download"]))
|
226 |
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = true;
|
227 |
+
|
228 |
if( /* Updating counter? */$updating_user_counter && ($_user_already_downloaded_this_file || $_user_already_downloaded_a_streaming_variation_of_this_file))
|
229 |
{
|
230 |
$_user_file_download_access_log_entry /* First, we update the last download time for this file. */["ltime"] = time();
|
231 |
+
|
232 |
+
if( /* Backward compatibility here. Is this even set? */!empty($user_file_download_access_log_entry["counter"]))
|
233 |
$_user_file_download_access_log_entry["counter"] = (int)$user_file_download_access_log_entry["counter"] + 1;
|
234 |
+
else // Backward compatibility here. Default value to `1`, if this is NOT even set yet.
|
235 |
$_user_file_download_access_log_entry["counter"] = 1 + 1;
|
236 |
}
|
237 |
}
|
238 |
}
|
239 |
+
else // Weed out empty log entries. Some older versions of s2Member may have corrupt/empty log entries.
|
240 |
+
unset /* Remove. */($user_file_download_access_log[$user_file_download_access_log_entry_key]);
|
241 |
}
|
242 |
if( /* Updating counter? */$updating_user_counter && /* Do we need a new log entry for this file? */ !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file)
|
243 |
$user_file_download_access_log[] = array("date" => date("Y-m-d"), "time" => time(), "ltime" => time(), "file" => $req["file_download"], "counter" => 1);
|
244 |
+
|
245 |
if($user_previous_file_downloads >= $user_file_downloads["allowed"] && !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file && !$user->has_cap("administrator"))
|
246 |
{
|
247 |
if /* We only need this section when/if we're actually serving. */($serving)
|
248 |
wp_redirect(add_query_arg(urlencode_deep(array("_s2member_seeking" => array("type" => "file", "file" => $req["file_download"], "_uri" => base64_encode($_SERVER["REQUEST_URI"])), "s2member_seeking" => "file-".$req["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())).exit();
|
249 |
+
|
250 |
+
else // Else return false.
|
251 |
return false;
|
252 |
}
|
253 |
else if /* Save/update counter? By default, we do NOT update the counter when a URL is simply being created for access. */($updating_user_counter)
|
255 |
}
|
256 |
}
|
257 |
}
|
258 |
+
else // Otherwise, we're either NOT ``$checking_user``; or permission was granted with a valid File Download Key.
|
259 |
{
|
260 |
if(!$using_amazon_storage && !file_exists($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"]))
|
261 |
{
|
262 |
if /* We only need this section when/if we're actually serving. */($serving)
|
263 |
+
{
|
264 |
+
status_header(404);
|
265 |
+
header("Content-Type: text/html; charset=UTF-8");
|
266 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
267 |
+
exit(_x('<strong>404: Sorry, file not found.</strong> Please contact Support for assistance.', "s2member-front", "s2member"));
|
268 |
+
}
|
269 |
+
else // Else return false.
|
270 |
return false;
|
271 |
}
|
272 |
}
|
273 |
+
|
274 |
if /* In either case, the following routines apply. */($serving || $creating)
|
275 |
{
|
276 |
$basename = basename($req["file_download"]);
|
277 |
$mimetypes = parse_ini_file(dirname(dirname(dirname(__FILE__)))."/includes/mime-types.ini");
|
278 |
$extension = strtolower(substr($req["file_download"], strrpos($req["file_download"], ".") + 1));
|
279 |
+
|
280 |
$key = ($req["file_download_key"] && is_string($req["file_download_key"])) ? $req["file_download_key"] : false;
|
281 |
+
|
282 |
$stream = (isset($req["file_stream"])) ? filter_var($req["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
|
283 |
$inline = (!$stream && isset($req["file_inline"])) ? filter_var($req["file_inline"], FILTER_VALIDATE_BOOLEAN) : (($stream || in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]))) ? true : false);
|
284 |
$ssl = (isset($req["file_ssl"])) ? filter_var($req["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl()) ? true : false);
|
285 |
$storage = ($req["file_storage"] && is_string($req["file_storage"])) ? strtolower($req["file_storage"]) : false;
|
286 |
$remote = (isset($req["file_remote"])) ? filter_var($req["file_remote"], FILTER_VALIDATE_BOOLEAN) : false;
|
287 |
+
|
288 |
$_basename_dir_app_data = c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]);
|
289 |
$rewrite_base_guess = (is_dir(dirname($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir"])."/".$_basename_dir_app_data)) ? dirname($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"])."/".$_basename_dir_app_data : content_url("/".$_basename_dir_app_data);
|
290 |
$rewrite_base = ($req["file_rewrite_base"] && is_string($req["file_rewrite_base"])) ? $req["file_rewrite_base"] : false;
|
291 |
$rewrite = $rewriting = (!$rewrite_base && isset($req["file_rewrite"])) ? filter_var($req["file_rewrite"], FILTER_VALIDATE_BOOLEAN) : (($rewrite_base) ? true : false);
|
292 |
unset /* A little housekeeping here. */($_basename_dir_app_data);
|
293 |
+
|
294 |
$skip_confirmation = (isset($req["skip_confirmation"])) ? filter_var($req["skip_confirmation"], FILTER_VALIDATE_BOOLEAN) : false;
|
295 |
$url_to_storage_source = (isset($req["url_to_storage_source"])) ? filter_var($req["url_to_storage_source"], FILTER_VALIDATE_BOOLEAN) : false;
|
296 |
+
|
297 |
$pathinfo = (!$using_amazon_storage) ? pathinfo(($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/".$req["file_download"])) : array();
|
298 |
$mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream";
|
299 |
$disposition = (($inline) ? "inline" : "attachment")."; filename=\"".c_ws_plugin__s2member_utils_strings::esc_dq($basename)."\"; filename*=UTF-8''".rawurlencode($basename);
|
300 |
$length = (!$using_amazon_storage && $file) ? filesize($file) : -1;
|
301 |
+
|
302 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
303 |
do_action("ws_plugin__s2member_during_file_download_access", get_defined_vars());
|
304 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
305 |
+
|
306 |
if($using_amazon_storage && $using_amazon_cf_storage && ($serving || ($creating && $url_to_storage_source)))
|
307 |
{
|
308 |
if /* We only need this section when/if we're actually serving. */($serving)
|
309 |
wp_redirect(c_ws_plugin__s2member_files_in::amazon_cf_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)).exit();
|
310 |
+
|
311 |
+
else // Else return File Download URL.
|
312 |
return apply_filters("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_cf_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars());
|
313 |
}
|
314 |
+
|
315 |
else if($using_amazon_storage && $using_amazon_s3_storage && ($serving || ($creating && $url_to_storage_source)))
|
316 |
{
|
317 |
if /* We only need this section when/if we're actually serving. */($serving)
|
318 |
wp_redirect(c_ws_plugin__s2member_files_in::amazon_s3_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)).exit();
|
319 |
+
|
320 |
+
else // Else return File Download URL.
|
321 |
return apply_filters("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_s3_url($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars());
|
322 |
}
|
323 |
+
|
324 |
else if /* Creating a rewrite URL, pointing to local storage. */($creating && $rewriting)
|
325 |
+
{ // Note: we don't URL encode unreserved chars. Improves media player compatibility.
|
326 |
$_url_e_key = ($key) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($key)) : "";
|
327 |
$_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($storage)) : "";
|
328 |
$_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($req["file_download"]));
|
329 |
+
|
330 |
$url = ($rewrite_base) ? rtrim($rewrite_base, "/") : rtrim($rewrite_base_guess, "/");
|
331 |
$url .= (isset($req["file_download_key"])) ? (($key && $_url_e_key) ? "/s2member-file-download-key-".$_url_e_key : "") : "";
|
332 |
$url .= (isset($req["file_stream"])) ? (($stream) ? "/s2member-file-stream" : "/s2member-file-stream-no") : "";
|
334 |
$url .= (isset($req["file_storage"])) ? (($storage && $_url_e_storage) ? "/s2member-file-storage-".$_url_e_storage : "") : "";
|
335 |
$url .= (isset($req["file_remote"])) ? (($remote) ? "/s2member-file-remote" : "/s2member-file-remote-no") : "";
|
336 |
$url .= (isset($req["skip_confirmation"])) ? (($skip_confirmation) ? "/s2member-skip-confirmation" : "/s2member-skip-confirmation-no") : "";
|
337 |
+
|
338 |
$url = /* File Download Access URL via `mod_rewrite` functionality. */ $url."/".$_url_e_file;
|
339 |
$url = ($ssl) ? preg_replace("/^https?/", "https", $url) : preg_replace("/^https?/", "http", $url);
|
340 |
+
|
341 |
return apply_filters("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars());
|
342 |
}
|
343 |
+
|
344 |
else if /* Else we're creating a URL w/ a query-string; w/ local storage. */($creating)
|
345 |
+
{ // Note: we don't URL encode unreserved chars. Improves media player compatibility.
|
346 |
$_url_e_key = ($key) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($key)) : "";
|
347 |
$_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($storage)) : "";
|
348 |
$_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($req["file_download"]));
|
349 |
+
|
350 |
$url = (isset($req["file_download_key"])) ? (($key && $_url_e_key) ? "&s2member_file_download_key=".$_url_e_key : "") : "";
|
351 |
$url .= (isset($req["file_stream"])) ? (($stream) ? "&s2member_file_stream=yes" : "&s2member_file_stream=no") : "";
|
352 |
$url .= (isset($req["file_inline"])) ? (($inline) ? "&s2member_file_inline=yes" : "&s2member_file_inline=no") : "";
|
353 |
$url .= (isset($req["file_storage"])) ? (($storage && $_url_e_storage) ? "&s2member_file_storage=".$_url_e_storage : "") : "";
|
354 |
$url .= (isset($req["file_remote"])) ? (($remote) ? "&s2member_file_remote=yes" : "&s2member_file_remote=no") : "";
|
355 |
$url .= (isset($req["skip_confirmation"])) ? (($skip_confirmation) ? "&s2member_skip_confirmation=yes" : "&s2member_skip_confirmation=no") : "";
|
356 |
+
|
357 |
$url = site_url("/?".ltrim($url."&s2member_file_download=/".$_url_e_file, "&"));
|
358 |
$url = ($ssl) ? preg_replace("/^https?/", "https", $url) : preg_replace("/^https?/", "http", $url);
|
359 |
+
|
360 |
return apply_filters("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars());
|
361 |
}
|
362 |
+
|
363 |
else if /* Else, ``if ($serving)``, use local storage. */($serving)
|
364 |
{
|
365 |
@set_time_limit(0);
|
366 |
+
|
367 |
@ini_set("zlib.output_compression", 0);
|
368 |
if(function_exists("apache_setenv"))
|
369 |
@apache_setenv("no-gzip", "1");
|
370 |
+
|
371 |
while /* Cleans existing output buffers. */(@ob_end_clean());
|
372 |
+
|
373 |
if /* Requesting a specific byte range? */($range)
|
374 |
{
|
375 |
if /* Invalid range? */(strpos($range, "=") === FALSE)
|
384 |
exit /* Stop here (invalid). */();
|
385 |
}
|
386 |
list($range_type, $byte_range) = preg_split("/\s*\=\s*/", $range, 2);
|
387 |
+
|
388 |
$range_type = strtolower(trim($range_type));
|
389 |
$byte_range = trim($byte_range);
|
390 |
+
|
391 |
if /* Invalid range type? */($range_type !== "bytes")
|
392 |
{
|
393 |
status_header(416);
|
400 |
exit /* Stop here (invalid). */();
|
401 |
}
|
402 |
$byte_ranges = preg_split("/\s*,\s*/", $byte_range);
|
403 |
+
|
404 |
if /* Invalid byte range? */(strpos($byte_ranges[0], "-") === FALSE)
|
405 |
{
|
406 |
status_header(416);
|
412 |
header("Content-Disposition: ".$disposition);
|
413 |
exit /* Stop here (invalid). */();
|
414 |
}
|
415 |
+
|
416 |
+
// Only dealing with the first byte range. Others are simply ignored here.
|
417 |
list($byte_range_start, $byte_range_stops) = preg_split("/\s*\-\s*/", $byte_ranges[0], 2);
|
418 |
+
|
419 |
$byte_range_start = trim($byte_range_start);
|
420 |
$byte_range_stops = trim($byte_range_stops);
|
421 |
+
|
422 |
$byte_range_start = ($byte_range_start === "") ? NULL : (integer)$byte_range_start;
|
423 |
$byte_range_stops = ($byte_range_stops === "") ? NULL : (integer)$byte_range_stops;
|
424 |
+
|
425 |
if(!isset($byte_range_start) && $byte_range_stops > 0 && $byte_range_stops <= $length)
|
426 |
{
|
427 |
$byte_range_start = $length - $byte_range_stops;
|
432 |
$byte_range_stops = /* To the end of the file in this case. */ $length - 1;
|
433 |
}
|
434 |
else if(isset($byte_range_start, $byte_range_stops) && $byte_range_start >= 0 && $byte_range_start < $length - 1 && $byte_range_stops > $byte_range_start && $byte_range_stops <= $length - 1) {
|
435 |
+
// Nothing to do in this case, starts/stops already defined properly.
|
436 |
}
|
437 |
+
else // We have an invalid byte range.
|
438 |
{
|
439 |
status_header(416);
|
440 |
nocache_headers();
|
445 |
header("Content-Disposition: ".$disposition);
|
446 |
exit /* Stop here (invalid). */();
|
447 |
}
|
448 |
+
// Range.
|
449 |
status_header(206);
|
450 |
nocache_headers();
|
451 |
header("Content-Encoding:");
|
456 |
header("Content-Length: ".$byte_range_size);
|
457 |
header("Content-Disposition: ".$disposition);
|
458 |
}
|
459 |
+
else // A normal request (NOT a specific byte range).
|
460 |
{
|
461 |
status_header(200);
|
462 |
nocache_headers();
|
473 |
$_bytes_to_read = $byte_range_size;
|
474 |
fseek($resource, $byte_range_start);
|
475 |
}
|
476 |
+
else // Entire file.
|
477 |
$_bytes_to_read = $length;
|
478 |
+
|
479 |
$chunk_size = apply_filters("ws_plugin__s2member_file_downloads_chunk_size", 2097152, get_defined_vars());
|
480 |
+
|
481 |
while /* We have bytes to read here. */($_bytes_to_read)
|
482 |
{
|
483 |
$_bytes_to_read -= ($_reading = ($_bytes_to_read > $chunk_size) ? $chunk_size : $_bytes_to_read);
|
491 |
}
|
492 |
}
|
493 |
}
|
494 |
+
|
495 |
else if /* We only need this section when/if we're actually serving. */($serving && $req["file_download"])
|
496 |
+
{
|
497 |
+
status_header(503);
|
498 |
+
header("Content-Type: text/html; charset=UTF-8");
|
499 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
500 |
+
exit(_x('<strong>503: Access denied.</strong> Invalid File Download specs.', "s2member-front", "s2member"));
|
501 |
+
}
|
502 |
else if /* We only need this section when/if we're creating a URL. */($creating)
|
503 |
return false;
|
504 |
+
|
505 |
do_action("ws_plugin__s2member_after_file_download_access", get_defined_vars());
|
506 |
+
|
507 |
return ($creating) ? /* If creating, false. */ false : null;
|
508 |
}
|
509 |
/**
|
514 |
*
|
515 |
* @param array $config Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine.
|
516 |
* Possible ``$config`` array elements: `file_download` *(required)*, `file_download_key`, `file_stream`, `file_inline`, `file_storage`, `file_remote`, `file_ssl`, `file_rewrite`, `file_rewrite_base`, `skip_confirmation`, `url_to_storage_source`, `count_against_user`, `check_user`.
|
517 |
+
* @param bool $get_streamer_array Optional. Defaults to `false`. If `true`, this function will return an array with the following elements: `streamer`, `file`, `url`. For further details, please review this section in your Dashboard: `s2Member -› Download Options -› JW Player® & RTMP Protocol Examples`.
|
518 |
* @return str A File Download URL string on success; or an array on success, with elements `streamer`, `file`, `url` when/if ``$get_streamer_array`` is true; else false on any type of failure.
|
519 |
*
|
520 |
* @see s2Member\API_Functions\s2member_file_download_url()
|
521 |
*/
|
522 |
public static function create_file_download_url($config = FALSE, $get_streamer_array = FALSE)
|
523 |
{
|
524 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
525 |
do_action("ws_plugin__s2member_before_create_file_download_url", get_defined_vars());
|
526 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
527 |
+
|
528 |
$config = (is_array($config)) ? $config : /* This absolutely MUST be an array. */ array();
|
529 |
+
|
530 |
$config["file_download"] = (isset($config["file_download"]) && is_string($config["file_download"])) ? trim($config["file_download"], "/") : @$config["file_download"];
|
531 |
$config["file_download_key"] = (isset($config["file_download"]) && is_string($config["file_download"]) && !empty($config["file_download_key"])) ? c_ws_plugin__s2member_files::file_download_key($config["file_download"], ((in_array($config["file_download_key"], array("ip-forever", "universal", "cache-compatible"))) ? $config["file_download_key"] : false)) : @$config["file_download_key"];
|
532 |
+
|
533 |
$config["url_to_storage_source"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["url_to_storage_source"];
|
534 |
$config["file_stream"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["file_stream"];
|
535 |
+
|
536 |
if(($_url = c_ws_plugin__s2member_files_in::check_file_download_access /* Successfully created a URL to the file? */(($create_file_download_url = $config))))
|
537 |
{
|
538 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
539 |
do_action("ws_plugin__s2member_during_create_file_download_url", get_defined_vars());
|
540 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
541 |
+
|
542 |
$extension = strtolower(substr($config["file_download"], strrpos($config["file_download"], ".") + 1));
|
543 |
$streaming = (isset($config["file_stream"])) ? filter_var($config["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array($extension, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
|
544 |
$ssl = (isset($config["file_ssl"])) ? filter_var($config["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl()) ? true : false);
|
545 |
+
|
546 |
if($get_streamer_array && $streaming && ($cfx = "/cfx/st") && ($cfx_pos = strpos($_url, $cfx)) !== false && ($streamer = substr($_url, 0, $cfx_pos + strlen($cfx))) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
|
547 |
$return = array("streamer" => $streamer, "prefix" => $extension.":", "file" => preg_replace("/^".preg_quote($streamer, "/")."\//", "", $_url), "url" => preg_replace("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
|
548 |
+
|
549 |
else if($get_streamer_array && $streaming && is_array($ups = c_ws_plugin__s2member_utils_urls::parse_url($_url)) && isset($ups["scheme"], $ups["host"]) && ($streamer = $ups["scheme"]."://".$ups["host"].((!empty($ups["port"])) ? ":".$ups["port"] : "")) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access(array_merge($config, array("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
|
550 |
$return = array("streamer" => $streamer, "prefix" => $extension.":", "file" => preg_replace("/^".preg_quote($streamer, "/")."\//", "", $_url), "url" => preg_replace("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
|
551 |
+
|
552 |
else if /* If streamer, we MUST return false here; unable to acquire streamer/file. */($get_streamer_array)
|
553 |
$return = /* We MUST return false here, unable to acquire streamer/file. */ false;
|
554 |
+
|
555 |
+
else // Else return URL string ( ``$get_streamer_array`` is false ).
|
556 |
$return = /* Else return URL string. */ $_url;
|
557 |
}
|
558 |
+
|
559 |
return apply_filters("ws_plugin__s2member_create_file_download_url", ((isset($return)) ? $return : false), get_defined_vars());
|
560 |
}
|
561 |
/**
|
571 |
*/
|
572 |
public static function check_file_remote_authorization($user = FALSE)
|
573 |
{
|
574 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
575 |
do_action("ws_plugin__s2member_before_check_file_remote_authorization", get_defined_vars());
|
576 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
577 |
+
|
578 |
$_g = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep(((!empty($_GET)) ? $_GET : array())));
|
579 |
+
|
580 |
if(!is_object($user) && isset($_g["s2member_file_remote"]) && filter_var($_g["s2member_file_remote"], FILTER_VALIDATE_BOOLEAN))
|
581 |
{
|
582 |
do_action("ws_plugin__s2member_during_check_file_remote_authorization_before", get_defined_vars());
|
583 |
+
|
584 |
if(empty($_SERVER["PHP_AUTH_USER"]) || empty($_SERVER["PHP_AUTH_PW"]) || !user_pass_ok($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
|
585 |
{
|
586 |
header('WWW-Authenticate: Basic realm="'.c_ws_plugin__s2member_utils_strings::esc_dq(strip_tags(_x("Members Only", "s2member-front", "s2member"))).'"');
|
587 |
+
|
588 |
status_header /* Send an unauthorized 401 status header now. */(401);
|
589 |
+
header /* Content-Type with UTF-8. */("Content-Type: text/html; charset=UTF-8");
|
590 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
591 |
+
|
592 |
exit(_x('<strong>401:</strong> Sorry, access denied.', "s2member-front", "s2member"));
|
593 |
}
|
594 |
else if(is_object($_user = new WP_User($_SERVER["PHP_AUTH_USER"])) && !empty($_user->ID))
|
595 |
$user = /* Now assign ``$user``. */ $_user;
|
596 |
+
|
597 |
do_action("ws_plugin__s2member_during_check_file_remote_authorization_after", get_defined_vars());
|
598 |
}
|
599 |
return apply_filters("ws_plugin__s2member_check_file_remote_authorization", $user, get_defined_vars());
|
610 |
*/
|
611 |
public static function check_file_download_key($file = FALSE, $key = FALSE)
|
612 |
{
|
613 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
614 |
do_action("_ws_plugin__s2member_before_check_file_download_key", get_defined_vars());
|
615 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
616 |
+
|
617 |
if($file && is_string($file) && ($file = trim($file, "/")) && $key && is_string($key))
|
618 |
{
|
619 |
if($key === c_ws_plugin__s2member_files::file_download_key($file) || $key === c_ws_plugin__s2member_files::file_download_key("/".$file))
|
637 |
public static function amazon_s3_sign($string = FALSE)
|
638 |
{
|
639 |
$s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
640 |
+
|
641 |
return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign((string)$string, $s3c["secret_key"]);
|
642 |
}
|
643 |
/**
|
658 |
{
|
659 |
$file = /* Trim / force string. */ trim((string)$file, "/");
|
660 |
$url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($file));
|
661 |
+
|
662 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
663 |
if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
|
664 |
$s3c[$option] = $option_value;
|
665 |
+
|
666 |
$s3c["expires"] = strtotime("+".apply_filters("ws_plugin__s2member_amazon_s3_file_expires_time", "24 hours", get_defined_vars()));
|
667 |
+
|
668 |
$s3_file = add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode_deep(array("response-cache-control" => ($s3_cache_control = "no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"), "response-content-disposition" => ($s3_content_disposition = (((bool)$inline) ? "inline" : "attachment").'; filename="'.(string)$basename.'"'), "response-content-type" => ($s3_content_type = (string)$mimetype), "response-expires" => ($s3_expires = gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT")))), "/".$url_e_file);
|
669 |
$s3_raw_file = add_query_arg(array("response-cache-control" => $s3_cache_control, "response-content-disposition" => $s3_content_disposition, "response-content-type" => $s3_content_type, "response-expires" => $s3_expires), "/".$url_e_file);
|
670 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("GET\n\n\n".$s3c["expires"]."\n"."/".$s3c["bucket"].$s3_raw_file));
|
671 |
+
|
672 |
$s3_url = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "http".(($ssl) ? "s" : "")."://s3.amazonaws.com/".$s3c["bucket"].$s3_file : "http".(($ssl) ? "s" : "")."://".$s3c["bucket"].".s3.amazonaws.com".$s3_file;
|
673 |
+
|
674 |
return add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode_deep(array("AWSAccessKeyId" => $s3c["access_key"], "Expires" => $s3c["expires"], "Signature" => $s3_signature))), $s3_url);
|
675 |
}
|
676 |
/**
|
687 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
688 |
if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
|
689 |
$s3c[$option] = $option_value;
|
690 |
+
|
691 |
$cfc["distros_s3_access_id"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_s3_access_id"];
|
692 |
+
|
693 |
if /* Must have Amazon® S3 Bucket/Keys. */($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
|
694 |
{
|
695 |
$s3_date = gmdate("D, d M Y H:i:s")." GMT";
|
697 |
$s3_domain = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "s3.amazonaws.com" : $s3c["bucket"].".s3.amazonaws.com";
|
698 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("GET\n\n\n".$s3_date."\n/".$s3c["bucket"]."/?acl"));
|
699 |
$s3_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $s3_domain, "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
700 |
+
|
701 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
702 |
{
|
703 |
if(preg_match("/\<Owner\>(.+?)\<\/Owner\>/is", $s3_response["body"], $s3_owner_tag) && preg_match("/\<ID\>(.+?)\<\/ID\>/is", $s3_owner_tag[1], $s3_owner_id_tag) && (preg_match("/\<DisplayName\>(.*?)\<\/DisplayName\>/is", $s3_owner_tag[1], $s3_owner_display_name_tag) || ($s3_owner_display_name_tag = array("-", "Owner"))))
|
706 |
$s3_acls_xml = '<AccessControlPolicy><Owner><ID>'.esc_html($s3_owner["access_id"]).'</ID><DisplayName>'.esc_html($s3_owner["display_name"]).'</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>'.esc_html($s3_owner["access_id"]).'</ID><DisplayName>'.esc_html($s3_owner["display_name"]).'</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant>'.(($cfc["distros_s3_access_id"]) ? '<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>'.esc_html($cfc["distros_s3_access_id"]).'</ID><DisplayName>s2Member/CloudFront</DisplayName></Grantee><Permission>READ</Permission></Grant>' : '').'</AccessControlList></AccessControlPolicy>';
|
707 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\napplication/xml\n".$s3_date."\n/".$s3c["bucket"]."/?acl"));
|
708 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_acls_xml, "headers" => array("Host" => $s3_domain, "Content-Type" => "application/xml", "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
709 |
+
|
710 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
711 |
{
|
712 |
$s3_location = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "/".$s3c["bucket"]."/?policy" : "/?policy";
|
714 |
$s3_policy_json = '{"Version":"2008-10-17","Id":"'.c_ws_plugin__s2member_utils_strings::esc_dq($s3_policy_id).'","Statement":[{"Sid":"'.c_ws_plugin__s2member_utils_strings::esc_dq($s3_policy_sid).'","Effect":"Allow","Principal":{"CanonicalUser":"'.c_ws_plugin__s2member_utils_strings::esc_dq($cfc["distros_s3_access_id"]).'"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::'.c_ws_plugin__s2member_utils_strings::esc_dq($s3c["bucket"]).'/*"}]}';
|
715 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\napplication/json\n".$s3_date."\n/".$s3c["bucket"]."/?policy"));
|
716 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_policy_json, "headers" => array("Host" => $s3_domain, "Content-Type" => "application/json", "Date" => $s3_date, "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
717 |
+
|
718 |
if(!$cfc["distros_s3_access_id"] || (($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && ($s3_response["code"] === 200 || $s3_response["code"] === 204 /* Also OK. */)))
|
719 |
{
|
720 |
$s3_location = ((strtolower($s3c["bucket"]) !== $s3c["bucket"])) ? "/".$s3c["bucket"]."/crossdomain.xml" : "/crossdomain.xml";
|
721 |
$s3_policy_xml = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__))."/templates/cfg-files/s2-cross-xml.php")));
|
722 |
$s3_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_s3_sign("PUT\n\ntext/xml\n".$s3_date."\nx-amz-acl:public-read\n/".$s3c["bucket"]."/crossdomain.xml"));
|
723 |
$s3_args = array("method" => "PUT", "redirection" => 0, "body" => $s3_policy_xml, "headers" => array("Host" => $s3_domain, "Content-Type" => "text/xml", "Date" => $s3_date, "X-Amz-Acl" => "public-read", "Authorization" => "AWS ".$s3c["access_key"].":".$s3_signature));
|
724 |
+
|
725 |
if(($s3_response = c_ws_plugin__s2member_utils_urls::remote("https://".$s3_domain.$s3_location, false, array_merge($s3_args, array("timeout" => 20)), "array")) && $s3_response["code"] === 200)
|
726 |
return /* Successfully configured Amazon® S3 Bucket ACLs and Policy. */ array("success" => true, "code" => null, "message" => null);
|
727 |
+
|
728 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
729 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
730 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Cross-Domain Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
731 |
+
|
732 |
+
else // Else, we use a default error code and message.
|
733 |
return array("success" => false, "code" => -94, "message" => _x("Unable to update existing Amazon® S3 Cross-Domain Policy. Connection failed.", "s2member-admin", "s2member"));
|
734 |
}
|
735 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
736 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
737 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Bucket Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
738 |
+
|
739 |
+
else // Else, we use a default error code and message.
|
740 |
return array("success" => false, "code" => -95, "message" => _x("Unable to update existing Amazon® S3 Bucket Policy. Connection failed.", "s2member-admin", "s2member"));
|
741 |
}
|
742 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
743 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
744 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
745 |
+
|
746 |
+
else // Else, we use a default error code and message.
|
747 |
return array("success" => false, "code" => -96, "message" => _x("Unable to update existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
|
748 |
}
|
749 |
+
else // Else, we use a default error code and message.
|
750 |
return array("success" => false, "code" => -97, "message" => _x("Unable to acquire/read existing Amazon® S3 Bucket ACLs. Unexpected response.", "s2member-admin", "s2member"));
|
751 |
}
|
752 |
else if(isset($s3_response["code"], $s3_response["message"]))
|
753 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
754 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
755 |
+
|
756 |
+
else // Else, we use a default error code and message.
|
757 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
|
758 |
}
|
759 |
+
else // Else, we use a default error code and message.
|
760 |
return array("success" => false, "code" => -99, "message" => _x("Unable to auto-configure existing Amazon® S3 Bucket ACLs. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key.", "s2member-admin", "s2member"));
|
761 |
}
|
762 |
/**
|
771 |
public static function amazon_cf_sign($string = FALSE)
|
772 |
{
|
773 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
774 |
+
|
775 |
return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign((string)$string, ($cfc["secret_key"] = $s3c["secret_key"]));
|
776 |
}
|
777 |
/**
|
782 |
*
|
783 |
* @param str $string Input string/data, to be signed by this routine.
|
784 |
* @return str|bool An RSA-SHA1 signature for Amazon® CloudFront, else false on failure.
|
|
|
|
|
|
|
785 |
*/
|
786 |
public static function amazon_cf_rsa_sign($string = FALSE)
|
787 |
{
|
788 |
$cfc["private_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"];
|
789 |
+
|
790 |
return c_ws_plugin__s2member_utils_strings::rsa_sha1_sign((string)$string, $cfc["private_key"]);
|
791 |
}
|
792 |
/**
|
805 |
*/
|
806 |
public static function amazon_cf_url($file = FALSE, $stream = FALSE, $inline = FALSE, $ssl = FALSE, $basename = FALSE, $mimetype = FALSE)
|
807 |
{
|
808 |
+
$file = /* Trim & force string. */ trim((string)$file, "/");
|
809 |
$url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode($file));
|
810 |
+
|
811 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
812 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
813 |
$cfc[$option] = $option_value;
|
814 |
+
|
815 |
$cfc["expires"] = strtotime("+".apply_filters("ws_plugin__s2member_amazon_cf_file_expires_time", "24 hours", get_defined_vars()));
|
816 |
+
|
817 |
$cf_extn = /* Parses the file extension out so we can scan it in some special scenarios. */ strtolower(substr($file, strrpos($file, ".") + 1));
|
818 |
$cf_ip_res = /* Do NOT restrict access to a particular IP during `localhost` development. The IP may NOT be the same one Amazon® CloudFront sees. */ (c_ws_plugin__s2member_utils_conds::is_localhost()) ? false : true;
|
819 |
$cf_stream_extn_resource_exclusions = array_unique((array)apply_filters("ws_plugin__s2member_amazon_cf_file_streaming_extension_resource_exclusions", array("mp3" /* MP3 files should NOT include an extension in their resource reference. */), get_defined_vars()));
|
820 |
$cf_resource = ($stream) ? ((in_array($cf_extn, $cf_stream_extn_resource_exclusions)) ? substr($file, 0, strrpos($file, ".")) : $file) : "http".(($ssl) ? "s" : "")."://".(($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"])."/".$url_e_file;
|
821 |
$cf_url = ($stream) ? "rtmp".(($ssl) ? "e" : "")."://".(($cfc["distro_streaming_cname"]) ? $cfc["distro_streaming_cname"] : $cfc["distro_streaming_dname"])."/cfx/st/".$file : "http".(($ssl) ? "s" : "")."://".(($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"])."/".$url_e_file;
|
822 |
$cf_policy = '{"Statement":[{"Resource":"'.c_ws_plugin__s2member_utils_strings::esc_dq($cf_resource).'","Condition":{'.(($cf_ip_res) ? '"IpAddress":{"AWS:SourceIp":"'.c_ws_plugin__s2member_utils_strings::esc_dq($_SERVER["REMOTE_ADDR"]).'/32"},' : '').'"DateLessThan":{"AWS:EpochTime":'.(int)$cfc["expires"].'}}}]}';
|
823 |
+
|
824 |
$cf_signature = c_ws_plugin__s2member_files_in::amazon_cf_rsa_sign($cf_policy);
|
825 |
$cf_base64_url_safe_policy = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($cf_policy, array("+", "=", "/"), array("-", "_", "~"), false);
|
826 |
$cf_base64_url_safe_signature = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($cf_signature, array("+", "=", "/"), array("-", "_", "~"), false);
|
827 |
+
|
828 |
return add_query_arg(c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep(urlencode_deep(array("Policy" => $cf_base64_url_safe_policy, "Signature" => $cf_base64_url_safe_signature, "Key-Pair-Id" => $cfc["private_key_id"]))), $cf_url);
|
829 |
}
|
830 |
/**
|
841 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
842 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
843 |
$cfc[$option] = $option_value;
|
844 |
+
|
845 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
846 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
847 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
848 |
+
|
849 |
if /* We MUST have an Amazon® S3 Bucket and Keys. */($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
|
850 |
{
|
851 |
if /* We MUST have Amazon® CloudFront Keys in order to auto-configure. */($cfc["private_key"] && $cfc["private_key_id"])
|
854 |
{
|
855 |
if(!$cfc["distro_downloads_id"] || ($cfc["distro_downloads_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
856 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
857 |
+
|
858 |
else if($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
|
859 |
return array("success" => false, "code" => -86, "message" => _x("Unable to delete existing Amazon® CloudFront Downloads Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
860 |
+
|
861 |
else if($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro($cfc["distro_downloads_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
862 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
863 |
+
|
864 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
865 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
866 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
867 |
+
|
868 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distro_downloads_clear) && $cf_distro_downloads_clear)
|
869 |
{
|
870 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
871 |
+
|
872 |
if(!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_distro($cfc["distro_streaming_id"], "streaming")) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
|
873 |
{
|
874 |
if(!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
875 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
876 |
+
|
877 |
else if($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
|
878 |
return array("success" => false, "code" => -87, "message" => _x("Unable to delete existing Amazon® CloudFront Streaming Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
879 |
+
|
880 |
else if($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro($cfc["distro_streaming_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
881 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
882 |
+
|
883 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
884 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
885 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
886 |
+
|
887 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distro_streaming_clear) && $cf_distro_streaming_clear)
|
888 |
{
|
889 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
890 |
+
|
891 |
if(!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_access_origin_identity($cfc["distros_access_id"])) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
|
892 |
{
|
893 |
if(!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
|
894 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
895 |
+
|
896 |
else if($cfc["distros_access_id"] && $cf_get_response && $cf_get_response["success"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_access_origin_identity($cfc["distros_access_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
|
897 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
898 |
+
|
899 |
else if(isset($cf_del_response["code"], $cf_del_response["message"]))
|
900 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
901 |
return array("success" => false, "code" => $cf_del_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
|
902 |
+
|
903 |
if /* Successfully cleared? Ready for a new one? */(isset($cf_distros_access_clear) && $cf_distros_access_clear)
|
904 |
{
|
905 |
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */($cf_get_response, $cf_del_response);
|
906 |
+
|
907 |
$cfc = array_merge($cfc, array("distros_access_id" => "", "distros_s3_access_id" => "", "distro_downloads_id" => "", "distro_downloads_dname" => "", "distro_streaming_id" => "", "distro_streaming_dname" => "", "distros_auto_config_status" => ""));
|
908 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distros_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => "", "ws_plugin__s2member_amazon_cf_files_distros_auto_config_status" => "");
|
909 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
910 |
+
|
911 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distros_access_origin_identity()) && $cf_response["success"])
|
912 |
{
|
913 |
$cfc = array_merge($cfc, array("distros_access_id" => $cf_response["distros_access_id"], "distros_s3_access_id" => $cf_response["distros_s3_access_id"]));
|
914 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distros_access_id" => $cf_response["distros_access_id"], "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => $cf_response["distros_s3_access_id"]);
|
915 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
916 |
+
|
917 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro("downloads")) && $cf_response["success"])
|
918 |
{
|
919 |
$cfc = array_merge($cfc, array("distro_downloads_id" => $cf_response["distro_downloads_id"], "distro_downloads_dname" => $cf_response["distro_downloads_dname"]));
|
920 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => $cf_response["distro_downloads_id"], "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => $cf_response["distro_downloads_dname"]);
|
921 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
922 |
+
|
923 |
if(($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro("streaming")) && $cf_response["success"])
|
924 |
{
|
925 |
$cfc = array_merge($cfc, array("distro_streaming_id" => $cf_response["distro_streaming_id"], "distro_streaming_dname" => $cf_response["distro_streaming_dname"]));
|
926 |
$cf_options = array("ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => $cf_response["distro_streaming_id"], "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => $cf_response["distro_streaming_dname"]);
|
927 |
c_ws_plugin__s2member_menu_pages::update_all_options($cf_options, true, false, false, false, false);
|
928 |
+
|
929 |
for($a = 1, $attempts = 4, $sleep = 2, sleep($sleep); $a <= $attempts; $a++, (($a <= $attempts) ? sleep($sleep) : null))
|
930 |
/* Allow a generous propagation time here. Amazon's high-availability services do NOT guarantee real-time updates.
|
931 |
Since we DO need a fully propagated Origin Access Identity now, we need to make several attempts at success.
|
940 |
if(isset($s3_response["code"], $s3_response["message"]))
|
941 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
|
942 |
return array("success" => false, "code" => $s3_response["code"], "message" => sprintf(_x("Unable to update existing Amazon® S3 ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
|
943 |
+
|
944 |
+
else // Else, we use a default error code and message.
|
945 |
return array("success" => false, "code" => -88, "message" => _x("Unable to update existing Amazon® S3 ACLs. Connection failed.", "s2member-admin", "s2member"));
|
946 |
}
|
947 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
948 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
949 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
950 |
+
|
951 |
+
else // Else, we use a default error code and message.
|
952 |
return array("success" => false, "code" => -89, "message" => _x("Unable to create Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
953 |
}
|
954 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
955 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
956 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
957 |
+
|
958 |
+
else // Else, we use a default error code and message.
|
959 |
return array("success" => false, "code" => -90, "message" => _x("Unable to create Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
960 |
}
|
961 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
962 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
963 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
964 |
+
|
965 |
+
else // Else, we use a default error code and message.
|
966 |
return array("success" => false, "code" => -91, "message" => _x("Unable to create Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
967 |
}
|
968 |
+
else // Else, we use a default error code and message.
|
969 |
return array("success" => false, "code" => -92, "message" => _x("Unable to clear existing Amazon® CloudFront Origin Access Identity.", "s2member-admin", "s2member"));
|
970 |
}
|
971 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
972 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
973 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
974 |
+
|
975 |
+
else // Else, we use a default error code and message.
|
976 |
return array("success" => false, "code" => -93, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
977 |
}
|
978 |
+
else // Else, we use a default error code and message.
|
979 |
return array("success" => false, "code" => -94, "message" => _x("Unable to clear existing Amazon® CloudFront Streaming Distro.", "s2member-admin", "s2member"));
|
980 |
}
|
981 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
982 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
983 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
984 |
+
|
985 |
+
else // Else, we use a default error code and message.
|
986 |
return array("success" => false, "code" => -95, "message" => _x("Unable to acquire existing Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
987 |
}
|
988 |
+
else // Else, we use a default error code and message.
|
989 |
return array("success" => false, "code" => -96, "message" => _x("Unable to clear existing Amazon® CloudFront Downloads Distro.", "s2member-admin", "s2member"));
|
990 |
}
|
991 |
else if(isset($cf_get_response["code"], $cf_get_response["message"]))
|
992 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
993 |
return array("success" => false, "code" => $cf_get_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
|
994 |
+
|
995 |
+
else // Else, we use a default error code and message.
|
996 |
return array("success" => false, "code" => -97, "message" => _x("Unable to acquire existing Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
997 |
}
|
998 |
+
else // Else, we use a default error code and message.
|
999 |
return array("success" => false, "code" => -98, "message" => _x("Unable to auto-configure Amazon® CloudFront Distros. Incomplete Amazon® CloudFront configuration options. Missing of one: Amazon® CloudFront Private Key-Pair-ID, or Private Key file contents.", "s2member-admin", "s2member"));
|
1000 |
}
|
1001 |
+
else // Else, we use a default error code and message.
|
1002 |
return array("success" => false, "code" => -99, "message" => _x("Unable to auto-configure Amazon® S3/CloudFront Distros. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key. You must provide s2Member with an Amazon® S3 configuration before enabling CloudFront.", "s2member-admin", "s2member"));
|
1003 |
}
|
1004 |
/**
|
1018 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1019 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1020 |
$cfc[$option] = $option_value;
|
1021 |
+
|
1022 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1023 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1024 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1025 |
+
|
1026 |
$cf_domain = "cloudfront.amazonaws.com";
|
1027 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1028 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/".$access_id;
|
1029 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1030 |
$cf_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1031 |
+
|
1032 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && (($cf_response["code"] === 404 && $cf_response["message"]) || ($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))))
|
1033 |
{
|
1034 |
if($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1035 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]));
|
1036 |
+
|
1037 |
else /* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1038 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Existing Amazon® CloudFront Origin Access Identity NOT found. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1039 |
}
|
1040 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1041 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1042 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1043 |
+
|
1044 |
+
else // Else, we use a default error code and message.
|
1045 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1046 |
}
|
1047 |
+
else // Else, we use a default error code and message.
|
1048 |
return array("success" => false, "code" => -99, "message" => _x("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Invalid Access ID.", "s2member-admin", "s2member"));
|
1049 |
}
|
1050 |
/**
|
1066 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1067 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1068 |
$cfc[$option] = $option_value;
|
1069 |
+
|
1070 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1071 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1072 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1073 |
+
|
1074 |
$cf_domain = "cloudfront.amazonaws.com";
|
1075 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1076 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/".$access_id;
|
1077 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1078 |
$cf_args = array("method" => "DELETE", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "If-Match" => $access_id_etag, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1079 |
+
|
1080 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 204 /* Deleted. */))
|
1081 |
return /* Deleted successfully. */ array("success" => true, "code" => null, "message" => null);
|
1082 |
+
|
1083 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1084 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1085 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1086 |
+
|
1087 |
+
else // Else, we use a default error code and message.
|
1088 |
return array("success" => false, "code" => -98, "message" => _x("Unable to delete existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1089 |
}
|
1090 |
+
else // Else, we use a default error code and message.
|
1091 |
return array("success" => false, "code" => -99, "message" => _x("Unable to delete existing Amazon® CloudFront Origin Access Identity. Invalid Access ID, ETag, or XML config.", "s2member-admin", "s2member"));
|
1092 |
}
|
1093 |
/**
|
1104 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1105 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1106 |
$cfc[$option] = $option_value;
|
1107 |
+
|
1108 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1109 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1110 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1111 |
+
|
1112 |
$cf_domain = "cloudfront.amazonaws.com";
|
1113 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1114 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront";
|
1116 |
$cf_distros_access_reference = time().".".md5("access".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"]);
|
1117 |
$cf_distros_access_xml = '<?xml version="1.0" encoding="UTF-8"?><CloudFrontOriginAccessIdentityConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><CallerReference>'.esc_html($cf_distros_access_reference).'</CallerReference><Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment></CloudFrontOriginAccessIdentityConfig>';
|
1118 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distros_access_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1119 |
+
|
1120 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1121 |
{
|
1122 |
if(preg_match("/\<CloudFrontOriginAccessIdentity.*?\>(.+?)\<\/CloudFrontOriginAccessIdentity\>/is", $cf_response["body"], $cf_distros_access_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distros_access_tag[1], $cf_distros_access_id_tag) && preg_match("/\<S3CanonicalUserId\>(.+?)\<\/S3CanonicalUserId\>/is", $cf_distros_access_tag[1], $cf_distros_s3_access_id_tag))
|
1123 |
return array("success" => true, "code" => null, "message" => null, "distros_access_id" => trim($cf_distros_access_id_tag[1]), "distros_s3_access_id" => trim($cf_distros_s3_access_id_tag[1]));
|
1124 |
+
|
1125 |
+
else // Else, we use a default error code and message.
|
1126 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create/read Amazon® CloudFront Origin Access Identity. Unexpected response.", "s2member-admin", "s2member"));
|
1127 |
}
|
1128 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1129 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1130 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1131 |
+
|
1132 |
+
else // Else, we use a default error code and message.
|
1133 |
return array("success" => false, "code" => -99, "message" => _x("Unable to create Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
|
1134 |
}
|
1135 |
/**
|
1150 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1151 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1152 |
$cfc[$option] = $option_value;
|
1153 |
+
|
1154 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1155 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1156 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1157 |
+
|
1158 |
$cf_domain = "cloudfront.amazonaws.com";
|
1159 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1160 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1161 |
$cf_location = ($distro_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id : "/2010-11-01/distribution/".$distro_id;
|
1162 |
$cf_args = array("method" => "GET", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1163 |
+
|
1164 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && (($cf_response["code"] === 404 && $cf_response["message"]) || ($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))))
|
1165 |
{
|
1166 |
if($cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1167 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]), "deployed" => ((stripos($cf_response["body"], "<Status>Deployed</Status>") !== false) ? true : false));
|
1168 |
+
|
1169 |
else /* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1170 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Existing Amazon® CloudFront Distro NOT found. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1171 |
}
|
1172 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1173 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1174 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to acquire existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1175 |
+
|
1176 |
+
else // Else, we use a default error code and message.
|
1177 |
return array("success" => false, "code" => -98, "message" => _x("Unable to acquire existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1178 |
}
|
1179 |
+
else // Else, we use a default error code and message.
|
1180 |
return array("success" => false, "code" => -99, "message" => _x("Unable to acquire existing Amazon® CloudFront Distro. Invalid Distro ID and/or Distro type.", "s2member-admin", "s2member"));
|
1181 |
}
|
1182 |
/**
|
1202 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1203 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1204 |
$cfc[$option] = $option_value;
|
1205 |
+
|
1206 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1207 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1208 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1209 |
+
|
1210 |
$cf_domain = "cloudfront.amazonaws.com";
|
1211 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1212 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1213 |
$cf_location = ($distro_id_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id."/config" : "/2010-11-01/distribution/".$distro_id."/config";
|
1214 |
$cf_distro_xml = ($distro_id_type === "streaming") ? '<?xml version="1.0" encoding="UTF-8"?><StreamingDistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName></S3Origin><CallerReference>'.esc_html($distro_id_reference).'</CallerReference><Enabled>false</Enabled><TrustedSigners><Self/></TrustedSigners></StreamingDistributionConfig>' : '<?xml version="1.0" encoding="UTF-8"?><DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName></S3Origin><CallerReference>'.esc_html($distro_id_reference).'</CallerReference><Enabled>false</Enabled><TrustedSigners><Self/></TrustedSigners></DistributionConfig>';
|
1215 |
$cf_args = array("method" => "PUT", "redirection" => 0, "body" => $cf_distro_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "If-Match" => $distro_id_etag, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1216 |
+
|
1217 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && $cf_response["code"] === 200 && !empty($cf_response["headers"]["etag"]) && !empty($cf_response["body"]))
|
1218 |
return array("success" => true, "code" => null, "message" => null, "etag" => trim($cf_response["headers"]["etag"]), "xml" => trim($cf_response["body"]), "deployed" => ((stripos($cf_response["body"], "<Status>Deployed</Status>") !== false) ? true : false));
|
1219 |
+
|
1220 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1221 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1222 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to disable existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1223 |
+
|
1224 |
+
else // Else, we use a default error code and message.
|
1225 |
return array("success" => false, "code" => -97, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1226 |
}
|
1227 |
+
else // Else, we use a default error code and message.
|
1228 |
return array("success" => false, "code" => -98, "message" => _x("Existing Amazon® CloudFront Distro cannot be disabled at this time. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1229 |
}
|
1230 |
+
else // Else, we use a default error code and message.
|
1231 |
return array("success" => true, "code" => null, "message" => null, "etag" => $distro_id_etag, "xml" => $distro_id_xml, "deployed" => ((stripos($distro_id_xml, "<Status>Deployed</Status>") !== false) ? true : false));
|
1232 |
}
|
1233 |
+
else // Else, we use a default error code and message.
|
1234 |
return array("success" => false, "code" => -99, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Invalid Distro ID, ETag, or XML config.", "s2member-admin", "s2member"));
|
1235 |
}
|
1236 |
/**
|
1258 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1259 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1260 |
$cfc[$option] = $option_value;
|
1261 |
+
|
1262 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1263 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1264 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1265 |
+
|
1266 |
$cf_domain = "cloudfront.amazonaws.com";
|
1267 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1268 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1269 |
$cf_location = ($distro_id_type === "streaming") ? "/2010-11-01/streaming-distribution/".$distro_id : "/2010-11-01/distribution/".$distro_id;
|
1270 |
$cf_args = array("method" => "DELETE", "redirection" => 0, "headers" => array("Host" => $cf_domain, "Date" => $cf_date, "If-Match" => $cf_response["etag"], "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1271 |
+
|
1272 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 204 /* Deleted. */))
|
1273 |
return /* Deleted successfully. */ array("success" => true, "code" => null, "message" => null);
|
1274 |
+
|
1275 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1276 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1277 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to delete existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1278 |
+
|
1279 |
+
else // Else, we use a default error code and message.
|
1280 |
return array("success" => false, "code" => -94, "message" => _x("Unable to delete existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1281 |
}
|
1282 |
else if(isset($cf_response["success"], $cf_response["deployed"]) && $cf_response["success"] && !$cf_response["deployed"])
|
1283 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1284 |
return array("success" => false, "code" => -95, "message" => _x("Existing Amazon® CloudFront Distro cannot be deleted at this time. Still in a `pending` state after having been disabled by s2Member. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1285 |
+
|
1286 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1287 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1288 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to check status of existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1289 |
+
|
1290 |
+
else // Else, we use a default error code and message.
|
1291 |
return array("success" => false, "code" => -96, "message" => _x("Unable to check status of existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1292 |
}
|
1293 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1294 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1295 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to disable existing Amazon® CloudFront Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1296 |
+
|
1297 |
+
else // Else, we use a default error code and message.
|
1298 |
return array("success" => false, "code" => -97, "message" => _x("Unable to disable existing Amazon® CloudFront Distro. Connection failed.", "s2member-admin", "s2member"));
|
1299 |
}
|
1300 |
+
else // Else, we use a default error code and message.
|
1301 |
return array("success" => false, "code" => -98, "message" => _x("Existing Amazon® CloudFront Distro cannot be deleted at this time. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
|
1302 |
}
|
1303 |
+
else // Else, we use a default error code and message.
|
1304 |
return array("success" => false, "code" => -99, "message" => _x("Unable to delete existing Amazon® CloudFront Distro. Invalid Distro ID or ETag.", "s2member-admin", "s2member"));
|
1305 |
}
|
1306 |
/**
|
1320 |
foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
|
1321 |
if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
|
1322 |
$cfc[$option] = $option_value;
|
1323 |
+
|
1324 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
1325 |
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
|
1326 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1327 |
+
|
1328 |
$cf_domain = "cloudfront.amazonaws.com";
|
1329 |
$cf_date = gmdate("D, d M Y H:i:s")." GMT";
|
1330 |
$cf_signature = base64_encode(c_ws_plugin__s2member_files_in::amazon_cf_sign($cf_date));
|
1331 |
+
|
1332 |
if /* Create a `downloads` Distro? This uses a different XML schema. */($distro_type === "downloads")
|
1333 |
{
|
1334 |
$cf_location = /* Create distro. */ "/2010-11-01/distribution";
|
1335 |
$cf_distro_downloads_reference = time().".".md5("downloads".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"].$cfc["distro_downloads_cname"]);
|
1336 |
$cf_distro_downloads_xml = '<?xml version="1.0" encoding="UTF-8"?><DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName><OriginAccessIdentity>origin-access-identity/cloudfront/'.esc_html($cfc["distros_access_id"]).'</OriginAccessIdentity></S3Origin><CallerReference>'.esc_html($cf_distro_downloads_reference).'</CallerReference>'.(($cfc["distro_downloads_cname"]) ? '<CNAME>'.esc_html($cfc["distro_downloads_cname"]).'</CNAME>' : '').'<Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment><Enabled>true</Enabled><DefaultRootObject>index.html</DefaultRootObject><TrustedSigners><Self/></TrustedSigners></DistributionConfig>';
|
1337 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distro_downloads_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1338 |
+
|
1339 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1340 |
{
|
1341 |
if(preg_match("/\<Distribution.*?\>(.+?)\<\/Distribution\>/is", $cf_response["body"], $cf_distro_downloads_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distro_downloads_tag[1], $cf_distro_downloads_id_tag) && preg_match("/\<DomainName\>(.+?)\<\/DomainName\>/is", $cf_distro_downloads_tag[1], $cf_distro_downloads_dname_tag))
|
1342 |
return array("success" => true, "code" => null, "message" => null, "distro_downloads_id" => trim($cf_distro_downloads_id_tag[1]), "distro_downloads_dname" => trim($cf_distro_downloads_dname_tag[1]));
|
1343 |
+
|
1344 |
+
else // Else, we use a default error code and message.
|
1345 |
return array("success" => false, "code" => -97, "message" => _x("Unable to create/read Amazon® CloudFront Downloads Distro. Unexpected response.", "s2member-admin", "s2member"));
|
1346 |
}
|
1347 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1348 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1349 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1350 |
+
|
1351 |
+
else // Else, we use a default error code and message.
|
1352 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
|
1353 |
}
|
1354 |
+
|
1355 |
else if /* Create a `streaming` Distro? A different XML schema. */($distro_type === "streaming")
|
1356 |
{
|
1357 |
$cf_location = /* Create streaming distro. */ "/2010-11-01/streaming-distribution";
|
1358 |
$cf_distro_streaming_reference = time().".".md5("streaming".$s3c["bucket"].$s3c["access_key"].$s3c["secret_key"].$cfc["private_key"].$cfc["private_key_id"].$cfc["distro_streaming_cname"]);
|
1359 |
$cf_distro_streaming_xml = '<?xml version="1.0" encoding="UTF-8"?><StreamingDistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><S3Origin><DNSName>'.esc_html($s3c["bucket"]).'.s3.amazonaws.com</DNSName><OriginAccessIdentity>origin-access-identity/cloudfront/'.esc_html($cfc["distros_access_id"]).'</OriginAccessIdentity></S3Origin><CallerReference>'.esc_html($cf_distro_streaming_reference).'</CallerReference>'.(($cfc["distro_streaming_cname"]) ? '<CNAME>'.esc_html($cfc["distro_streaming_cname"]).'</CNAME>' : '').'<Comment>'.esc_html(sprintf(_x("Created by s2Member, for S3 Bucket: %s.", "s2member-admin", "s2member"), $s3c["bucket"])).'</Comment><Enabled>true</Enabled><DefaultRootObject>index.html</DefaultRootObject><TrustedSigners><Self/></TrustedSigners></StreamingDistributionConfig>';
|
1360 |
$cf_args = array("method" => "POST", "redirection" => 0, "body" => $cf_distro_streaming_xml, "headers" => array("Host" => $cf_domain, "Content-Type" => "application/xml", "Date" => $cf_date, "Authorization" => "AWS ".$cfc["access_key"].":".$cf_signature));
|
1361 |
+
|
1362 |
if(($cf_response = c_ws_plugin__s2member_utils_urls::remote("https://".$cf_domain.$cf_location, false, array_merge($cf_args, array("timeout" => 20)), "array")) && ($cf_response["code"] === 200 || $cf_response["code"] === 201 /* Created. */))
|
1363 |
{
|
1364 |
if(preg_match("/\<StreamingDistribution.*?\>(.+?)\<\/StreamingDistribution\>/is", $cf_response["body"], $cf_distro_streaming_tag) && preg_match("/\<Id\>(.+?)\<\/Id\>/is", $cf_distro_streaming_tag[1], $cf_distro_streaming_id_tag) && preg_match("/\<DomainName\>(.+?)\<\/DomainName\>/is", $cf_distro_streaming_tag[1], $cf_distro_streaming_dname_tag))
|
1365 |
return array("success" => true, "code" => null, "message" => null, "distro_streaming_id" => trim($cf_distro_streaming_id_tag[1]), "distro_streaming_dname" => trim($cf_distro_streaming_dname_tag[1]));
|
1366 |
+
|
1367 |
+
else // Else, we use a default error code and message.
|
1368 |
return array("success" => false, "code" => -97, "message" => _x("Unable to create/read Amazon® CloudFront Streaming Distro. Unexpected response.", "s2member-admin", "s2member"));
|
1369 |
}
|
1370 |
else if(isset($cf_response["code"], $cf_response["message"]))
|
1371 |
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
|
1372 |
return array("success" => false, "code" => $cf_response["code"], "message" => sprintf(_x("Unable to create Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
|
1373 |
+
|
1374 |
+
else // Else, we use a default error code and message.
|
1375 |
return array("success" => false, "code" => -98, "message" => _x("Unable to create Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
|
1376 |
}
|
1377 |
}
|
1378 |
+
else // Else, we use a default error code and message.
|
1379 |
return array("success" => false, "code" => -99, "message" => _x("Unable to create Amazon® CloudFront Distro. Invalid Distro type.", "s2member-admin", "s2member"));
|
1380 |
}
|
1381 |
}
|
includes/classes/files.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_files"))
|
21 |
{
|
22 |
/**
|
@@ -41,9 +41,9 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
41 |
* @return null|str If called directly with ``$create_file_download_url``, returns a string with the URL, based on configuration.
|
42 |
* Else, this function may exit script execution after serving a File Download.
|
43 |
*/
|
44 |
-
public static function check_file_download_access($create_file_download_url = FALSE)
|
45 |
{
|
46 |
-
if(is_array($create_file_download_url) || !empty($_GET["s2member_file_download"]))
|
47 |
{
|
48 |
return c_ws_plugin__s2member_files_in::check_file_download_access($create_file_download_url);
|
49 |
}
|
@@ -56,12 +56,12 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
56 |
*
|
57 |
* @param array $config Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine.
|
58 |
* Possible ``$config`` array elements: `file_download` *(required)*, `file_download_key`, `file_stream`, `file_inline`, `file_storage`, `file_remote`, `file_ssl`, `file_rewrite`, `file_rewrite_base`, `skip_confirmation`, `url_to_storage_source`, `count_against_user`, `check_user`.
|
59 |
-
* @param bool $get_streamer_array Optional. Defaults to `false`. If `true`, this function will return an array with the following elements: `streamer`, `file`, `url`. For further details, please review this section in your Dashboard: `s2Member
|
60 |
* @return str A File Download URL string on success; or an array on success, with elements `streamer`, `file`, `url` when/if ``$get_streamer_array`` is true; else false on any type of failure.
|
61 |
*
|
62 |
* @see s2Member\API_Functions\s2member_file_download_url()
|
63 |
*/
|
64 |
-
public static function create_file_download_url($config = FALSE, $get_streamer_array = FALSE)
|
65 |
{
|
66 |
return c_ws_plugin__s2member_files_in::create_file_download_url($config, $get_streamer_array);
|
67 |
}
|
@@ -74,25 +74,25 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
74 |
* @return bool|array True on success, else array on failure.
|
75 |
* Failure array will contain a failure `code`, and a failure `message`.
|
76 |
*/
|
77 |
-
public static function amazon_s3_auto_configure_acls()
|
78 |
{
|
79 |
return c_ws_plugin__s2member_files_in::amazon_s3_auto_configure_acls();
|
80 |
}
|
81 |
/**
|
82 |
-
* Auto-configures Amazon®
|
83 |
*
|
84 |
* @package s2Member\Files
|
85 |
-
* @since
|
86 |
*
|
87 |
* @return bool|array True on success, else array on failure.
|
88 |
* Failure array will contain a failure `code`, and a failure `message`.
|
89 |
*/
|
90 |
-
public static function
|
91 |
{
|
92 |
-
return c_ws_plugin__s2member_files_in::
|
93 |
}
|
94 |
/**
|
95 |
-
* Determines the max period (
|
96 |
*
|
97 |
* @package s2Member\Files
|
98 |
* @since 3.5
|
@@ -105,13 +105,13 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
105 |
public static function max_download_period /* No longer used by s2Member. */()
|
106 |
{
|
107 |
do_action("ws_plugin__s2member_before_max_download_period", get_defined_vars());
|
108 |
-
|
109 |
for($n = 0, $max = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
110 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]))
|
111 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
112 |
if(($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
113 |
$max = ($max < $days) ? $days : $max;
|
114 |
-
|
115 |
return apply_filters("ws_plugin__s2member_max_download_period", (($max > 365) ? 365 : $max), get_defined_vars());
|
116 |
}
|
117 |
/**
|
@@ -122,16 +122,16 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
122 |
*
|
123 |
* @return bool|int False if no access is allowed, else Level number (int) 0+.
|
124 |
*/
|
125 |
-
public static function min_level_4_downloads()
|
126 |
{
|
127 |
do_action("ws_plugin__s2member_before_min_level_4_downloads", get_defined_vars());
|
128 |
-
|
129 |
for($n = 0, $min = false; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
130 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]))
|
131 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
132 |
if(($min = $n) >= 0)
|
133 |
break;
|
134 |
-
|
135 |
return apply_filters("ws_plugin__s2member_min_level_4_downloads", ((is_int($min)) ? $min : false), get_defined_vars());
|
136 |
}
|
137 |
/**
|
@@ -151,23 +151,23 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
151 |
*/
|
152 |
public static function file_download_key($file = FALSE, $directive = FALSE)
|
153 |
{
|
154 |
-
|
155 |
do_action("ws_plugin__s2member_before_file_download_key", get_defined_vars());
|
156 |
-
unset
|
157 |
-
|
158 |
$file = ($file && is_string($file) && ($file = trim($file, "/"))) ? $file : "";
|
159 |
-
|
160 |
if($directive === "ip-forever" && c_ws_plugin__s2member_no_cache::no_cache_constants(true))
|
161 |
$salt = $file.$_SERVER["REMOTE_ADDR"];
|
162 |
-
|
163 |
else if($directive === "universal" || $directive === "cache-compatible" || $directive)
|
164 |
-
$salt = /* Just the file name. This IS
|
165 |
-
|
166 |
else if(c_ws_plugin__s2member_no_cache::no_cache_constants(true))
|
167 |
$salt = date("Y-m-d").$_SERVER["REMOTE_ADDR"].$_SERVER["HTTP_USER_AGENT"].$file;
|
168 |
-
|
169 |
$key = (!empty($salt)) ? md5(c_ws_plugin__s2member_utils_encryption::xencrypt($salt, false, false)) : "";
|
170 |
-
|
171 |
return apply_filters("ws_plugin__s2member_file_download_key", $key, get_defined_vars());
|
172 |
}
|
173 |
/**
|
@@ -178,9 +178,9 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
178 |
*
|
179 |
* @param obj $user Optional. A `WP_User` object. Defaults to the current User's object.
|
180 |
* @param str $not_counting_this_particular_file Optional. If you want to exclude a particular file,
|
181 |
-
* relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(
|
182 |
-
* @param array $user_log Optional. Prevents another database connection *(
|
183 |
-
* @param array $user_arc Optional. Prevents another database connection *(
|
184 |
* @return array An array with the following elements... File Downloads allowed for this User: (int)`allowed`, Download Period for this User in days: (int)`allowed_days`, Files downloaded by this User in the current Period: (int)`currently`, log of all Files downloaded in the current Period, with file names/dates: (array)`log`, archive of all Files downloaded in prior Periods, with file names/dates: (array)`archive`.
|
185 |
*
|
186 |
* @note Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
|
@@ -188,37 +188,37 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
188 |
*/
|
189 |
public static function user_downloads($user = FALSE, $not_counting_this_particular_file = FALSE, $user_log = FALSE, $user_arc = FALSE)
|
190 |
{
|
191 |
-
|
192 |
do_action("ws_plugin__s2member_before_user_downloads", get_defined_vars());
|
193 |
-
unset
|
194 |
-
|
195 |
-
$allowed = $allowed_days = $currently =
|
196 |
-
$log = $arc =
|
197 |
-
|
198 |
if((is_object($user) || is_object($user = (is_user_logged_in()) ? wp_get_current_user() : false)) && !empty($user->ID) && ($user_id = $user->ID))
|
199 |
{
|
200 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
201 |
{
|
202 |
-
if($user->has_cap("access_s2member_level".$n))
|
203 |
{
|
204 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
205 |
{
|
206 |
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"];
|
207 |
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"];
|
208 |
}
|
209 |
-
if
|
210 |
-
break
|
211 |
}
|
212 |
}
|
213 |
$log = (is_array($user_log)) ? $user_log : ((is_array($log = get_user_option("s2member_file_download_access_log", $user_id)) && $log !== array(false)) ? $log : array());
|
214 |
$arc = (is_array($user_arc)) ? $user_arc : ((is_array($arc = get_user_option("s2member_file_download_access_arc", $user_id)) && $arc !== array(false)) ? $arc : array());
|
215 |
-
|
216 |
foreach(($user_file_download_access_log = $log) as $user_file_download_access_log_entry_key => $user_file_download_access_log_entry)
|
217 |
if(isset($user_file_download_access_log_entry["date"]) && strtotime($user_file_download_access_log_entry["date"]) >= strtotime("-".$allowed_days." days"))
|
218 |
if(isset($user_file_download_access_log_entry["file"]) && $user_file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
|
219 |
$currently = $currently + 1;
|
220 |
}
|
221 |
-
|
222 |
return apply_filters("ws_plugin__s2member_user_downloads", array("allowed" => $allowed, "allowed_days" => $allowed_days, "currently" => $currently, "log" => $log, "archive" => $arc), get_defined_vars());
|
223 |
}
|
224 |
/**
|
@@ -227,8 +227,8 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
227 |
* @package s2Member\Files
|
228 |
* @since 111026
|
229 |
*
|
230 |
-
* @param str $file Required. Location of the file, relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(
|
231 |
-
* @param str|int $user_id Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively *(
|
232 |
* @param bool $check_archives_too Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if ``$user_id`` is specified, based solely on a specific User's `allowed_days`, configured in your Basic Download Restrictions, at the User's current Membership Level.
|
233 |
* @return int The total for this particular ``$file``, based on configuration of function arguments.
|
234 |
*
|
@@ -237,20 +237,20 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
237 |
*/
|
238 |
public static function total_downloads_of($file = FALSE, $user_id = FALSE, $check_archives_too = TRUE)
|
239 |
{
|
240 |
-
global
|
241 |
-
|
242 |
-
if
|
243 |
{
|
244 |
if(is_array($results = $wpdb->get_results("SELECT `meta_key`, `meta_value` FROM `".$wpdb->usermeta."` WHERE ".((is_numeric($user_id)) ? "`user_id` = '".esc_sql($user_id)."' AND " : "")."(`meta_key` = '".$wpdb->prefix."s2member_file_download_access_log'".(($check_archives_too) ? " OR `meta_key` = '".$wpdb->prefix."s2member_file_download_access_arc'" : "").") AND `meta_value` REGEXP '.*\"file\";s:[0-9]+:\"".esc_sql($file)."\".*'")))
|
245 |
{
|
246 |
foreach($results as $r /* Go through the entire array of results found in the `REGEXP` database query above. */)
|
247 |
if(is_array($la_entries = /* Unserialize the array. */ maybe_unserialize($r->meta_value)) && !empty($la_entries))
|
248 |
-
|
249 |
foreach($la_entries as $la_entry /* Go through all of the entries in each result ``$r``; collecting `counter` values. */)
|
250 |
if(!empty($la_entry["file"]) && $la_entry["file"] === $file && /* Back compatibility. Is `counter` even set? */ (!empty($la_entry["counter"]) || ($la_entry["counter"] = 1)))
|
251 |
{
|
252 |
$total = (!empty($total)) ? $total + (int)$la_entry["counter"] : (int)$la_entry["counter"];
|
253 |
-
break
|
254 |
}
|
255 |
}
|
256 |
}
|
@@ -262,8 +262,8 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
262 |
* @package s2Member\Files
|
263 |
* @since 111026
|
264 |
*
|
265 |
-
* @param str $file Required. Location of the file, relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(
|
266 |
-
* @param str|int $user_id Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively *(
|
267 |
* @param bool $check_archives_too Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if ``$user_id`` is specified, based solely on a specific User's `allowed_days`, configured in your Basic Download Restrictions, at the User's current Membership Level.
|
268 |
* @return int The total for this particular ``$file``, based on configuration of function arguments.
|
269 |
*
|
@@ -272,20 +272,20 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
272 |
*/
|
273 |
public static function total_unique_downloads_of($file = FALSE, $user_id = FALSE, $check_archives_too = TRUE)
|
274 |
{
|
275 |
-
global
|
276 |
-
|
277 |
-
if
|
278 |
{
|
279 |
if(is_array($results = $wpdb->get_results("SELECT `meta_key`, `meta_value` FROM `".$wpdb->usermeta."` WHERE ".((is_numeric($user_id)) ? "`user_id` = '".esc_sql($user_id)."' AND " : "")."(`meta_key` = '".$wpdb->prefix."s2member_file_download_access_log'".(($check_archives_too) ? " OR `meta_key` = '".$wpdb->prefix."s2member_file_download_access_arc'" : "").") AND `meta_value` REGEXP '.*\"file\";s:[0-9]+:\"".esc_sql($file)."\".*'")))
|
280 |
{
|
281 |
foreach($results as $r /* Go through the entire array of results found in the `REGEXP` database query above. */)
|
282 |
if(is_array($la_entries = /* Unserialize the array. */ maybe_unserialize($r->meta_value)) && !empty($la_entries))
|
283 |
-
|
284 |
foreach($la_entries as $la_entry /* Go through all of the entries in each result ``$r``; collecting `counter` values. */)
|
285 |
if(!empty($la_entry["file"]) && $la_entry["file"] === $file && /* Back compatibility. Is `counter` even set? */ (!empty($la_entry["counter"]) || ($la_entry["counter"] = 1)))
|
286 |
{
|
287 |
-
$total = (!empty($total)) ? /* Only count `1` here (
|
288 |
-
break
|
289 |
}
|
290 |
}
|
291 |
}
|
@@ -304,10 +304,10 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
304 |
$start_line = /* Beginning line for this entry. */ "# BEGIN s2Member GZIP exclusions";
|
305 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
306 |
$htaccess = /* Location of this `.htaccess` file. */ ABSPATH.".htaccess";
|
307 |
-
|
308 |
if(file_exists($htaccess) && is_readable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
309 |
return preg_match("/".preg_quote($start_line, "/")."[\r\n]+.*?[\r\n]+".preg_quote($end_line, "/")."[\r\n]{0,2}/is", $htaccess_contents);
|
310 |
-
|
311 |
return /* Default return `false`. */ false;
|
312 |
}
|
313 |
/**
|
@@ -326,17 +326,17 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
326 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
327 |
$htaccess = /* Location of this `.htaccess` file we need to write in. */ ABSPATH.".htaccess";
|
328 |
$ideally_position_before = /* Ideally, we can position before this entry. */ "# BEGIN WordPress";
|
329 |
-
|
330 |
$no_gzip = $start_line."\n".trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_no_gzip_htaccess"])))."\n".$end_line;
|
331 |
-
|
332 |
if(file_exists($htaccess) && is_readable($htaccess) && is_writable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
333 |
{
|
334 |
if(stripos /* If we can position in the ideal location, that's awesome. Let's do that now. */($htaccess_contents, $ideally_position_before) !== false)
|
335 |
$htaccess_contents = trim(str_ireplace($ideally_position_before, $no_gzip."\n\n".$ideally_position_before, $htaccess_contents));
|
336 |
-
|
337 |
-
else
|
338 |
$htaccess_contents = trim($no_gzip."\n\n".$htaccess_contents);
|
339 |
-
|
340 |
return file_put_contents($htaccess, $htaccess_contents);
|
341 |
}
|
342 |
else if(!file_exists($htaccess) && is_writable(dirname($htaccess)))
|
@@ -352,18 +352,18 @@ if(!class_exists("c_ws_plugin__s2member_files"))
|
|
352 |
* @package s2Member\Files
|
353 |
* @since 120212
|
354 |
*
|
355 |
-
* @return bool True if
|
356 |
*/
|
357 |
public static function remove_no_gzip_from_root_htaccess()
|
358 |
{
|
359 |
$start_line = /* Beginning line for this entry. */ "# BEGIN s2Member GZIP exclusions";
|
360 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
361 |
$htaccess = /* Location of this `.htaccess` file we need to write in. */ ABSPATH.".htaccess";
|
362 |
-
|
363 |
if(file_exists($htaccess) && is_readable($htaccess) && is_writable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
364 |
{
|
365 |
$htaccess_contents = trim(preg_replace("/".preg_quote($start_line, "/")."[\r\n]+.*?[\r\n]+".preg_quote($end_line, "/")."[\r\n]{0,2}/is", "", $htaccess_contents));
|
366 |
-
|
367 |
return /* Check for `false`, because this could return `0` if the file is now empty. */ (file_put_contents($htaccess, $htaccess_contents) !== false);
|
368 |
}
|
369 |
else if(!file_exists($htaccess) /* Return `true` here, we're OK. */)
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_files"))
|
21 |
{
|
22 |
/**
|
41 |
* @return null|str If called directly with ``$create_file_download_url``, returns a string with the URL, based on configuration.
|
42 |
* Else, this function may exit script execution after serving a File Download.
|
43 |
*/
|
44 |
+
public static function check_file_download_access($create_file_download_url = FALSE)
|
45 |
{
|
46 |
+
if(is_array($create_file_download_url) || !empty($_GET["s2member_file_download"]))
|
47 |
{
|
48 |
return c_ws_plugin__s2member_files_in::check_file_download_access($create_file_download_url);
|
49 |
}
|
56 |
*
|
57 |
* @param array $config Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine.
|
58 |
* Possible ``$config`` array elements: `file_download` *(required)*, `file_download_key`, `file_stream`, `file_inline`, `file_storage`, `file_remote`, `file_ssl`, `file_rewrite`, `file_rewrite_base`, `skip_confirmation`, `url_to_storage_source`, `count_against_user`, `check_user`.
|
59 |
+
* @param bool $get_streamer_array Optional. Defaults to `false`. If `true`, this function will return an array with the following elements: `streamer`, `file`, `url`. For further details, please review this section in your Dashboard: `s2Member -› Download Options -› JW Player® & RTMP Protocol Examples`.
|
60 |
* @return str A File Download URL string on success; or an array on success, with elements `streamer`, `file`, `url` when/if ``$get_streamer_array`` is true; else false on any type of failure.
|
61 |
*
|
62 |
* @see s2Member\API_Functions\s2member_file_download_url()
|
63 |
*/
|
64 |
+
public static function create_file_download_url($config = FALSE, $get_streamer_array = FALSE)
|
65 |
{
|
66 |
return c_ws_plugin__s2member_files_in::create_file_download_url($config, $get_streamer_array);
|
67 |
}
|
74 |
* @return bool|array True on success, else array on failure.
|
75 |
* Failure array will contain a failure `code`, and a failure `message`.
|
76 |
*/
|
77 |
+
public static function amazon_s3_auto_configure_acls()
|
78 |
{
|
79 |
return c_ws_plugin__s2member_files_in::amazon_s3_auto_configure_acls();
|
80 |
}
|
81 |
/**
|
82 |
+
* Auto-configures Amazon® CloudFront distros.
|
83 |
*
|
84 |
* @package s2Member\Files
|
85 |
+
* @since 130209
|
86 |
*
|
87 |
* @return bool|array True on success, else array on failure.
|
88 |
* Failure array will contain a failure `code`, and a failure `message`.
|
89 |
*/
|
90 |
+
public static function amazon_cf_auto_configure_distros()
|
91 |
{
|
92 |
+
return c_ws_plugin__s2member_files_in::amazon_cf_auto_configure_distros();
|
93 |
}
|
94 |
/**
|
95 |
+
* Determines the max period (in days), for Download Access.
|
96 |
*
|
97 |
* @package s2Member\Files
|
98 |
* @since 3.5
|
105 |
public static function max_download_period /* No longer used by s2Member. */()
|
106 |
{
|
107 |
do_action("ws_plugin__s2member_before_max_download_period", get_defined_vars());
|
108 |
+
|
109 |
for($n = 0, $max = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
110 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]))
|
111 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
112 |
if(($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
113 |
$max = ($max < $days) ? $days : $max;
|
114 |
+
|
115 |
return apply_filters("ws_plugin__s2member_max_download_period", (($max > 365) ? 365 : $max), get_defined_vars());
|
116 |
}
|
117 |
/**
|
122 |
*
|
123 |
* @return bool|int False if no access is allowed, else Level number (int) 0+.
|
124 |
*/
|
125 |
+
public static function min_level_4_downloads()
|
126 |
{
|
127 |
do_action("ws_plugin__s2member_before_min_level_4_downloads", get_defined_vars());
|
128 |
+
|
129 |
for($n = 0, $min = false; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
130 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]))
|
131 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
132 |
if(($min = $n) >= 0)
|
133 |
break;
|
134 |
+
|
135 |
return apply_filters("ws_plugin__s2member_min_level_4_downloads", ((is_int($min)) ? $min : false), get_defined_vars());
|
136 |
}
|
137 |
/**
|
151 |
*/
|
152 |
public static function file_download_key($file = FALSE, $directive = FALSE)
|
153 |
{
|
154 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
155 |
do_action("ws_plugin__s2member_before_file_download_key", get_defined_vars());
|
156 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
157 |
+
|
158 |
$file = ($file && is_string($file) && ($file = trim($file, "/"))) ? $file : "";
|
159 |
+
|
160 |
if($directive === "ip-forever" && c_ws_plugin__s2member_no_cache::no_cache_constants(true))
|
161 |
$salt = $file.$_SERVER["REMOTE_ADDR"];
|
162 |
+
|
163 |
else if($directive === "universal" || $directive === "cache-compatible" || $directive)
|
164 |
+
$salt = /* Just the file name. This IS cacheable. */ $file;
|
165 |
+
|
166 |
else if(c_ws_plugin__s2member_no_cache::no_cache_constants(true))
|
167 |
$salt = date("Y-m-d").$_SERVER["REMOTE_ADDR"].$_SERVER["HTTP_USER_AGENT"].$file;
|
168 |
+
|
169 |
$key = (!empty($salt)) ? md5(c_ws_plugin__s2member_utils_encryption::xencrypt($salt, false, false)) : "";
|
170 |
+
|
171 |
return apply_filters("ws_plugin__s2member_file_download_key", $key, get_defined_vars());
|
172 |
}
|
173 |
/**
|
178 |
*
|
179 |
* @param obj $user Optional. A `WP_User` object. Defaults to the current User's object.
|
180 |
* @param str $not_counting_this_particular_file Optional. If you want to exclude a particular file,
|
181 |
+
* relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(when applicable)*.
|
182 |
+
* @param array $user_log Optional. Prevents another database connection *(i.e. the User's log does not need to be pulled again)*.
|
183 |
+
* @param array $user_arc Optional. Prevents another database connection *(i.e. the User's archive does not need to be pulled again)*.
|
184 |
* @return array An array with the following elements... File Downloads allowed for this User: (int)`allowed`, Download Period for this User in days: (int)`allowed_days`, Files downloaded by this User in the current Period: (int)`currently`, log of all Files downloaded in the current Period, with file names/dates: (array)`log`, archive of all Files downloaded in prior Periods, with file names/dates: (array)`archive`.
|
185 |
*
|
186 |
* @note Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
|
188 |
*/
|
189 |
public static function user_downloads($user = FALSE, $not_counting_this_particular_file = FALSE, $user_log = FALSE, $user_arc = FALSE)
|
190 |
{
|
191 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
192 |
do_action("ws_plugin__s2member_before_user_downloads", get_defined_vars());
|
193 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
194 |
+
|
195 |
+
$allowed = $allowed_days = $currently = /* Initialize these to zero. */ 0;
|
196 |
+
$log = $arc = /* Initialize these to a default empty array value. */ array();
|
197 |
+
|
198 |
if((is_object($user) || is_object($user = (is_user_logged_in()) ? wp_get_current_user() : false)) && !empty($user->ID) && ($user_id = $user->ID))
|
199 |
{
|
200 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
201 |
{
|
202 |
+
if /* Do they have access? */($user->has_cap("access_s2member_level".$n))
|
203 |
{
|
204 |
if(!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"]) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"]))
|
205 |
{
|
206 |
$allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed"];
|
207 |
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_file_downloads_allowed_days"];
|
208 |
}
|
209 |
+
if /* We can stop now, if this is their Role. */($user->has_cap("s2member_level".$n))
|
210 |
+
break /* Break now. */;
|
211 |
}
|
212 |
}
|
213 |
$log = (is_array($user_log)) ? $user_log : ((is_array($log = get_user_option("s2member_file_download_access_log", $user_id)) && $log !== array(false)) ? $log : array());
|
214 |
$arc = (is_array($user_arc)) ? $user_arc : ((is_array($arc = get_user_option("s2member_file_download_access_arc", $user_id)) && $arc !== array(false)) ? $arc : array());
|
215 |
+
|
216 |
foreach(($user_file_download_access_log = $log) as $user_file_download_access_log_entry_key => $user_file_download_access_log_entry)
|
217 |
if(isset($user_file_download_access_log_entry["date"]) && strtotime($user_file_download_access_log_entry["date"]) >= strtotime("-".$allowed_days." days"))
|
218 |
if(isset($user_file_download_access_log_entry["file"]) && $user_file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
|
219 |
$currently = $currently + 1;
|
220 |
}
|
221 |
+
|
222 |
return apply_filters("ws_plugin__s2member_user_downloads", array("allowed" => $allowed, "allowed_days" => $allowed_days, "currently" => $currently, "log" => $log, "archive" => $arc), get_defined_vars());
|
223 |
}
|
224 |
/**
|
227 |
* @package s2Member\Files
|
228 |
* @since 111026
|
229 |
*
|
230 |
+
* @param str $file Required. Location of the file, relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(when applicable)*.
|
231 |
+
* @param str|int $user_id Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively *(i.e among all Users/Members)*.
|
232 |
* @param bool $check_archives_too Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if ``$user_id`` is specified, based solely on a specific User's `allowed_days`, configured in your Basic Download Restrictions, at the User's current Membership Level.
|
233 |
* @return int The total for this particular ``$file``, based on configuration of function arguments.
|
234 |
*
|
237 |
*/
|
238 |
public static function total_downloads_of($file = FALSE, $user_id = FALSE, $check_archives_too = TRUE)
|
239 |
{
|
240 |
+
global /* Global database object reference. */ $wpdb;
|
241 |
+
|
242 |
+
if /* Was ``$file`` passed in properly? */($file && is_string($file))
|
243 |
{
|
244 |
if(is_array($results = $wpdb->get_results("SELECT `meta_key`, `meta_value` FROM `".$wpdb->usermeta."` WHERE ".((is_numeric($user_id)) ? "`user_id` = '".esc_sql($user_id)."' AND " : "")."(`meta_key` = '".$wpdb->prefix."s2member_file_download_access_log'".(($check_archives_too) ? " OR `meta_key` = '".$wpdb->prefix."s2member_file_download_access_arc'" : "").") AND `meta_value` REGEXP '.*\"file\";s:[0-9]+:\"".esc_sql($file)."\".*'")))
|
245 |
{
|
246 |
foreach($results as $r /* Go through the entire array of results found in the `REGEXP` database query above. */)
|
247 |
if(is_array($la_entries = /* Unserialize the array. */ maybe_unserialize($r->meta_value)) && !empty($la_entries))
|
248 |
+
|
249 |
foreach($la_entries as $la_entry /* Go through all of the entries in each result ``$r``; collecting `counter` values. */)
|
250 |
if(!empty($la_entry["file"]) && $la_entry["file"] === $file && /* Back compatibility. Is `counter` even set? */ (!empty($la_entry["counter"]) || ($la_entry["counter"] = 1)))
|
251 |
{
|
252 |
$total = (!empty($total)) ? $total + (int)$la_entry["counter"] : (int)$la_entry["counter"];
|
253 |
+
break /* Break now. No need to continue looping; ``$file`` found in these entries. */;
|
254 |
}
|
255 |
}
|
256 |
}
|
262 |
* @package s2Member\Files
|
263 |
* @since 111026
|
264 |
*
|
265 |
+
* @param str $file Required. Location of the file, relative to the `/s2member-files/` directory, or relative to the root of your Amazon® S3 Bucket *(when applicable)*.
|
266 |
+
* @param str|int $user_id Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively *(i.e among all Users/Members)*.
|
267 |
* @param bool $check_archives_too Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if ``$user_id`` is specified, based solely on a specific User's `allowed_days`, configured in your Basic Download Restrictions, at the User's current Membership Level.
|
268 |
* @return int The total for this particular ``$file``, based on configuration of function arguments.
|
269 |
*
|
272 |
*/
|
273 |
public static function total_unique_downloads_of($file = FALSE, $user_id = FALSE, $check_archives_too = TRUE)
|
274 |
{
|
275 |
+
global /* Global database object reference. */ $wpdb;
|
276 |
+
|
277 |
+
if /* Was ``$file`` passed in properly? */($file && is_string($file))
|
278 |
{
|
279 |
if(is_array($results = $wpdb->get_results("SELECT `meta_key`, `meta_value` FROM `".$wpdb->usermeta."` WHERE ".((is_numeric($user_id)) ? "`user_id` = '".esc_sql($user_id)."' AND " : "")."(`meta_key` = '".$wpdb->prefix."s2member_file_download_access_log'".(($check_archives_too) ? " OR `meta_key` = '".$wpdb->prefix."s2member_file_download_access_arc'" : "").") AND `meta_value` REGEXP '.*\"file\";s:[0-9]+:\"".esc_sql($file)."\".*'")))
|
280 |
{
|
281 |
foreach($results as $r /* Go through the entire array of results found in the `REGEXP` database query above. */)
|
282 |
if(is_array($la_entries = /* Unserialize the array. */ maybe_unserialize($r->meta_value)) && !empty($la_entries))
|
283 |
+
|
284 |
foreach($la_entries as $la_entry /* Go through all of the entries in each result ``$r``; collecting `counter` values. */)
|
285 |
if(!empty($la_entry["file"]) && $la_entry["file"] === $file && /* Back compatibility. Is `counter` even set? */ (!empty($la_entry["counter"]) || ($la_entry["counter"] = 1)))
|
286 |
{
|
287 |
+
$total = (!empty($total)) ? /* Only count `1` here (i.e. unique downloads). */ $total + 1 : 1;
|
288 |
+
break /* Break now. No need to continue looping; ``$file`` found in these entries. */;
|
289 |
}
|
290 |
}
|
291 |
}
|
304 |
$start_line = /* Beginning line for this entry. */ "# BEGIN s2Member GZIP exclusions";
|
305 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
306 |
$htaccess = /* Location of this `.htaccess` file. */ ABSPATH.".htaccess";
|
307 |
+
|
308 |
if(file_exists($htaccess) && is_readable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
309 |
return preg_match("/".preg_quote($start_line, "/")."[\r\n]+.*?[\r\n]+".preg_quote($end_line, "/")."[\r\n]{0,2}/is", $htaccess_contents);
|
310 |
+
|
311 |
return /* Default return `false`. */ false;
|
312 |
}
|
313 |
/**
|
326 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
327 |
$htaccess = /* Location of this `.htaccess` file we need to write in. */ ABSPATH.".htaccess";
|
328 |
$ideally_position_before = /* Ideally, we can position before this entry. */ "# BEGIN WordPress";
|
329 |
+
|
330 |
$no_gzip = $start_line."\n".trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_no_gzip_htaccess"])))."\n".$end_line;
|
331 |
+
|
332 |
if(file_exists($htaccess) && is_readable($htaccess) && is_writable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
333 |
{
|
334 |
if(stripos /* If we can position in the ideal location, that's awesome. Let's do that now. */($htaccess_contents, $ideally_position_before) !== false)
|
335 |
$htaccess_contents = trim(str_ireplace($ideally_position_before, $no_gzip."\n\n".$ideally_position_before, $htaccess_contents));
|
336 |
+
|
337 |
+
else // Else, let's put it at the very top of the file by default.
|
338 |
$htaccess_contents = trim($no_gzip."\n\n".$htaccess_contents);
|
339 |
+
|
340 |
return file_put_contents($htaccess, $htaccess_contents);
|
341 |
}
|
342 |
else if(!file_exists($htaccess) && is_writable(dirname($htaccess)))
|
352 |
* @package s2Member\Files
|
353 |
* @since 120212
|
354 |
*
|
355 |
+
* @return bool True if successful, else false on any type of failure.
|
356 |
*/
|
357 |
public static function remove_no_gzip_from_root_htaccess()
|
358 |
{
|
359 |
$start_line = /* Beginning line for this entry. */ "# BEGIN s2Member GZIP exclusions";
|
360 |
$end_line = /* Identifying end line for this entry. */ "# END s2Member GZIP exclusions";
|
361 |
$htaccess = /* Location of this `.htaccess` file we need to write in. */ ABSPATH.".htaccess";
|
362 |
+
|
363 |
if(file_exists($htaccess) && is_readable($htaccess) && is_writable($htaccess) && ($htaccess_contents = file_get_contents($htaccess)) !== false && is_string($htaccess_contents = trim($htaccess_contents)))
|
364 |
{
|
365 |
$htaccess_contents = trim(preg_replace("/".preg_quote($start_line, "/")."[\r\n]+.*?[\r\n]+".preg_quote($end_line, "/")."[\r\n]{0,2}/is", "", $htaccess_contents));
|
366 |
+
|
367 |
return /* Check for `false`, because this could return `0` if the file is now empty. */ (file_put_contents($htaccess, $htaccess_contents) !== false);
|
368 |
}
|
369 |
else if(!file_exists($htaccess) /* Return `true` here, we're OK. */)
|
includes/classes/installation.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_installation"))
|
21 |
{
|
22 |
/**
|
@@ -37,108 +37,108 @@ if(!class_exists("c_ws_plugin__s2member_installation"))
|
|
37 |
*/
|
38 |
public static function activate($reactivation_reason = FALSE)
|
39 |
{
|
40 |
-
global
|
41 |
-
global $current_site, $current_blog;
|
42 |
-
|
43 |
do_action("ws_plugin__s2member_before_activation", get_defined_vars());
|
44 |
-
|
45 |
-
c_ws_plugin__s2member_roles_caps::config_roles
|
46 |
update_option("ws_plugin__s2member_activated_levels", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]);
|
47 |
-
|
48 |
if(!is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
49 |
if(is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir))))
|
50 |
mkdir($files_dir, 0777, true);
|
51 |
-
|
52 |
if(is_dir($files_dir) && is_writable($files_dir))
|
53 |
if(!file_exists($htaccess = $files_dir."/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_files_dir_htaccess", false, get_defined_vars()))
|
54 |
file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"]))));
|
55 |
-
|
56 |
c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess /* Handle the root `.htaccess` file as well now, for GZIP exclusions. */();
|
57 |
-
|
58 |
if(!is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
59 |
if(is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir))))
|
60 |
mkdir($logs_dir, 0777, true);
|
61 |
-
|
62 |
if(is_dir($logs_dir) && is_writable($logs_dir))
|
63 |
if(!file_exists($htaccess = $logs_dir."/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_logs_dir_htaccess", false, get_defined_vars()))
|
64 |
file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"]))));
|
65 |
-
|
66 |
(!is_array(get_option("ws_plugin__s2member_cache"))) ? update_option("ws_plugin__s2member_cache", array()) : null;
|
67 |
(!is_array(get_option("ws_plugin__s2member_notices"))) ? update_option("ws_plugin__s2member_notices", array()) : null;
|
68 |
(!is_array(get_option("ws_plugin__s2member_options"))) ? update_option("ws_plugin__s2member_options", array()) : null;
|
69 |
(!is_numeric(get_option("ws_plugin__s2member_configured"))) ? update_option("ws_plugin__s2member_configured", "0") : null;
|
70 |
-
|
71 |
-
if($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"])
|
72 |
{
|
73 |
-
$v = get_option("ws_plugin__s2member_activated_version");
|
74 |
-
|
75 |
-
if(!$v || !version_compare($v, "3.2", ">="))
|
76 |
-
|
77 |
{
|
78 |
$like = "`meta_key` LIKE 's2member\_%' AND `meta_key` NOT LIKE '%s2member\_originating\_blog%'";
|
79 |
$wpdb->query("UPDATE `".$wpdb->usermeta."` SET `meta_key` = CONCAT('".$wpdb->prefix."', `meta_key`) WHERE ".$like);
|
80 |
}
|
81 |
-
|
82 |
-
if(!$v || !version_compare($v, "3.2.5", ">="))
|
83 |
-
|
84 |
{
|
85 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '\_transient\_%'");
|
86 |
}
|
87 |
-
|
88 |
-
if(!$v || !version_compare($v, "3.2.6", ">="))
|
89 |
-
|
90 |
{
|
91 |
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
|
92 |
}
|
93 |
-
|
94 |
if(!$v || !version_compare($v, "110912", ">=") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === array("all"))
|
95 |
-
|
96 |
{
|
97 |
-
$notice = '<strong>IMPORTANT:</strong> This version of s2Member® changes the way your <code>Alternative View Protections</code> work. Please review your options under: <code>s2Member
|
98 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
99 |
}
|
100 |
-
|
101 |
$notice = '<strong>s2Member</strong> has been <strong>reactivated</strong>, with '.(($reactivation_reason === "levels") ? '<code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]).'</code> Membership Levels' : 'the latest version').'.<br />';
|
102 |
$notice .= 'You now have version '.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'. Your existing configuration remains.';
|
103 |
-
|
104 |
-
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site())
|
105 |
$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! :-)';
|
106 |
-
|
107 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
108 |
}
|
109 |
-
else
|
110 |
{
|
111 |
-
$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>(
|
112 |
-
|
113 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:users.php", false, false, true);
|
114 |
-
|
115 |
$notice = '<strong>s2Member</strong> v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).' has been <strong>activated</strong>. Nice work!<br />';
|
116 |
$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! :-)';
|
117 |
-
|
118 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
119 |
}
|
120 |
-
|
121 |
-
if(is_multisite() && is_main_site())
|
122 |
{
|
123 |
$wpdb->query("INSERT INTO `".$wpdb->usermeta."` (`user_id`, `meta_key`, `meta_value`) SELECT `ID`, 's2member_originating_blog', '".esc_sql($current_site->blog_id)."' FROM `".$wpdb->users."` WHERE `ID` NOT IN (SELECT `user_id` FROM `".$wpdb->usermeta."` WHERE `meta_key` = 's2member_originating_blog')");
|
124 |
-
|
125 |
$notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'.<br />';
|
126 |
$notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
|
127 |
$notice .= 'In the Dashboard for your Main Site, see:<br />';
|
128 |
-
$notice .= '<code>s2Member
|
129 |
-
|
130 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
131 |
-
|
132 |
update_site_option("ws_plugin__s2member_options", (array)get_option("ws_plugin__s2member_options"));
|
133 |
-
|
134 |
update_option("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
|
135 |
}
|
136 |
-
|
137 |
update_option("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION);
|
138 |
-
|
139 |
do_action("ws_plugin__s2member_after_activation", get_defined_vars());
|
140 |
-
|
141 |
-
return
|
142 |
}
|
143 |
/**
|
144 |
* Deactivation routines for s2Member.
|
@@ -150,36 +150,36 @@ if(!class_exists("c_ws_plugin__s2member_installation"))
|
|
150 |
*/
|
151 |
public static function deactivate()
|
152 |
{
|
153 |
-
global
|
154 |
-
global $current_site, $current_blog;
|
155 |
-
|
156 |
do_action("ws_plugin__s2member_before_deactivation", get_defined_vars());
|
157 |
-
|
158 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
|
159 |
{
|
160 |
-
c_ws_plugin__s2member_roles_caps::unlink_roles
|
161 |
-
|
162 |
c_ws_plugin__s2member_files::remove_no_gzip_from_root_htaccess /* Remove GZIP exclusions. */();
|
163 |
-
|
164 |
if(is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
165 |
{
|
166 |
if(file_exists($htaccess = $files_dir."/.htaccess"))
|
167 |
if(is_writable($htaccess))
|
168 |
unlink($htaccess);
|
169 |
-
|
170 |
@rmdir($files_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir));
|
171 |
}
|
172 |
-
|
173 |
if(is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
174 |
{
|
175 |
foreach(scandir($logs_dir) as $log_file)
|
176 |
if(is_file($log_file = $logs_dir."/".$log_file))
|
177 |
if(is_writable($log_file))
|
178 |
unlink($log_file);
|
179 |
-
|
180 |
@rmdir($logs_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir));
|
181 |
}
|
182 |
-
|
183 |
delete_option("ws_plugin__s2member_cache");
|
184 |
delete_option("ws_plugin__s2member_notices");
|
185 |
delete_option("ws_plugin__s2member_options");
|
@@ -187,22 +187,22 @@ if(!class_exists("c_ws_plugin__s2member_installation"))
|
|
187 |
delete_option("ws_plugin__s2member_activated_levels");
|
188 |
delete_option("ws_plugin__s2member_activated_version");
|
189 |
delete_option("ws_plugin__s2member_activated_mms_version");
|
190 |
-
|
191 |
-
if(is_multisite() && is_main_site()
|
192 |
delete_site_option("ws_plugin__s2member_options");
|
193 |
-
|
194 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
195 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_s2m_"))."%'");
|
196 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_timeout_s2m_"))."%'");
|
197 |
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
198 |
$wpdb->query("DELETE FROM `".$wpdb->usermeta."` WHERE `meta_key` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
199 |
-
|
200 |
do_action("ws_plugin__s2member_during_deactivation", get_defined_vars());
|
201 |
}
|
202 |
-
|
203 |
do_action("ws_plugin__s2member_after_deactivation", get_defined_vars());
|
204 |
-
|
205 |
-
return
|
206 |
}
|
207 |
}
|
208 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_installation"))
|
21 |
{
|
22 |
/**
|
37 |
*/
|
38 |
public static function activate($reactivation_reason = FALSE)
|
39 |
{
|
40 |
+
global /* Global database object reference. */ $wpdb;
|
41 |
+
global /* Multisite. */ $current_site, $current_blog;
|
42 |
+
|
43 |
do_action("ws_plugin__s2member_before_activation", get_defined_vars());
|
44 |
+
|
45 |
+
c_ws_plugin__s2member_roles_caps::config_roles /* Config Roles/Caps. */();
|
46 |
update_option("ws_plugin__s2member_activated_levels", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]);
|
47 |
+
|
48 |
if(!is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
49 |
if(is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir))))
|
50 |
mkdir($files_dir, 0777, true);
|
51 |
+
|
52 |
if(is_dir($files_dir) && is_writable($files_dir))
|
53 |
if(!file_exists($htaccess = $files_dir."/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_files_dir_htaccess", false, get_defined_vars()))
|
54 |
file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"]))));
|
55 |
+
|
56 |
c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess /* Handle the root `.htaccess` file as well now, for GZIP exclusions. */();
|
57 |
+
|
58 |
if(!is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
59 |
if(is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir))))
|
60 |
mkdir($logs_dir, 0777, true);
|
61 |
+
|
62 |
if(is_dir($logs_dir) && is_writable($logs_dir))
|
63 |
if(!file_exists($htaccess = $logs_dir."/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_logs_dir_htaccess", false, get_defined_vars()))
|
64 |
file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"]))));
|
65 |
+
|
66 |
(!is_array(get_option("ws_plugin__s2member_cache"))) ? update_option("ws_plugin__s2member_cache", array()) : null;
|
67 |
(!is_array(get_option("ws_plugin__s2member_notices"))) ? update_option("ws_plugin__s2member_notices", array()) : null;
|
68 |
(!is_array(get_option("ws_plugin__s2member_options"))) ? update_option("ws_plugin__s2member_options", array()) : null;
|
69 |
(!is_numeric(get_option("ws_plugin__s2member_configured"))) ? update_option("ws_plugin__s2member_configured", "0") : null;
|
70 |
+
|
71 |
+
if /* If we are re-activating. */($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"])
|
72 |
{
|
73 |
+
$v = /* Currently. */get_option("ws_plugin__s2member_activated_version");
|
74 |
+
|
75 |
+
if /* Needs to be upgraded? */(!$v || !version_compare($v, "3.2", ">="))
|
76 |
+
// Version 3.2 is where `meta_key` names were changed. They're prefixed now.
|
77 |
{
|
78 |
$like = "`meta_key` LIKE 's2member\_%' AND `meta_key` NOT LIKE '%s2member\_originating\_blog%'";
|
79 |
$wpdb->query("UPDATE `".$wpdb->usermeta."` SET `meta_key` = CONCAT('".$wpdb->prefix."', `meta_key`) WHERE ".$like);
|
80 |
}
|
81 |
+
|
82 |
+
if /* Needs to be upgraded? */(!$v || !version_compare($v, "3.2.5", ">="))
|
83 |
+
// Version 3.2.5 is where transient names were changed. They're prefixed now.
|
84 |
{
|
85 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '\_transient\_%'");
|
86 |
}
|
87 |
+
|
88 |
+
if /* Needs to be upgraded? */(!$v || !version_compare($v, "3.2.6", ">="))
|
89 |
+
// Version 3.2.6 fixed `s2member_ccaps_req` being stored empty and/or w/ one empty element in the array.
|
90 |
{
|
91 |
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
|
92 |
}
|
93 |
+
|
94 |
if(!$v || !version_compare($v, "110912", ">=") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === array("all"))
|
95 |
+
// s2Member v110912 changed the way the "all" option for Alternative Views was handled.
|
96 |
{
|
97 |
+
$notice = '<strong>IMPORTANT:</strong> This version of s2Member® changes the way your <code>Alternative View Protections</code> work. Please review your options under: <code>s2Member -› Restriction Options -› Alternative View Protections</code>.<br />';
|
98 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
99 |
}
|
100 |
+
|
101 |
$notice = '<strong>s2Member</strong> has been <strong>reactivated</strong>, with '.(($reactivation_reason === "levels") ? '<code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]).'</code> Membership Levels' : 'the latest version').'.<br />';
|
102 |
$notice .= 'You now have version '.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'. Your existing configuration remains.';
|
103 |
+
|
104 |
+
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) // No Changelog on a Multisite Blog Farm.
|
105 |
$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! :-)';
|
106 |
+
|
107 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
108 |
}
|
109 |
+
else // Otherwise (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide.
|
110 |
{
|
111 |
+
$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/Profile 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.';
|
112 |
+
|
113 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:users.php", false, false, true);
|
114 |
+
|
115 |
$notice = '<strong>s2Member</strong> v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).' has been <strong>activated</strong>. Nice work!<br />';
|
116 |
$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! :-)';
|
117 |
+
|
118 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
119 |
}
|
120 |
+
|
121 |
+
if(is_multisite() && is_main_site()) // Network activation routines.
|
122 |
{
|
123 |
$wpdb->query("INSERT INTO `".$wpdb->usermeta."` (`user_id`, `meta_key`, `meta_value`) SELECT `ID`, 's2member_originating_blog', '".esc_sql($current_site->blog_id)."' FROM `".$wpdb->users."` WHERE `ID` NOT IN (SELECT `user_id` FROM `".$wpdb->usermeta."` WHERE `meta_key` = 's2member_originating_blog')");
|
124 |
+
|
125 |
$notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'.<br />';
|
126 |
$notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
|
127 |
$notice .= 'In the Dashboard for your Main Site, see:<br />';
|
128 |
+
$notice .= '<code>s2Member -› Multisite (Config)</code>.';
|
129 |
+
|
130 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
|
131 |
+
|
132 |
update_site_option("ws_plugin__s2member_options", (array)get_option("ws_plugin__s2member_options"));
|
133 |
+
|
134 |
update_option("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
|
135 |
}
|
136 |
+
|
137 |
update_option("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION);
|
138 |
+
|
139 |
do_action("ws_plugin__s2member_after_activation", get_defined_vars());
|
140 |
+
|
141 |
+
return /* Return for uniformity. */;
|
142 |
}
|
143 |
/**
|
144 |
* Deactivation routines for s2Member.
|
150 |
*/
|
151 |
public static function deactivate()
|
152 |
{
|
153 |
+
global /* Global database object reference. */ $wpdb;
|
154 |
+
global /* Multisite. */ $current_site, $current_blog;
|
155 |
+
|
156 |
do_action("ws_plugin__s2member_before_deactivation", get_defined_vars());
|
157 |
+
|
158 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
|
159 |
{
|
160 |
+
c_ws_plugin__s2member_roles_caps::unlink_roles /* Unlink Roles/Caps. */();
|
161 |
+
|
162 |
c_ws_plugin__s2member_files::remove_no_gzip_from_root_htaccess /* Remove GZIP exclusions. */();
|
163 |
+
|
164 |
if(is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
165 |
{
|
166 |
if(file_exists($htaccess = $files_dir."/.htaccess"))
|
167 |
if(is_writable($htaccess))
|
168 |
unlink($htaccess);
|
169 |
+
|
170 |
@rmdir($files_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir));
|
171 |
}
|
172 |
+
|
173 |
if(is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
174 |
{
|
175 |
foreach(scandir($logs_dir) as $log_file)
|
176 |
if(is_file($log_file = $logs_dir."/".$log_file))
|
177 |
if(is_writable($log_file))
|
178 |
unlink($log_file);
|
179 |
+
|
180 |
@rmdir($logs_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir));
|
181 |
}
|
182 |
+
|
183 |
delete_option("ws_plugin__s2member_cache");
|
184 |
delete_option("ws_plugin__s2member_notices");
|
185 |
delete_option("ws_plugin__s2member_options");
|
187 |
delete_option("ws_plugin__s2member_activated_levels");
|
188 |
delete_option("ws_plugin__s2member_activated_version");
|
189 |
delete_option("ws_plugin__s2member_activated_mms_version");
|
190 |
+
|
191 |
+
if(is_multisite() && is_main_site() /* Site options? */)
|
192 |
delete_site_option("ws_plugin__s2member_options");
|
193 |
+
|
194 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
195 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_s2m_"))."%'");
|
196 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_timeout_s2m_"))."%'");
|
197 |
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
198 |
$wpdb->query("DELETE FROM `".$wpdb->usermeta."` WHERE `meta_key` LIKE '%".esc_sql(like_escape("s2member_"))."%'");
|
199 |
+
|
200 |
do_action("ws_plugin__s2member_during_deactivation", get_defined_vars());
|
201 |
}
|
202 |
+
|
203 |
do_action("ws_plugin__s2member_after_deactivation", get_defined_vars());
|
204 |
+
|
205 |
+
return /* Return for uniformity. */;
|
206 |
}
|
207 |
}
|
208 |
}
|
includes/classes/ip-restrictions.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
21 |
{
|
22 |
/**
|
@@ -41,84 +41,84 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
41 |
*/
|
42 |
public static function ip_restrictions_ok($ip = FALSE, $restriction = FALSE)
|
43 |
{
|
44 |
-
|
45 |
do_action("ws_plugin__s2member_before_ip_restrictions_ok", get_defined_vars());
|
46 |
-
unset
|
47 |
-
|
48 |
if(!apply_filters("ws_plugin__s2member_disable_all_ip_restrictions", false, get_defined_vars())
|
49 |
/* Also allow specific exclusions here. */ && !apply_filters("ws_plugin__s2member_disable_specific_ip_restriction", false, get_defined_vars())
|
50 |
/* And enabled by site owner? */ && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] /* And a valid ``$restriction``? */ && $restriction && is_string($restriction)
|
51 |
/* Flag indicating that we ARE processing this IP Restriction. Useful in Hooks/Filters. */ && ($processing = true))
|
52 |
{
|
53 |
$msg_503 = _x('<strong>503: Service Temporarily Unavailable</strong><br />Too many IP addresses accessing one secure area<em>!</em><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
|
54 |
-
|
55 |
$prefix = /* s2Member Transient prefix for all IP Restrictions. Allows s2Member to find these easily. */ "s2m_ipr_";
|
56 |
-
|
57 |
$transient_entries = $prefix.md5("s2member_ip_restrictions_".$restriction."_entries");
|
58 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".$restriction."_security_breach");
|
59 |
-
|
60 |
-
|
61 |
$concurrency = apply_filters("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
|
62 |
-
|
63 |
$entries = (is_array($entries = get_transient($transient_entries))) ? $entries : array();
|
64 |
-
|
65 |
-
foreach
|
66 |
-
if($_time < strtotime("-".$concurrency))
|
67 |
-
unset
|
68 |
-
|
69 |
-
$ip = ($ip && is_string($ip)) ? $ip :
|
70 |
-
$entries[$ip] =
|
71 |
set_transient($transient_entries, $entries, 2 * (strtotime("+".$concurrency) - strtotime("now")));
|
72 |
-
|
73 |
-
if
|
74 |
{
|
75 |
c_ws_plugin__s2member_no_cache::no_cache_constants(true);
|
76 |
-
|
77 |
-
status_header
|
78 |
-
wp_clear_auth_cookie
|
79 |
-
header
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars());
|
84 |
-
unset
|
85 |
-
|
86 |
-
exit
|
87 |
}
|
88 |
-
|
89 |
else if(count($entries) > $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"])
|
90 |
{
|
91 |
c_ws_plugin__s2member_no_cache::no_cache_constants(true);
|
92 |
-
|
93 |
-
set_transient
|
94 |
($transient_security_breach, 1, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"]);
|
95 |
-
|
96 |
-
status_header
|
97 |
-
wp_clear_auth_cookie
|
98 |
-
header
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars());
|
103 |
-
unset
|
104 |
-
|
105 |
-
exit
|
106 |
}
|
107 |
-
|
108 |
-
else
|
109 |
{
|
110 |
-
|
111 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars());
|
112 |
-
unset
|
113 |
-
|
114 |
return apply_filters("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars());
|
115 |
}
|
116 |
}
|
117 |
-
|
118 |
-
|
119 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars());
|
120 |
-
unset
|
121 |
-
|
122 |
return apply_filters("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars());
|
123 |
}
|
124 |
/**
|
@@ -133,11 +133,11 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
133 |
public static function specific_ip_restriction_breached_security($restriction = FALSE)
|
134 |
{
|
135 |
do_action("ws_plugin__s2member_before_specific_ip_restriction_breached_security", get_defined_vars());
|
136 |
-
|
137 |
-
$prefix =
|
138 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_security_breach");
|
139 |
$breached_security = $associated_with_security_breach = (get_transient($transient_security_breach)) ? true : false;
|
140 |
-
|
141 |
return apply_filters("ws_plugin__s2member_before_specific_ip_restriction_breached_security", $breached_security, get_defined_vars());
|
142 |
}
|
143 |
/**
|
@@ -153,19 +153,19 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
153 |
*/
|
154 |
public static function delete_reset_specific_ip_restrictions($restriction = FALSE)
|
155 |
{
|
156 |
-
global
|
157 |
-
|
158 |
do_action("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions", get_defined_vars());
|
159 |
-
|
160 |
-
$prefix
|
161 |
$transient_entries = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_entries");
|
162 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_security_breach");
|
163 |
-
|
164 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape($transient_entries))."'");
|
165 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape($transient_security_breach))."'");
|
166 |
-
|
167 |
do_action("ws_plugin__s2member_after_delete_reset_specific_ip_restrictions", get_defined_vars());
|
168 |
-
|
169 |
return apply_filters("ws_plugin__s2member_delete_reset_specific_ip_restrictions", true, get_defined_vars());
|
170 |
}
|
171 |
/**
|
@@ -181,24 +181,24 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
181 |
public static function delete_reset_specific_ip_restrictions_via_ajax()
|
182 |
{
|
183 |
do_action("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions_via_ajax", get_defined_vars());
|
184 |
-
|
185 |
-
status_header
|
186 |
-
header("Content-Type: text/plain; charset=
|
187 |
-
|
188 |
-
|
189 |
-
if
|
190 |
-
|
191 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
|
192 |
if(($nonce = $_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
|
193 |
if(wp_verify_nonce($nonce, "ws-plugin--s2member-delete-reset-specific-ip-restrictions-via-ajax"))
|
194 |
-
|
195 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))
|
196 |
if(is_string /* Must be a string here. */($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))
|
197 |
if(($restriction = trim(stripslashes($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))))
|
198 |
-
|
199 |
if(c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions($restriction))
|
200 |
-
$success =
|
201 |
-
|
202 |
exit(apply_filters("ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax", ((isset($success) && $success) ? "1" : "0"), get_defined_vars()));
|
203 |
}
|
204 |
/**
|
@@ -213,15 +213,15 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
213 |
*/
|
214 |
public static function delete_reset_all_ip_restrictions()
|
215 |
{
|
216 |
-
global
|
217 |
-
|
218 |
do_action("ws_plugin__s2member_before_delete_reset_all_ip_restrictions", get_defined_vars());
|
219 |
-
|
220 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_s2m_ipr_"))."%'");
|
221 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_timeout_s2m_ipr_"))."%'");
|
222 |
-
|
223 |
do_action("ws_plugin__s2member_after_delete_reset_all_ip_restrictions", get_defined_vars());
|
224 |
-
|
225 |
return apply_filters("ws_plugin__s2member_delete_reset_all_ip_restrictions", true, get_defined_vars());
|
226 |
}
|
227 |
/**
|
@@ -237,20 +237,20 @@ if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
|
237 |
public static function delete_reset_all_ip_restrictions_via_ajax()
|
238 |
{
|
239 |
do_action("ws_plugin__s2member_before_delete_reset_all_ip_restrictions_via_ajax", get_defined_vars());
|
240 |
-
|
241 |
-
status_header
|
242 |
-
header("Content-Type: text/plain; charset=
|
243 |
-
|
244 |
-
|
245 |
-
if
|
246 |
-
|
247 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
|
248 |
if(($nonce = $_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
|
249 |
if(wp_verify_nonce($nonce, "ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax"))
|
250 |
-
|
251 |
if(c_ws_plugin__s2member_ip_restrictions::delete_reset_all_ip_restrictions())
|
252 |
-
$success =
|
253 |
-
|
254 |
exit(apply_filters("ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax", ((isset($success) && $success) ? "1" : "0"), get_defined_vars()));
|
255 |
}
|
256 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_ip_restrictions"))
|
21 |
{
|
22 |
/**
|
41 |
*/
|
42 |
public static function ip_restrictions_ok($ip = FALSE, $restriction = FALSE)
|
43 |
{
|
44 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
45 |
do_action("ws_plugin__s2member_before_ip_restrictions_ok", get_defined_vars());
|
46 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
47 |
+
|
48 |
if(!apply_filters("ws_plugin__s2member_disable_all_ip_restrictions", false, get_defined_vars())
|
49 |
/* Also allow specific exclusions here. */ && !apply_filters("ws_plugin__s2member_disable_specific_ip_restriction", false, get_defined_vars())
|
50 |
/* And enabled by site owner? */ && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] /* And a valid ``$restriction``? */ && $restriction && is_string($restriction)
|
51 |
/* Flag indicating that we ARE processing this IP Restriction. Useful in Hooks/Filters. */ && ($processing = true))
|
52 |
{
|
53 |
$msg_503 = _x('<strong>503: Service Temporarily Unavailable</strong><br />Too many IP addresses accessing one secure area<em>!</em><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
|
54 |
+
|
55 |
$prefix = /* s2Member Transient prefix for all IP Restrictions. Allows s2Member to find these easily. */ "s2m_ipr_";
|
56 |
+
|
57 |
$transient_entries = $prefix.md5("s2member_ip_restrictions_".$restriction."_entries");
|
58 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".$restriction."_security_breach");
|
59 |
+
|
60 |
+
// If you add Filters, use a string compatible with PHP's strtotime() function.
|
61 |
$concurrency = apply_filters("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
|
62 |
+
|
63 |
$entries = (is_array($entries = get_transient($transient_entries))) ? $entries : array();
|
64 |
+
|
65 |
+
foreach /* Auto-expire entries, based on time. */($entries as $_entry => $_time)
|
66 |
+
if /* Based on time. */($_time < strtotime("-".$concurrency))
|
67 |
+
unset /* Unset this entry value. */($entries[$_entry]);
|
68 |
+
|
69 |
+
$ip = ($ip && is_string($ip)) ? $ip : /* Allow empty IPs. */ "empty";
|
70 |
+
$entries[$ip] = /* Log entry. Add IP with entry time. */ strtotime("now");
|
71 |
set_transient($transient_entries, $entries, 2 * (strtotime("+".$concurrency) - strtotime("now")));
|
72 |
+
|
73 |
+
if /* Already breached security? */(get_transient($transient_security_breach))
|
74 |
{
|
75 |
c_ws_plugin__s2member_no_cache::no_cache_constants(true);
|
76 |
+
|
77 |
+
status_header /* Send a 503 error status header; temporarily unavailable. */(503);
|
78 |
+
wp_clear_auth_cookie /* Clear authorization cookies; we need to log them out now. */();
|
79 |
+
header /* Content-Type text/html with UTF-8. */("Content-Type: text/html; charset=UTF-8");
|
80 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
81 |
+
|
82 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
83 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars());
|
84 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
85 |
+
|
86 |
+
exit /* Clean exit with 503 error message. */($msg_503);
|
87 |
}
|
88 |
+
|
89 |
else if(count($entries) > $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"])
|
90 |
{
|
91 |
c_ws_plugin__s2member_no_cache::no_cache_constants(true);
|
92 |
+
|
93 |
+
set_transient // A security breach has just occurred. We need to set this Transient now.
|
94 |
($transient_security_breach, 1, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"]);
|
95 |
+
|
96 |
+
status_header /* Send a 503 error status header; temporarily unavailable. */(503);
|
97 |
+
wp_clear_auth_cookie /* Clear authorization cookies; we need to log them out now. */();
|
98 |
+
header /* Content-Type text/html with UTF-8. */("Content-Type: text/html; charset=UTF-8");
|
99 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
100 |
+
|
101 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
102 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars());
|
103 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
104 |
+
|
105 |
+
exit /* Clean exit with 503 error message. */($msg_503);
|
106 |
}
|
107 |
+
|
108 |
+
else // OK, this looks legitimate. Apply Filters here and return true.
|
109 |
{
|
110 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
111 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars());
|
112 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
113 |
+
|
114 |
return apply_filters("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars());
|
115 |
}
|
116 |
}
|
117 |
+
|
118 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
119 |
do_action("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars());
|
120 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
121 |
+
|
122 |
return apply_filters("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars());
|
123 |
}
|
124 |
/**
|
133 |
public static function specific_ip_restriction_breached_security($restriction = FALSE)
|
134 |
{
|
135 |
do_action("ws_plugin__s2member_before_specific_ip_restriction_breached_security", get_defined_vars());
|
136 |
+
|
137 |
+
$prefix = /* s2Member Transient prefix for all IP Restrictions. */ "s2m_ipr_";
|
138 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_security_breach");
|
139 |
$breached_security = $associated_with_security_breach = (get_transient($transient_security_breach)) ? true : false;
|
140 |
+
|
141 |
return apply_filters("ws_plugin__s2member_before_specific_ip_restriction_breached_security", $breached_security, get_defined_vars());
|
142 |
}
|
143 |
/**
|
153 |
*/
|
154 |
public static function delete_reset_specific_ip_restrictions($restriction = FALSE)
|
155 |
{
|
156 |
+
global /* Need global database object. */ $wpdb;
|
157 |
+
|
158 |
do_action("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions", get_defined_vars());
|
159 |
+
|
160 |
+
$prefix /* s2Member Transient prefix for all IP Restrictions. */ = "s2m_ipr_";
|
161 |
$transient_entries = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_entries");
|
162 |
$transient_security_breach = $prefix.md5("s2member_ip_restrictions_".(string)$restriction."_security_breach");
|
163 |
+
|
164 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape($transient_entries))."'");
|
165 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(like_escape($transient_security_breach))."'");
|
166 |
+
|
167 |
do_action("ws_plugin__s2member_after_delete_reset_specific_ip_restrictions", get_defined_vars());
|
168 |
+
|
169 |
return apply_filters("ws_plugin__s2member_delete_reset_specific_ip_restrictions", true, get_defined_vars());
|
170 |
}
|
171 |
/**
|
181 |
public static function delete_reset_specific_ip_restrictions_via_ajax()
|
182 |
{
|
183 |
do_action("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions_via_ajax", get_defined_vars());
|
184 |
+
|
185 |
+
status_header /* Send a 200 OK status header. */(200);
|
186 |
+
header /* Content-Type with UTF-8. */("Content-Type: text/plain; charset=UTF-8");
|
187 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
188 |
+
|
189 |
+
if /* Check privileges. Ability to create Users? */(current_user_can("create_users"))
|
190 |
+
|
191 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
|
192 |
if(($nonce = $_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
|
193 |
if(wp_verify_nonce($nonce, "ws-plugin--s2member-delete-reset-specific-ip-restrictions-via-ajax"))
|
194 |
+
|
195 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))
|
196 |
if(is_string /* Must be a string here. */($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))
|
197 |
if(($restriction = trim(stripslashes($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))))
|
198 |
+
|
199 |
if(c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions($restriction))
|
200 |
+
$success = /* Yes, this IP Restriction was deleted/reset. */ true;
|
201 |
+
|
202 |
exit(apply_filters("ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax", ((isset($success) && $success) ? "1" : "0"), get_defined_vars()));
|
203 |
}
|
204 |
/**
|
213 |
*/
|
214 |
public static function delete_reset_all_ip_restrictions()
|
215 |
{
|
216 |
+
global /* Need global database object. */ $wpdb;
|
217 |
+
|
218 |
do_action("ws_plugin__s2member_before_delete_reset_all_ip_restrictions", get_defined_vars());
|
219 |
+
|
220 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_s2m_ipr_"))."%'");
|
221 |
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(like_escape("_transient_timeout_s2m_ipr_"))."%'");
|
222 |
+
|
223 |
do_action("ws_plugin__s2member_after_delete_reset_all_ip_restrictions", get_defined_vars());
|
224 |
+
|
225 |
return apply_filters("ws_plugin__s2member_delete_reset_all_ip_restrictions", true, get_defined_vars());
|
226 |
}
|
227 |
/**
|
237 |
public static function delete_reset_all_ip_restrictions_via_ajax()
|
238 |
{
|
239 |
do_action("ws_plugin__s2member_before_delete_reset_all_ip_restrictions_via_ajax", get_defined_vars());
|
240 |
+
|
241 |
+
status_header /* Send a 200 OK status header. */(200);
|
242 |
+
header /* Content-Type with UTF-8. */("Content-Type: text/plain; charset=UTF-8");
|
243 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
244 |
+
|
245 |
+
if /* Check privileges. Ability to create Users? */(current_user_can("create_users"))
|
246 |
+
|
247 |
if(!empty($_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
|
248 |
if(($nonce = $_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
|
249 |
if(wp_verify_nonce($nonce, "ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax"))
|
250 |
+
|
251 |
if(c_ws_plugin__s2member_ip_restrictions::delete_reset_all_ip_restrictions())
|
252 |
+
$success = /* Yes, all IP Restrictions were deleted/reset. */ true;
|
253 |
+
|
254 |
exit(apply_filters("ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax", ((isset($success) && $success) ? "1" : "0"), get_defined_vars()));
|
255 |
}
|
256 |
}
|
includes/classes/labels.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_labels"))
|
21 |
{
|
22 |
/**
|
@@ -40,13 +40,13 @@ if (!class_exists ("c_ws_plugin__s2member_labels"))
|
|
40 |
public static function config_label_translations ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_config_label_translations", get_defined_vars ());
|
43 |
-
|
44 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["apply_label_translations"])
|
45 |
add_filter ("gettext_with_context", "c_ws_plugin__s2member_labels::_label_translations", 10, 3);
|
46 |
-
|
47 |
do_action ("ws_plugin__s2member_after_config_label_translations", get_defined_vars ());
|
48 |
-
|
49 |
-
return
|
50 |
}
|
51 |
/**
|
52 |
* A sort of callback function that deals with Label translations.
|
@@ -67,14 +67,14 @@ if (!class_exists ("c_ws_plugin__s2member_labels"))
|
|
67 |
{
|
68 |
if (preg_match ("/^(Free )?Subscriber$/i", $role) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]))
|
69 |
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"];
|
70 |
-
|
71 |
else if (preg_match ("/^s2Member Level ([0-9]+)$/i", $role, $m) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"]))
|
72 |
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"];
|
73 |
-
|
74 |
$translation = apply_filters ("_ws_plugin__s2member_label_translations", $translation, get_defined_vars ());
|
75 |
}
|
76 |
-
|
77 |
-
return
|
78 |
}
|
79 |
}
|
80 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_labels"))
|
21 |
{
|
22 |
/**
|
40 |
public static function config_label_translations ()
|
41 |
{
|
42 |
do_action ("ws_plugin__s2member_before_config_label_translations", get_defined_vars ());
|
43 |
+
|
44 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["apply_label_translations"])
|
45 |
add_filter ("gettext_with_context", "c_ws_plugin__s2member_labels::_label_translations", 10, 3);
|
46 |
+
|
47 |
do_action ("ws_plugin__s2member_after_config_label_translations", get_defined_vars ());
|
48 |
+
|
49 |
+
return /* Return for uniformity. */;
|
50 |
}
|
51 |
/**
|
52 |
* A sort of callback function that deals with Label translations.
|
67 |
{
|
68 |
if (preg_match ("/^(Free )?Subscriber$/i", $role) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]))
|
69 |
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"];
|
70 |
+
|
71 |
else if (preg_match ("/^s2Member Level ([0-9]+)$/i", $role, $m) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"]))
|
72 |
$translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"];
|
73 |
+
|
74 |
$translation = apply_filters ("_ws_plugin__s2member_label_translations", $translation, get_defined_vars ());
|
75 |
}
|
76 |
+
|
77 |
+
return /* Return translation. */ $translation;
|
78 |
}
|
79 |
}
|
80 |
}
|
includes/classes/list-servers.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
21 |
{
|
22 |
/**
|
@@ -38,11 +38,11 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
|
38 |
public static function list_servers_integrated ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
|
41 |
-
|
42 |
-
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
43 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_mailchimp_list_ids"]) || !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_aweber_list_ids"]))
|
44 |
return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
|
45 |
-
|
46 |
return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
|
47 |
}
|
48 |
/**
|
@@ -66,123 +66,125 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
|
66 |
*
|
67 |
* @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
|
68 |
* @todo Add a separate option for mail debugging; or consolidate?
|
69 |
-
* @todo Integrate AWeber® API (
|
70 |
*/
|
71 |
public static function process_list_servers ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE, $double_opt_in = TRUE, $user_id = FALSE)
|
72 |
{
|
73 |
-
global
|
74 |
-
|
75 |
-
|
76 |
do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
|
77 |
-
unset
|
78 |
-
|
79 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && ($args = func_get_args ()) && $role && is_string ($role) && is_numeric ($level) && $login && is_string ($login) && is_string ($pass = (string)$pass) && $email && is_string ($email) && is_email ($email) && is_string ($fname = (string)$fname) && is_string ($lname = (string)$lname) && is_string ($ip = (string)$ip) && is_bool ($opt_in = (bool)$opt_in) && $opt_in && is_bool ($double_opt_in = (bool)$double_opt_in) && $user_id && is_numeric ($user_id) && is_object ($user = new WP_User ($user_id)) && !empty ($user->ID))
|
80 |
{
|
81 |
-
$ccaps = implode (",", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
82 |
-
|
83 |
-
$email_configs_were_on =
|
84 |
-
c_ws_plugin__s2member_email_configs::email_config_release
|
85 |
-
|
86 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
87 |
{
|
88 |
-
if
|
89 |
-
include_once dirname (dirname (__FILE__)) . "/externals/mailchimp/nc-mcapi.inc.php";
|
90 |
-
|
91 |
-
$mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true);
|
92 |
-
|
93 |
foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
|
94 |
{
|
95 |
$mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_method" => "listSubscribe");
|
96 |
-
|
97 |
-
if (($mailchimp["list"] = trim ($mailchimp_list)))
|
98 |
{
|
99 |
-
if (strpos ($mailchimp["list"], "::") !== false)
|
100 |
{
|
101 |
list ($mailchimp["list_id"], $mailchimp["interest_groups_title"], $mailchimp["interest_groups"]) = preg_split ("/\:\:/", $mailchimp["list"], 3);
|
102 |
-
|
103 |
-
if (($mailchimp["interest_groups_title"] = trim ($mailchimp["interest_groups_title"])))
|
104 |
if (($mailchimp["interest_groups"] = (trim ($mailchimp["interest_groups"])) ? preg_split ("/\|/", trim ($mailchimp["interest_groups"])) : false))
|
105 |
$mailchimp["interest_groups"] = array ("GROUPINGS" => array (array ("name" => $mailchimp["interest_groups_title"], "groups" => implode (",", $mailchimp["interest_groups"]))));
|
106 |
-
|
107 |
-
if
|
108 |
-
continue
|
109 |
}
|
110 |
-
else
|
111 |
$mailchimp["list_id"] = $mailchimp["list"];
|
112 |
-
|
113 |
$mailchimp["merge_array"] = array ("MERGE1" => $fname, "MERGE2" => $lname, "OPTIN_IP" => $ip, "OPTIN_TIME" => date ("Y-m-d H:i:s"));
|
114 |
$mailchimp["merge_array"] = ($mailchimp["interest_groups"]) ? array_merge ($mailchimp["merge_array"], $mailchimp["interest_groups"]) : $mailchimp["merge_array"];
|
115 |
$mailchimp["merge_array"] = apply_filters ( /* Deprecated. */"ws_plugin__s2member_mailchimp_array", $mailchimp["merge_array"], get_defined_vars ());
|
116 |
-
|
117 |
-
|
118 |
-
if ($mailchimp["api_response"] = $mcapi->{$mailchimp["api_method"]}($mailchimp["list_id"], $email,
|
119 |
-
($mailchimp["api_merge_array"] = apply_filters ("ws_plugin__s2member_mailchimp_merge_array", $mailchimp["merge_array"], get_defined_vars ())),
|
120 |
-
($mailchimp["api_email_type"] = apply_filters ("ws_plugin__s2member_mailchimp_email_type", "html", get_defined_vars ())),
|
121 |
-
($mailchimp["api_double_optin"] = apply_filters ("ws_plugin__s2member_mailchimp_double_optin", $double_opt_in, get_defined_vars ())),
|
122 |
-
($mailchimp["api_update_existing"] = apply_filters ("ws_plugin__s2member_mailchimp_update_existing", false, get_defined_vars ())),
|
123 |
-
($mailchimp["api_replace_interests"] = apply_filters ("ws_plugin__s2member_mailchimp_replace_interests", true, get_defined_vars ())),
|
124 |
-
($mailchimp["api_send_welcome"] = apply_filters ("ws_plugin__s2member_mailchimp_send_welcome", false, get_defined_vars ()))))
|
125 |
-
$mailchimp["api_success"] = $success = true;
|
126 |
-
$mailchimp["api_properties"] = $mcapi;
|
127 |
-
|
|
|
128 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
129 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
130 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
131 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
132 |
$log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
|
133 |
-
|
134 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
135 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
136 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
137 |
-
file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
|
138 |
}
|
139 |
}
|
140 |
}
|
141 |
-
|
142 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
143 |
{
|
144 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
|
145 |
{
|
146 |
$aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_method" => "listSubscribe");
|
147 |
-
|
148 |
-
if (($aweber["list_id"] = trim ($aweber_list)))
|
149 |
{
|
150 |
$aweber["bcc"] = apply_filters ("ws_plugin__s2member_aweber_bcc", false, get_defined_vars ());
|
151 |
$aweber["pass_inclusion"] = (apply_filters ("ws_plugin__s2member_aweber_pass_inclusion", false, get_defined_vars ()) && $pass) ? "\nPass: " . $pass : false;
|
152 |
$buyer = ($fname || $lname) ? trim ($fname . " " . $lname) : /* Must have. AWeber's PayPal Email Parser chokes on an empty value. */ ucwords (preg_replace ("/^(.+?)@.+/", "$1", $email));
|
153 |
-
|
154 |
-
if ($aweber["wp_mail_response"] = wp_mail ($aweber["list_id"] . "@aweber.com",
|
155 |
-
($aweber["wp_mail_sbj"] = apply_filters ("ws_plugin__s2member_aweber_sbj", "s2Member Subscription Request", get_defined_vars ())),
|
156 |
-
($aweber["wp_mail_msg"] = apply_filters ("ws_plugin__s2member_aweber_msg", "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nAd Tracking: s2Member-" . ((is_multisite () && !is_main_site ()) ? $current_blog->domain . $current_blog->path : $_SERVER["HTTP_HOST"]) . "\nEMail Address: " . $email . "\nBuyer: " . $buyer . "\nFull Name: " . trim ($fname . " " . $lname) . "\nFirst Name: " . $fname . "\nLast Name: " . $lname . "\nIP Address: " . $ip . "\nUser ID: " . $user_id . "\nLogin: " . $login . $aweber["pass_inclusion"] . "\nRole: " . $role . "\nLevel: " . $level . "\nCCaps: " . $ccaps . "\n - end.", get_defined_vars ()))
|
157 |
-
($aweber["wp_mail_headers"] = "From: \"" . preg_replace ("/\"/", "", trim ($fname . " " . $lname)) . "\" <" . $email . ">" . (($aweber["bcc"]) ? "\r\nBcc: " . $aweber["bcc"] : "") . "\r\nContent-Type: text/plain; charset=
|
158 |
-
$aweber["wp_mail_success"] = $success = true;
|
159 |
-
|
|
|
160 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
161 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
162 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
163 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
164 |
$log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
|
165 |
-
|
166 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
167 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
168 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
169 |
-
file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
|
170 |
}
|
171 |
}
|
172 |
}
|
173 |
-
|
174 |
-
|
175 |
do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
|
176 |
-
unset
|
177 |
-
|
178 |
-
if
|
179 |
c_ws_plugin__s2member_email_configs::email_config ();
|
180 |
}
|
181 |
-
|
182 |
-
|
183 |
do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
|
184 |
-
unset
|
185 |
-
|
186 |
return apply_filters ("ws_plugin__s2member_process_list_servers", (isset ($success) && $success), get_defined_vars ());
|
187 |
}
|
188 |
/**
|
@@ -205,103 +207,105 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
|
205 |
*
|
206 |
* @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
|
207 |
* @todo Add a separate option for mail debugging; or consolidate?
|
208 |
-
* @todo Integrate AWeber® API (
|
209 |
*/
|
210 |
public static function process_list_server_removals ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE)
|
211 |
{
|
212 |
-
global
|
213 |
-
|
214 |
-
|
215 |
do_action ("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars ());
|
216 |
-
unset
|
217 |
-
|
218 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && ($args = func_get_args ()) && $role && is_string ($role) && is_numeric ($level) && $login && is_string ($login) && is_string ($pass = (string)$pass) && $email && is_string ($email) && is_email ($email) && is_string ($fname = (string)$fname) && is_string ($lname = (string)$lname) && is_string ($ip = (string)$ip) && is_bool ($opt_out = (bool)$opt_out) && $opt_out && $user_id && is_numeric ($user_id) && is_object ($user = new WP_User ($user_id)) && !empty ($user->ID))
|
219 |
{
|
220 |
-
$ccaps = implode (",", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
221 |
-
|
222 |
-
$email_configs_were_on =
|
223 |
-
c_ws_plugin__s2member_email_configs::email_config_release
|
224 |
-
|
225 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
226 |
{
|
227 |
-
if
|
228 |
-
include_once dirname (dirname (__FILE__)) . "/externals/mailchimp/nc-mcapi.inc.php";
|
229 |
-
|
230 |
-
$mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true);
|
231 |
-
|
232 |
foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
|
233 |
{
|
234 |
$mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_removal_method" => "listUnsubscribe");
|
235 |
-
|
236 |
-
if (($mailchimp["list_id"] = trim (preg_replace ("/\:\:.*$/", "", $mailchimp_list))))
|
237 |
{
|
238 |
-
if ($mailchimp["api_removal_response"] = $mcapi->{$mailchimp["api_removal_method"]}($mailchimp["list_id"], $email,
|
239 |
-
($mailchimp["api_removal_delete_member"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars ())),
|
240 |
-
($mailchimp["api_removal_send_goodbye"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars ())),
|
241 |
-
($mailchimp["api_removal_send_notify"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars ()))))
|
242 |
-
$mailchimp["api_removal_success"] = $removal_success = true;
|
243 |
-
$mailchimp["api_removal_properties"] = $mcapi;
|
244 |
-
|
|
|
245 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
246 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
247 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
248 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
249 |
$log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
|
250 |
-
|
251 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
252 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
253 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
254 |
-
file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
|
255 |
}
|
256 |
}
|
257 |
}
|
258 |
-
|
259 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
260 |
{
|
261 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
|
262 |
{
|
263 |
$aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_removal_method" => "listUnsubscribe");
|
264 |
-
|
265 |
-
if (($aweber["list_id"] = trim ($aweber_list)))
|
266 |
{
|
267 |
$aweber["removal_bcc"] = apply_filters ("ws_plugin__s2member_aweber_removal_bcc", false, get_defined_vars ());
|
268 |
-
|
269 |
-
c_ws_plugin__s2member_email_configs::email_config ();
|
270 |
-
The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
|
271 |
-
|
272 |
-
if ($aweber["wp_mail_removal_response"] = wp_mail ($aweber["list_id"] . "@aweber.com",
|
273 |
-
($aweber["wp_mail_removal_sbj"] = apply_filters ("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member#" . $aweber["list_id"], get_defined_vars ())),
|
274 |
-
($aweber["wp_mail_removal_msg"] = "REMOVE"), ($aweber["wp_mail_removal_headers"] = "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">" . (($aweber["removal_bcc"]) ? "\r\nBcc: " . $aweber["removal_bcc"] : "") . "\r\nContent-Type: text/plain; charset=
|
275 |
-
$aweber["wp_mail_removal_success"] = $removal_success = true;
|
276 |
-
|
277 |
-
c_ws_plugin__s2member_email_configs::email_config_release
|
278 |
-
|
|
|
279 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
280 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
281 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
282 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
283 |
$log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
|
284 |
-
|
285 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
286 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
287 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
288 |
-
file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
|
289 |
}
|
290 |
}
|
291 |
}
|
292 |
-
|
293 |
-
|
294 |
do_action ("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars ());
|
295 |
-
unset
|
296 |
-
|
297 |
-
if
|
298 |
c_ws_plugin__s2member_email_configs::email_config ();
|
299 |
}
|
300 |
-
|
301 |
-
|
302 |
do_action ("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars ());
|
303 |
-
unset
|
304 |
-
|
305 |
return apply_filters ("ws_plugin__s2member_process_list_server_removals", (isset ($removal_success) && $removal_success), get_defined_vars ());
|
306 |
}
|
307 |
/**
|
@@ -318,57 +322,57 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
|
318 |
* @param int|str $user_id Required. A WordPress® User ID, numeric string or integer.
|
319 |
* @param array $vars Required. An array of defined variables passed by the calling Hook.
|
320 |
* @param str $event Required. A specific event that triggered this call from the Action Hook.
|
321 |
-
* @param str $event_spec Required. A specific event specification *(
|
322 |
-
* @param str $mod_new_role Required if ``$event_spec === "modification"`` (
|
323 |
* @param str $mod_new_user Optional. If ``$event_spec === "modification"``, the new User object with current details.
|
324 |
* @param str $mod_old_user Optional. If ``$event_spec === "modification"``, the old/previous User obj with old details.
|
325 |
* @return null This function does not have a return value.
|
326 |
*/
|
327 |
public static function auto_process_list_server_removals ($user_id = FALSE, $vars = FALSE, $event = FALSE, $event_spec = FALSE, $mod_new_role = FALSE, $mod_new_user = FALSE, $mod_old_user = FALSE)
|
328 |
{
|
329 |
-
global
|
330 |
-
static $auto_processed =
|
331 |
-
|
332 |
-
|
333 |
do_action ("ws_plugin__s2member_before_auto_process_list_server_removals", get_defined_vars ());
|
334 |
-
unset
|
335 |
-
|
336 |
$custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"], "/^", "$/i");
|
337 |
-
|
338 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && $user_id && is_numeric ($user_id) && !in_array ($user_id, $auto_processed) && is_array ($vars) && is_string ($event = (string)$event) && is_string ($event_spec = (string)$event_spec) && (c_ws_plugin__s2member_utils_arrays::in_regex_array ($event, $custom_reg_auto_op_outs) || c_ws_plugin__s2member_utils_arrays::in_regex_array ($event_spec, $custom_reg_auto_op_outs)) && is_object ($user = $_user = new WP_User ($user_id)) && !empty ($user->ID))
|
339 |
{
|
340 |
-
$mod_new_role = ($event_spec === "modification" && $mod_new_role && is_string ($mod_new_role)) ? $mod_new_role : /* Might be empty (
|
341 |
$mod_new_user = ($event_spec === "modification" && $mod_new_user && is_object ($mod_new_user) && !empty ($mod_new_user->ID) && $mod_new_user->ID === $_user->ID) ? $mod_new_user : false;
|
342 |
$mod_old_user = ($event_spec === "modification" && $mod_old_user && is_object ($mod_old_user) && !empty ($mod_old_user->ID) && $mod_old_user->ID === $_user->ID) ? $mod_old_user : false;
|
343 |
-
|
344 |
-
$user = ($event_spec === "modification" && $mod_old_user) ? $mod_old_user : $_user;
|
345 |
-
|
346 |
-
if (($event_spec !== "modification" || ($event_spec === "modification" && /* Might be empty (
|
347 |
{
|
348 |
$removed = c_ws_plugin__s2member_list_servers::process_list_server_removals (c_ws_plugin__s2member_user_access::user_access_role ($user), c_ws_plugin__s2member_user_access::user_access_level ($user), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, $user->ID);
|
349 |
-
|
350 |
if ($event_spec === "modification" && $mod_new_role && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "2" || ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "1" && $removed)) /* Transitoning User/Member to different list(s)? */)
|
351 |
{
|
352 |
-
$user = ($event_spec === "modification" && $mod_new_user) ? $mod_new_user : $_user;
|
353 |
-
|
354 |
$transitioned = c_ws_plugin__s2member_list_servers::process_list_servers ($mod_new_role, c_ws_plugin__s2member_user_access::user_access_role_to_level ($mod_new_role), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, (($removed) ? false : true), $user->ID);
|
355 |
-
|
356 |
-
|
357 |
do_action ("ws_plugin__s2member_during_auto_process_list_server_removal_transitions", get_defined_vars ());
|
358 |
-
unset
|
359 |
}
|
360 |
-
|
361 |
-
|
362 |
do_action ("ws_plugin__s2member_during_auto_process_list_server_removals", get_defined_vars ());
|
363 |
-
unset
|
364 |
}
|
365 |
}
|
366 |
-
|
367 |
-
|
368 |
do_action ("ws_plugin__s2member_after_auto_process_list_server_removals", get_defined_vars ());
|
369 |
-
unset
|
370 |
-
|
371 |
-
return
|
372 |
}
|
373 |
}
|
374 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_list_servers"))
|
21 |
{
|
22 |
/**
|
38 |
public static function list_servers_integrated ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
|
41 |
+
|
42 |
+
for /* Go through each Level; looking for a configured list. */ ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
43 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_mailchimp_list_ids"]) || !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_aweber_list_ids"]))
|
44 |
return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
|
45 |
+
|
46 |
return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
|
47 |
}
|
48 |
/**
|
66 |
*
|
67 |
* @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
|
68 |
* @todo Add a separate option for mail debugging; or consolidate?
|
69 |
+
* @todo Integrate AWeber® API (much like the MailChimp® API).
|
70 |
*/
|
71 |
public static function process_list_servers ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE, $double_opt_in = TRUE, $user_id = FALSE)
|
72 |
{
|
73 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
74 |
+
|
75 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
76 |
do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
|
77 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
78 |
+
|
79 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && ($args = func_get_args ()) && $role && is_string ($role) && is_numeric ($level) && $login && is_string ($login) && is_string ($pass = (string)$pass) && $email && is_string ($email) && is_email ($email) && is_string ($fname = (string)$fname) && is_string ($lname = (string)$lname) && is_string ($ip = (string)$ip) && is_bool ($opt_in = (bool)$opt_in) && $opt_in && is_bool ($double_opt_in = (bool)$double_opt_in) && $user_id && is_numeric ($user_id) && is_object ($user = new WP_User ($user_id)) && !empty ($user->ID))
|
80 |
{
|
81 |
+
$ccaps = /* Get Custom Capabilities. */ implode (",", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
82 |
+
|
83 |
+
$email_configs_were_on = /* s2Member Filters enabled? */ c_ws_plugin__s2member_email_configs::email_config_status ();
|
84 |
+
c_ws_plugin__s2member_email_configs::email_config_release /* Release s2Member Filters before we begin this routine. */ ();
|
85 |
+
|
86 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
87 |
{
|
88 |
+
if /* Include the MailChimp® API Class here. */ (!class_exists ("NC_MCAPI"))
|
89 |
+
include_once /* MailChimp® API (no-conflict version). */ dirname (dirname (__FILE__)) . "/externals/mailchimp/nc-mcapi.inc.php";
|
90 |
+
|
91 |
+
$mcapi = /* MailChimp® API (no-conflict). */ new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true);
|
92 |
+
|
93 |
foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
|
94 |
{
|
95 |
$mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_method" => "listSubscribe");
|
96 |
+
|
97 |
+
if /* Trim this up. NO trailing white space. */ (($mailchimp["list"] = trim ($mailchimp_list)))
|
98 |
{
|
99 |
+
if /* Also contains Interest Groups? */ (strpos ($mailchimp["list"], "::") !== false)
|
100 |
{
|
101 |
list ($mailchimp["list_id"], $mailchimp["interest_groups_title"], $mailchimp["interest_groups"]) = preg_split ("/\:\:/", $mailchimp["list"], 3);
|
102 |
+
|
103 |
+
if /* This is a title configured by the list master. */ (($mailchimp["interest_groups_title"] = trim ($mailchimp["interest_groups_title"])))
|
104 |
if (($mailchimp["interest_groups"] = (trim ($mailchimp["interest_groups"])) ? preg_split ("/\|/", trim ($mailchimp["interest_groups"])) : false))
|
105 |
$mailchimp["interest_groups"] = array ("GROUPINGS" => array (array ("name" => $mailchimp["interest_groups_title"], "groups" => implode (",", $mailchimp["interest_groups"]))));
|
106 |
+
|
107 |
+
if /* Need to double-check this. If empty, skip over this entry. */ (empty ($mailchimp["list_id"]))
|
108 |
+
continue /* Continue to next List, if there is one. */;
|
109 |
}
|
110 |
+
else // Else, it's just a List ID.
|
111 |
$mailchimp["list_id"] = $mailchimp["list"];
|
112 |
+
|
113 |
$mailchimp["merge_array"] = array ("MERGE1" => $fname, "MERGE2" => $lname, "OPTIN_IP" => $ip, "OPTIN_TIME" => date ("Y-m-d H:i:s"));
|
114 |
$mailchimp["merge_array"] = ($mailchimp["interest_groups"]) ? array_merge ($mailchimp["merge_array"], $mailchimp["interest_groups"]) : $mailchimp["merge_array"];
|
115 |
$mailchimp["merge_array"] = apply_filters ( /* Deprecated. */"ws_plugin__s2member_mailchimp_array", $mailchimp["merge_array"], get_defined_vars ());
|
116 |
+
// Filter: `ws_plugin__s2member_mailchimp_array` deprecated in v110523. Please use Filter: `ws_plugin__s2member_mailchimp_merge_array`.
|
117 |
+
|
118 |
+
if ($mailchimp["api_response"] = $mcapi->{$mailchimp["api_method"]}($mailchimp["list_id"], $email, // See: `http://apidocs.mailchimp.com/` for full details.
|
119 |
+
($mailchimp["api_merge_array"] = apply_filters ("ws_plugin__s2member_mailchimp_merge_array", $mailchimp["merge_array"], get_defined_vars ())), // Configured merge array above.
|
120 |
+
($mailchimp["api_email_type"] = apply_filters ("ws_plugin__s2member_mailchimp_email_type", "html", get_defined_vars ())), // Type of email to receive (i.e. html,text,mobile).
|
121 |
+
($mailchimp["api_double_optin"] = apply_filters ("ws_plugin__s2member_mailchimp_double_optin", $double_opt_in, get_defined_vars ())), // Abuse of this may cause account suspension.
|
122 |
+
($mailchimp["api_update_existing"] = apply_filters ("ws_plugin__s2member_mailchimp_update_existing", false, get_defined_vars ())), // Existing subscribers should be updated with this?
|
123 |
+
($mailchimp["api_replace_interests"] = apply_filters ("ws_plugin__s2member_mailchimp_replace_interests", true, get_defined_vars ())), // Replace interest groups? (only if provided).
|
124 |
+
($mailchimp["api_send_welcome"] = apply_filters ("ws_plugin__s2member_mailchimp_send_welcome", false, get_defined_vars ())))) // See documentation. This is a weird option.
|
125 |
+
$mailchimp["api_success"] = $success = true; // Flag indicating that we DO have a successful processing of a new List; affects the function's overall return value.
|
126 |
+
$mailchimp["api_properties"] = $mcapi; // Include API instance too; as it contains some additional information after each method is processed (need this in the logs).
|
127 |
+
|
128 |
+
$logt = c_ws_plugin__s2member_utilities::time_details ();
|
129 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
130 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
131 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
132 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
133 |
$log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
|
134 |
+
|
135 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
136 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
137 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
138 |
+
file_put_contents ($logs_dir . "/" . $log2, "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
|
139 |
}
|
140 |
}
|
141 |
}
|
142 |
+
|
143 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
144 |
{
|
145 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
|
146 |
{
|
147 |
$aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_method" => "listSubscribe");
|
148 |
+
|
149 |
+
if /* Trim this up. NO trailing white space. */ (($aweber["list_id"] = trim ($aweber_list)))
|
150 |
{
|
151 |
$aweber["bcc"] = apply_filters ("ws_plugin__s2member_aweber_bcc", false, get_defined_vars ());
|
152 |
$aweber["pass_inclusion"] = (apply_filters ("ws_plugin__s2member_aweber_pass_inclusion", false, get_defined_vars ()) && $pass) ? "\nPass: " . $pass : false;
|
153 |
$buyer = ($fname || $lname) ? trim ($fname . " " . $lname) : /* Must have. AWeber's PayPal Email Parser chokes on an empty value. */ ucwords (preg_replace ("/^(.+?)@.+/", "$1", $email));
|
154 |
+
|
155 |
+
if ($aweber["wp_mail_response"] = wp_mail ($aweber["list_id"] . "@aweber.com", // AWeber® List ID converts to email address @aweber.com.
|
156 |
+
($aweber["wp_mail_sbj"] = apply_filters ("ws_plugin__s2member_aweber_sbj", "s2Member Subscription Request", get_defined_vars ())), // These Filters make it possible to customize these emails.
|
157 |
+
($aweber["wp_mail_msg"] = apply_filters ("ws_plugin__s2member_aweber_msg", "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nAd Tracking: s2Member-" . ((is_multisite () && !is_main_site ()) ? $current_blog->domain . $current_blog->path : $_SERVER["HTTP_HOST"]) . "\nEMail Address: " . $email . "\nBuyer: " . $buyer . "\nFull Name: " . trim ($fname . " " . $lname) . "\nFirst Name: " . $fname . "\nLast Name: " . $lname . "\nIP Address: " . $ip . "\nUser ID: " . $user_id . "\nLogin: " . $login . $aweber["pass_inclusion"] . "\nRole: " . $role . "\nLevel: " . $level . "\nCCaps: " . $ccaps . "\n - end.", get_defined_vars ())),
|
158 |
+
($aweber["wp_mail_headers"] = "From: \"" . preg_replace ("/\"/", "", trim ($fname . " " . $lname)) . "\" <" . $email . ">" . (($aweber["bcc"]) ? "\r\nBcc: " . $aweber["bcc"] : "") . "\r\nContent-Type: text/plain; charset=UTF-8")))
|
159 |
+
$aweber["wp_mail_success"] = $success = true; // Flag indicating that we DO have a successful processing of a new List; affects the function's overall return value.
|
160 |
+
|
161 |
+
$logt = c_ws_plugin__s2member_utilities::time_details ();
|
162 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
163 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
164 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
165 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
166 |
$log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
|
167 |
+
|
168 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
169 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
170 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
171 |
+
file_put_contents ($logs_dir . "/" . $log2, "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
|
172 |
}
|
173 |
}
|
174 |
}
|
175 |
+
|
176 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
177 |
do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
|
178 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
179 |
+
|
180 |
+
if /* Back on? */ ($email_configs_were_on)
|
181 |
c_ws_plugin__s2member_email_configs::email_config ();
|
182 |
}
|
183 |
+
|
184 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
185 |
do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
|
186 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
187 |
+
|
188 |
return apply_filters ("ws_plugin__s2member_process_list_servers", (isset ($success) && $success), get_defined_vars ());
|
189 |
}
|
190 |
/**
|
207 |
*
|
208 |
* @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
|
209 |
* @todo Add a separate option for mail debugging; or consolidate?
|
210 |
+
* @todo Integrate AWeber® API (much like the MailChimp® API).
|
211 |
*/
|
212 |
public static function process_list_server_removals ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE)
|
213 |
{
|
214 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
215 |
+
|
216 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
217 |
do_action ("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars ());
|
218 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
219 |
+
|
220 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && ($args = func_get_args ()) && $role && is_string ($role) && is_numeric ($level) && $login && is_string ($login) && is_string ($pass = (string)$pass) && $email && is_string ($email) && is_email ($email) && is_string ($fname = (string)$fname) && is_string ($lname = (string)$lname) && is_string ($ip = (string)$ip) && is_bool ($opt_out = (bool)$opt_out) && $opt_out && $user_id && is_numeric ($user_id) && is_object ($user = new WP_User ($user_id)) && !empty ($user->ID))
|
221 |
{
|
222 |
+
$ccaps = /* Get Custom Capabilities. */ implode (",", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
223 |
+
|
224 |
+
$email_configs_were_on = /* s2Member Filters enabled? */ c_ws_plugin__s2member_email_configs::email_config_status ();
|
225 |
+
c_ws_plugin__s2member_email_configs::email_config_release /* Release s2Member Filters before we begin this routine. */ ();
|
226 |
+
|
227 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
|
228 |
{
|
229 |
+
if /* Include the MailChimp® API Class here. */ (!class_exists ("NC_MCAPI"))
|
230 |
+
include_once /* MailChimp® API (no-conflict version). */ dirname (dirname (__FILE__)) . "/externals/mailchimp/nc-mcapi.inc.php";
|
231 |
+
|
232 |
+
$mcapi = /* MailChimp® API (no-conflict). */ new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true);
|
233 |
+
|
234 |
foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
|
235 |
{
|
236 |
$mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_removal_method" => "listUnsubscribe");
|
237 |
+
|
238 |
+
if /* Trim & strip groups. */ (($mailchimp["list_id"] = trim (preg_replace ("/\:\:.*$/", "", $mailchimp_list))))
|
239 |
{
|
240 |
+
if ($mailchimp["api_removal_response"] = $mcapi->{$mailchimp["api_removal_method"]}($mailchimp["list_id"], $email, // See: `http://apidocs.mailchimp.com/`.
|
241 |
+
($mailchimp["api_removal_delete_member"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars ())), // Completely delete?
|
242 |
+
($mailchimp["api_removal_send_goodbye"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars ())), // Send goodbye letter?
|
243 |
+
($mailchimp["api_removal_send_notify"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars ())))) // Send notification?
|
244 |
+
$mailchimp["api_removal_success"] = $removal_success = true; // Flag indicating that we DO have a successful removal; affects the function's overall return value.
|
245 |
+
$mailchimp["api_removal_properties"] = $mcapi; // Include API instance too; as it contains some additional information after each method is processed (need this in the logs).
|
246 |
+
|
247 |
+
$logt = c_ws_plugin__s2member_utilities::time_details ();
|
248 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
249 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
250 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
251 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
252 |
$log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
|
253 |
+
|
254 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
255 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
256 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
257 |
+
file_put_contents ($logs_dir . "/" . $log2, "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
|
258 |
}
|
259 |
}
|
260 |
}
|
261 |
+
|
262 |
if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
|
263 |
{
|
264 |
foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
|
265 |
{
|
266 |
$aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_removal_method" => "listUnsubscribe");
|
267 |
+
|
268 |
+
if /* Trim this up. NO trailing white space. */ (($aweber["list_id"] = trim ($aweber_list)))
|
269 |
{
|
270 |
$aweber["removal_bcc"] = apply_filters ("ws_plugin__s2member_aweber_removal_bcc", false, get_defined_vars ());
|
271 |
+
|
272 |
+
c_ws_plugin__s2member_email_configs::email_config (); // Email configs MUST be ON for removal requests.
|
273 |
+
// The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
|
274 |
+
|
275 |
+
if ($aweber["wp_mail_removal_response"] = wp_mail ($aweber["list_id"] . "@aweber.com", // AWeber® List ID converts to email address @aweber.com.
|
276 |
+
($aweber["wp_mail_removal_sbj"] = apply_filters ("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member#" . $aweber["list_id"], get_defined_vars ())), // Bug fix. AWeber® does not like dots (possibly other chars) in the Ad Tracking field. Now using just: `s2Member`.
|
277 |
+
($aweber["wp_mail_removal_msg"] = "REMOVE"), ($aweber["wp_mail_removal_headers"] = "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">" . (($aweber["removal_bcc"]) ? "\r\nBcc: " . $aweber["removal_bcc"] : "") . "\r\nContent-Type: text/plain; charset=UTF-8")))
|
278 |
+
$aweber["wp_mail_removal_success"] = $removal_success = true; // Flag indicating that we DO have a successful removal; affects the function's overall return value.
|
279 |
+
|
280 |
+
c_ws_plugin__s2member_email_configs::email_config_release /* Release. */ ();
|
281 |
+
|
282 |
+
$logt = c_ws_plugin__s2member_utilities::time_details ();
|
283 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
284 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
285 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
286 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
287 |
$log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
|
288 |
+
|
289 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
290 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
291 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
292 |
+
file_put_contents ($logs_dir . "/" . $log2, "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
|
293 |
}
|
294 |
}
|
295 |
}
|
296 |
+
|
297 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
298 |
do_action ("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars ());
|
299 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
300 |
+
|
301 |
+
if /* Back on? */ ($email_configs_were_on)
|
302 |
c_ws_plugin__s2member_email_configs::email_config ();
|
303 |
}
|
304 |
+
|
305 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
306 |
do_action ("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars ());
|
307 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
308 |
+
|
309 |
return apply_filters ("ws_plugin__s2member_process_list_server_removals", (isset ($removal_success) && $removal_success), get_defined_vars ());
|
310 |
}
|
311 |
/**
|
322 |
* @param int|str $user_id Required. A WordPress® User ID, numeric string or integer.
|
323 |
* @param array $vars Required. An array of defined variables passed by the calling Hook.
|
324 |
* @param str $event Required. A specific event that triggered this call from the Action Hook.
|
325 |
+
* @param str $event_spec Required. A specific event specification *(a broader classification)*.
|
326 |
+
* @param str $mod_new_role Required if ``$event_spec === "modification"`` (but can be empty). Role the User is being modified to.
|
327 |
* @param str $mod_new_user Optional. If ``$event_spec === "modification"``, the new User object with current details.
|
328 |
* @param str $mod_old_user Optional. If ``$event_spec === "modification"``, the old/previous User obj with old details.
|
329 |
* @return null This function does not have a return value.
|
330 |
*/
|
331 |
public static function auto_process_list_server_removals ($user_id = FALSE, $vars = FALSE, $event = FALSE, $event_spec = FALSE, $mod_new_role = FALSE, $mod_new_user = FALSE, $mod_old_user = FALSE)
|
332 |
{
|
333 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
334 |
+
static $auto_processed = /* Process ONE time for each User. */ array ();
|
335 |
+
|
336 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
337 |
do_action ("ws_plugin__s2member_before_auto_process_list_server_removals", get_defined_vars ());
|
338 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
339 |
+
|
340 |
$custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"], "/^", "$/i");
|
341 |
+
|
342 |
if (c_ws_plugin__s2member_list_servers::list_servers_integrated () && $user_id && is_numeric ($user_id) && !in_array ($user_id, $auto_processed) && is_array ($vars) && is_string ($event = (string)$event) && is_string ($event_spec = (string)$event_spec) && (c_ws_plugin__s2member_utils_arrays::in_regex_array ($event, $custom_reg_auto_op_outs) || c_ws_plugin__s2member_utils_arrays::in_regex_array ($event_spec, $custom_reg_auto_op_outs)) && is_object ($user = $_user = new WP_User ($user_id)) && !empty ($user->ID))
|
343 |
{
|
344 |
+
$mod_new_role = ($event_spec === "modification" && $mod_new_role && is_string ($mod_new_role)) ? $mod_new_role : /* Might be empty (i.e. they now have NO Role). */ false;
|
345 |
$mod_new_user = ($event_spec === "modification" && $mod_new_user && is_object ($mod_new_user) && !empty ($mod_new_user->ID) && $mod_new_user->ID === $_user->ID) ? $mod_new_user : false;
|
346 |
$mod_old_user = ($event_spec === "modification" && $mod_old_user && is_object ($mod_old_user) && !empty ($mod_old_user->ID) && $mod_old_user->ID === $_user->ID) ? $mod_old_user : false;
|
347 |
+
|
348 |
+
$user = ($event_spec === "modification" && $mod_old_user) ? $mod_old_user : $_user; // Now, should we switch over to the old/previous User object ``$mod_old_user`` here? Or, should we use the one pulled by this routine with the User's ID?
|
349 |
+
|
350 |
+
if (($event_spec !== "modification" || ($event_spec === "modification" && /* Might be empty (i.e. they now have NO Role). */ (string)$mod_new_role !== c_ws_plugin__s2member_user_access::user_access_role ($user) && strtotime ($user->user_registered) < strtotime ("-10 seconds") && ($event !== "user-role-change" || ($event === "user-role-change" && !empty ($vars["_p"]["ws_plugin__s2member_custom_reg_auto_opt_out_transitions"]))))) && ($auto_processed[$user->ID] = true))
|
351 |
{
|
352 |
$removed = c_ws_plugin__s2member_list_servers::process_list_server_removals (c_ws_plugin__s2member_user_access::user_access_role ($user), c_ws_plugin__s2member_user_access::user_access_level ($user), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, $user->ID);
|
353 |
+
|
354 |
if ($event_spec === "modification" && $mod_new_role && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "2" || ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "1" && $removed)) /* Transitoning User/Member to different list(s)? */)
|
355 |
{
|
356 |
+
$user = ($event_spec === "modification" && $mod_new_user) ? $mod_new_user : $_user; // Now, should we switch over to a new/current User object ``$mod_new_user`` here? (which may contain newly updated details). Or, should we simply use the User object pulled by this routine with the User's ID?
|
357 |
+
|
358 |
$transitioned = c_ws_plugin__s2member_list_servers::process_list_servers ($mod_new_role, c_ws_plugin__s2member_user_access::user_access_role_to_level ($mod_new_role), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, (($removed) ? false : true), $user->ID);
|
359 |
+
|
360 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
361 |
do_action ("ws_plugin__s2member_during_auto_process_list_server_removal_transitions", get_defined_vars ());
|
362 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
363 |
}
|
364 |
+
|
365 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
366 |
do_action ("ws_plugin__s2member_during_auto_process_list_server_removals", get_defined_vars ());
|
367 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
368 |
}
|
369 |
}
|
370 |
+
|
371 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
372 |
do_action ("ws_plugin__s2member_after_auto_process_list_server_removals", get_defined_vars ());
|
373 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
374 |
+
|
375 |
+
return /* Return for uniformity. */;
|
376 |
}
|
377 |
}
|
378 |
}
|
includes/classes/login-customizations.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
21 |
{
|
22 |
/**
|
@@ -40,10 +40,13 @@ if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
|
40 |
*/
|
41 |
public static function login_header_url($url = FALSE)
|
42 |
{
|
|
|
|
|
|
|
43 |
do_action("ws_plugin__s2member_before_login_header_url", get_defined_vars());
|
44 |
-
|
45 |
$url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_url"];
|
46 |
-
|
47 |
return apply_filters("ws_plugin__s2member_login_header_url", $url, get_defined_vars());
|
48 |
}
|
49 |
/**
|
@@ -59,10 +62,13 @@ if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
|
59 |
*/
|
60 |
public static function login_header_title($title = FALSE)
|
61 |
{
|
|
|
|
|
|
|
62 |
do_action("ws_plugin__s2member_before_login_header_title", get_defined_vars());
|
63 |
-
|
64 |
$title = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_title"];
|
65 |
-
|
66 |
return apply_filters("ws_plugin__s2member_login_header_title", $title, get_defined_vars());
|
67 |
}
|
68 |
/**
|
@@ -77,71 +83,74 @@ if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
|
77 |
*/
|
78 |
public static function login_header_styles()
|
79 |
{
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
84 |
do_action("ws_plugin__s2member_before_login_header_styles", get_defined_vars());
|
85 |
-
unset
|
86 |
-
|
87 |
-
$a[] =
|
88 |
$i = apply_filters("ws_plugin__s2member_login_header_styles_important", " !important", get_defined_vars());
|
89 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array_after_open", $a, get_defined_vars());
|
90 |
-
|
91 |
-
$a[] = 'html, body { border:0'.$i.'; background:none'.$i.'; }';
|
92 |
$a[] = 'html { background-color:#'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"].$i.'; }';
|
93 |
$a[] = 'html { background-image:url('.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"].')'.$i.'; }';
|
94 |
$a[] = 'html { background-repeat:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"].$i.'; }';
|
95 |
-
|
96 |
$a[] = 'body, body * { font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_size"].$i.'; }';
|
97 |
$a[] = 'body, body * { font-family:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_family"].$i.'; }';
|
98 |
-
|
99 |
$a[] = 'div#login { width:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"].'px'.$i.'; }';
|
100 |
$a[] = 'div#login h1 a { background:url('.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"].') no-repeat top center'.$i.'; background-size:auto'.$i.'; }';
|
101 |
$a[] = 'div#login h1 a { display:block'.$i.'; width:100%'.$i.'; height:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_height"].'px'.$i.'; }';
|
102 |
-
|
103 |
$a[] = 'div#login form { -moz-box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; -webkit-box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; }';
|
104 |
-
|
105 |
$a[] = 'div#login p#nav, div#login p#nav a, div#login p#nav a:hover, div#login p#nav a:active, div#login p#nav a:focus { color:#'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"].$i.'; text-shadow:1px 1px 3px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"].$i.'; }';
|
106 |
$a[] = 'div#login p#backtoblog, div#login p#backtoblog a, div#login p#backtoblog a:hover, div#login p#backtoblog a:active, div#login 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.'; }';
|
107 |
-
|
108 |
-
$a[] = 'div#login form p { margin:2px 0 16px 0'.$i.'; }';
|
109 |
$a[] = 'div#login form input[type="text"], div#login form input[type="email"], div#login form input[type="password"], div#login form textarea, div#login form select { font-weight:normal'.$i.'; color:#333333'.$i.'; background:none repeat scroll 0 0 #FBFBFB'.$i.'; border:1px solid #E5E5E5'.$i.'; font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"].$i.'; margin:0'.$i.'; padding:3px'.$i.'; -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
110 |
$a[] = 'div#login form select { width:99.5%'.$i.' !ie<8; } div#login form select > option { font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"].$i.'; }';
|
111 |
$a[] = 'div#login form label { cursor:pointer'.$i.'; } div#login form label.ws-plugin--s2member-custom-reg-field-op-l { opacity:0.7'.$i.'; font-size:90%'.$i.'; vertical-align:middle'.$i.'; }';
|
112 |
$a[] = 'div#login form input[type="checkbox"], div#login form input[type="radio"] { margin:0 3px 0 0'.$i.'; vertical-align:middle'.$i.'; }';
|
113 |
$a[] = 'div#login form input#ws-plugin--s2member-custom-reg-field-user-pass2[type="password"] { margin-top:5px'.$i.'; }';
|
114 |
-
|
115 |
$a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section { margin:2px 0 16px 0'.$i.'; border:0'.$i.'; height:1px'.$i.'; line-height:1px'.$i.'; background:#CCCCCC'.$i.'; }';
|
116 |
$a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section-title { margin:2px 0 16px 0'.$i.'; border:0 solid #CCCCCC'.$i.'; border-width:0 0 1px 0'.$i.'; padding:0 0 10px 0'.$i.'; font-size:110%'.$i.'; }';
|
117 |
-
|
118 |
$a[] = 'div#login form input[type="submit"], div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#666666'.$i.'; text-shadow:2px 2px 5px #EEEEEE'.$i.'; border:1px solid #999999'.$i.'; background:#FBFBFB'.$i.';'.((version_compare(get_bloginfo("version"), "3.5", "<")) ? ' padding:5px'.$i.';' : '').' -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; }';
|
119 |
$a[] = 'div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#000000'.$i.'; text-shadow:2px 2px 5px #CCCCCC'.$i.'; border-color:#000000'.$i.'; }';
|
120 |
$a[] = 'div#login form#registerform { padding-bottom:16px'.$i.'; } div#login form#registerform p.submit { float:none'.$i.'; margin-top:-10px'.$i.'; } div#login form#registerform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
121 |
$a[] = 'div#login form#lostpasswordform { padding-bottom:16px'.$i.'; } div#login form#lostpasswordform p.submit { float:none'.$i.'; } div#login form#lostpasswordform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
122 |
-
|
123 |
$a[] = 'div.ws-plugin--s2member-password-strength { margin-top:3px'.$i.'; font-color:#000000'.$i.'; background-color:#EEEEEE'.$i.'; padding:3px'.$i.'; -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; } div.ws-plugin--s2member-password-strength-short { background-color:#FFA0A0'.$i.'; } div.ws-plugin--s2member-password-strength-bad { background-color:#FFB78C'.$i.'; } div.ws-plugin--s2member-password-strength-good { background-color:#FFEC8B'.$i.'; } div.ws-plugin--s2member-password-strength-strong { background-color:#C3FF88'.$i.'; } div.ws-plugin--s2member-password-strength-mismatch { background-color:#D6C1AB'.$i.'; }';
|
124 |
-
|
125 |
$a[] = 'div#login form#registerform p#reg_passmail { font-style:italic'.$i.'; }';
|
126 |
-
|
127 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
128 |
$a[] = 'p#reg_passmail { display:none'.$i.'; }';
|
129 |
-
|
130 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array_before_close", $a, get_defined_vars());
|
131 |
-
$a[] =
|
132 |
-
|
133 |
-
|
134 |
do_action("ws_plugin__s2member_during_login_header_styles", get_defined_vars());
|
135 |
-
unset
|
136 |
-
|
137 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array", $a, get_defined_vars());
|
138 |
-
$s .= "\n".implode("\n", $a)."\n\n";
|
139 |
-
|
140 |
echo apply_filters("ws_plugin__s2member_login_header_styles", $s, get_defined_vars());
|
141 |
-
|
142 |
do_action("ws_plugin__s2member_after_login_header_styles", get_defined_vars());
|
143 |
-
|
144 |
-
return
|
145 |
}
|
146 |
/**
|
147 |
* Displays login footer design.
|
@@ -155,22 +164,25 @@ if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
|
155 |
*/
|
156 |
public static function login_footer_design()
|
157 |
{
|
|
|
|
|
|
|
158 |
do_action("ws_plugin__s2member_before_login_footer_design", get_defined_vars());
|
159 |
-
|
160 |
if(($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_footer_design"]))
|
161 |
-
|
162 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
163 |
{
|
164 |
-
echo
|
165 |
}
|
166 |
-
else
|
167 |
{
|
168 |
eval("?>".$code);
|
169 |
}
|
170 |
-
|
171 |
do_action("ws_plugin__s2member_after_login_footer_design", get_defined_vars());
|
172 |
-
|
173 |
-
return
|
174 |
}
|
175 |
}
|
176 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_login_customizations"))
|
21 |
{
|
22 |
/**
|
40 |
*/
|
41 |
public static function login_header_url($url = FALSE)
|
42 |
{
|
43 |
+
if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_design_enabled"])
|
44 |
+
return $url; // Login/Registration Design disabled in this case.
|
45 |
+
|
46 |
do_action("ws_plugin__s2member_before_login_header_url", get_defined_vars());
|
47 |
+
|
48 |
$url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_url"];
|
49 |
+
|
50 |
return apply_filters("ws_plugin__s2member_login_header_url", $url, get_defined_vars());
|
51 |
}
|
52 |
/**
|
62 |
*/
|
63 |
public static function login_header_title($title = FALSE)
|
64 |
{
|
65 |
+
if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_design_enabled"])
|
66 |
+
return $title; // Login/Registration Design disabled in this case.
|
67 |
+
|
68 |
do_action("ws_plugin__s2member_before_login_header_title", get_defined_vars());
|
69 |
+
|
70 |
$title = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_title"];
|
71 |
+
|
72 |
return apply_filters("ws_plugin__s2member_login_header_title", $title, get_defined_vars());
|
73 |
}
|
74 |
/**
|
83 |
*/
|
84 |
public static function login_header_styles()
|
85 |
{
|
86 |
+
if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_design_enabled"])
|
87 |
+
return; // Login/Registration Design disabled in this case.
|
88 |
+
|
89 |
+
$s = /* Initialize styles string here to give Hooks a chance. */ "";
|
90 |
+
$a = /* Initialize here to give Filters a chance. */ array();
|
91 |
+
|
92 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
93 |
do_action("ws_plugin__s2member_before_login_header_styles", get_defined_vars());
|
94 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
95 |
+
|
96 |
+
$a[] = /* Open style tag, then give Filters a chance below. */ '<style type="text/css">';
|
97 |
$i = apply_filters("ws_plugin__s2member_login_header_styles_important", " !important", get_defined_vars());
|
98 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array_after_open", $a, get_defined_vars());
|
99 |
+
|
100 |
+
$a[] = /* Clear existing. */ 'html, body { border:0'.$i.'; background:none'.$i.'; }';
|
101 |
$a[] = 'html { background-color:#'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"].$i.'; }';
|
102 |
$a[] = 'html { background-image:url('.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"].')'.$i.'; }';
|
103 |
$a[] = 'html { background-repeat:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"].$i.'; }';
|
104 |
+
|
105 |
$a[] = 'body, body * { font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_size"].$i.'; }';
|
106 |
$a[] = 'body, body * { font-family:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_family"].$i.'; }';
|
107 |
+
|
108 |
$a[] = 'div#login { width:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"].'px'.$i.'; }';
|
109 |
$a[] = 'div#login h1 a { background:url('.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"].') no-repeat top center'.$i.'; background-size:auto'.$i.'; }';
|
110 |
$a[] = 'div#login h1 a { display:block'.$i.'; width:100%'.$i.'; height:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_height"].'px'.$i.'; }';
|
111 |
+
|
112 |
$a[] = 'div#login form { -moz-box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; -webkit-box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; box-shadow:1px 1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].', -1px -1px 5px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"].$i.'; }';
|
113 |
+
|
114 |
$a[] = 'div#login p#nav, div#login p#nav a, div#login p#nav a:hover, div#login p#nav a:active, div#login p#nav a:focus { color:#'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"].$i.'; text-shadow:1px 1px 3px #'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"].$i.'; }';
|
115 |
$a[] = 'div#login p#backtoblog, div#login p#backtoblog a, div#login p#backtoblog a:hover, div#login p#backtoblog a:active, div#login 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.'; }';
|
116 |
+
|
117 |
+
$a[] = /* Handles paragraph margins inside the form. */ 'div#login form p { margin:2px 0 16px 0'.$i.'; }';
|
118 |
$a[] = 'div#login form input[type="text"], div#login form input[type="email"], div#login form input[type="password"], div#login form textarea, div#login form select { font-weight:normal'.$i.'; color:#333333'.$i.'; background:none repeat scroll 0 0 #FBFBFB'.$i.'; border:1px solid #E5E5E5'.$i.'; font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"].$i.'; margin:0'.$i.'; padding:3px'.$i.'; -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
119 |
$a[] = 'div#login form select { width:99.5%'.$i.' !ie<8; } div#login form select > option { font-size:'.$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"].$i.'; }';
|
120 |
$a[] = 'div#login form label { cursor:pointer'.$i.'; } div#login form label.ws-plugin--s2member-custom-reg-field-op-l { opacity:0.7'.$i.'; font-size:90%'.$i.'; vertical-align:middle'.$i.'; }';
|
121 |
$a[] = 'div#login form input[type="checkbox"], div#login form input[type="radio"] { margin:0 3px 0 0'.$i.'; vertical-align:middle'.$i.'; }';
|
122 |
$a[] = 'div#login form input#ws-plugin--s2member-custom-reg-field-user-pass2[type="password"] { margin-top:5px'.$i.'; }';
|
123 |
+
|
124 |
$a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section { margin:2px 0 16px 0'.$i.'; border:0'.$i.'; height:1px'.$i.'; line-height:1px'.$i.'; background:#CCCCCC'.$i.'; }';
|
125 |
$a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section-title { margin:2px 0 16px 0'.$i.'; border:0 solid #CCCCCC'.$i.'; border-width:0 0 1px 0'.$i.'; padding:0 0 10px 0'.$i.'; font-size:110%'.$i.'; }';
|
126 |
+
|
127 |
$a[] = 'div#login form input[type="submit"], div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#666666'.$i.'; text-shadow:2px 2px 5px #EEEEEE'.$i.'; border:1px solid #999999'.$i.'; background:#FBFBFB'.$i.';'.((version_compare(get_bloginfo("version"), "3.5", "<")) ? ' padding:5px'.$i.';' : '').' -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; }';
|
128 |
$a[] = 'div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#000000'.$i.'; text-shadow:2px 2px 5px #CCCCCC'.$i.'; border-color:#000000'.$i.'; }';
|
129 |
$a[] = 'div#login form#registerform { padding-bottom:16px'.$i.'; } div#login form#registerform p.submit { float:none'.$i.'; margin-top:-10px'.$i.'; } div#login form#registerform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
130 |
$a[] = 'div#login form#lostpasswordform { padding-bottom:16px'.$i.'; } div#login form#lostpasswordform p.submit { float:none'.$i.'; } div#login form#lostpasswordform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; width:98%'.$i.' !ie<8; margin-right:2%'.$i.' !ie<8; box-sizing:border-box'.$i.'; -ms-box-sizing:border-box'.$i.'; -moz-box-sizing:border-box'.$i.'; -webkit-box-sizing:border-box'.$i.'; }';
|
131 |
+
|
132 |
$a[] = 'div.ws-plugin--s2member-password-strength { margin-top:3px'.$i.'; font-color:#000000'.$i.'; background-color:#EEEEEE'.$i.'; padding:3px'.$i.'; -moz-border-radius:3px'.$i.'; -webkit-border-radius:3px'.$i.'; border-radius:3px'.$i.'; } div.ws-plugin--s2member-password-strength-short { background-color:#FFA0A0'.$i.'; } div.ws-plugin--s2member-password-strength-bad { background-color:#FFB78C'.$i.'; } div.ws-plugin--s2member-password-strength-good { background-color:#FFEC8B'.$i.'; } div.ws-plugin--s2member-password-strength-strong { background-color:#C3FF88'.$i.'; } div.ws-plugin--s2member-password-strength-mismatch { background-color:#D6C1AB'.$i.'; }';
|
133 |
+
|
134 |
$a[] = 'div#login form#registerform p#reg_passmail { font-style:italic'.$i.'; }';
|
135 |
+
|
136 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
137 |
$a[] = 'p#reg_passmail { display:none'.$i.'; }';
|
138 |
+
|
139 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array_before_close", $a, get_defined_vars());
|
140 |
+
$a[] = /* Now close style tag. There are other Filters below. */ '</style>';
|
141 |
+
|
142 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
143 |
do_action("ws_plugin__s2member_during_login_header_styles", get_defined_vars());
|
144 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
145 |
+
|
146 |
$a = apply_filters("ws_plugin__s2member_login_header_styles_array", $a, get_defined_vars());
|
147 |
+
$s .= /* Now put all array elements together. */ "\n".implode("\n", $a)."\n\n";
|
148 |
+
|
149 |
echo apply_filters("ws_plugin__s2member_login_header_styles", $s, get_defined_vars());
|
150 |
+
|
151 |
do_action("ws_plugin__s2member_after_login_header_styles", get_defined_vars());
|
152 |
+
|
153 |
+
return /* Return for uniformity. */;
|
154 |
}
|
155 |
/**
|
156 |
* Displays login footer design.
|
164 |
*/
|
165 |
public static function login_footer_design()
|
166 |
{
|
167 |
+
if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_design_enabled"])
|
168 |
+
return; // Login/Registration Design disabled in this case.
|
169 |
+
|
170 |
do_action("ws_plugin__s2member_before_login_footer_design", get_defined_vars());
|
171 |
+
|
172 |
if(($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_footer_design"]))
|
173 |
+
|
174 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
175 |
{
|
176 |
+
echo /* No PHP here. */ $code."\n";
|
177 |
}
|
178 |
+
else // Otherwise, safe to allow PHP code.
|
179 |
{
|
180 |
eval("?>".$code);
|
181 |
}
|
182 |
+
|
183 |
do_action("ws_plugin__s2member_after_login_footer_design", get_defined_vars());
|
184 |
+
|
185 |
+
return /* Return for uniformity. */;
|
186 |
}
|
187 |
}
|
188 |
}
|
includes/classes/login-redirects-r.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
|
21 |
{
|
22 |
/**
|
@@ -30,9 +30,9 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
|
|
30 |
/**
|
31 |
* Handles completely empty ``login_redirect`` values.
|
32 |
*
|
33 |
-
* Some plugins (
|
34 |
* In the case of BuddyPress, it's own Filter against `login_redirect` will deal with empty values. However, since s2Member removes all Filters
|
35 |
-
* against `login_redirect` (
|
36 |
*
|
37 |
* @attaches-to ``add_filter("login_redirect");``
|
38 |
*
|
@@ -56,21 +56,21 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
|
|
56 |
*
|
57 |
* @return null
|
58 |
*/
|
59 |
-
public static function remove_login_redirect_filters ()
|
60 |
{
|
61 |
do_action ("ws_plugin__s2member_before_remove_login_redirect_filters", get_defined_vars ());
|
62 |
-
|
63 |
if (!apply_filters ("ws_plugin__s2member_allow_other_login_redirect_filters", false, get_defined_vars ()))
|
64 |
{
|
65 |
-
remove_all_filters
|
66 |
add_filter ("login_redirect", "c_ws_plugin__s2member_login_redirects_r::_empty_login_redirect_filter");
|
67 |
-
|
68 |
do_action ("ws_plugin__s2member_during_remove_login_redirect_filters", get_defined_vars ());
|
69 |
}
|
70 |
-
|
71 |
do_action ("ws_plugin__s2member_after_remove_login_redirect_filters", get_defined_vars ());
|
72 |
-
|
73 |
-
return
|
74 |
}
|
75 |
}
|
76 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
|
21 |
{
|
22 |
/**
|
30 |
/**
|
31 |
* Handles completely empty ``login_redirect`` values.
|
32 |
*
|
33 |
+
* Some plugins (most notably BuddyPress v1.5) have a nasty habit of sending an empty ``$_REQUEST["redirect_to"]`` input field with login widgets.
|
34 |
* In the case of BuddyPress, it's own Filter against `login_redirect` will deal with empty values. However, since s2Member removes all Filters
|
35 |
+
* against `login_redirect` (for compatibility), we NEED this simple routine to check empty values, and default them to ``admin_url()``.
|
36 |
*
|
37 |
* @attaches-to ``add_filter("login_redirect");``
|
38 |
*
|
56 |
*
|
57 |
* @return null
|
58 |
*/
|
59 |
+
public static function remove_login_redirect_filters ()
|
60 |
{
|
61 |
do_action ("ws_plugin__s2member_before_remove_login_redirect_filters", get_defined_vars ());
|
62 |
+
|
63 |
if (!apply_filters ("ws_plugin__s2member_allow_other_login_redirect_filters", false, get_defined_vars ()))
|
64 |
{
|
65 |
+
remove_all_filters /* Removes all `login_redirect` Filters. */("login_redirect");
|
66 |
add_filter ("login_redirect", "c_ws_plugin__s2member_login_redirects_r::_empty_login_redirect_filter");
|
67 |
+
|
68 |
do_action ("ws_plugin__s2member_during_remove_login_redirect_filters", get_defined_vars ());
|
69 |
}
|
70 |
+
|
71 |
do_action ("ws_plugin__s2member_after_remove_login_redirect_filters", get_defined_vars ());
|
72 |
+
|
73 |
+
return /* Return for uniformity. */;
|
74 |
}
|
75 |
}
|
76 |
}
|
includes/classes/login-redirects.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
21 |
{
|
22 |
/**
|
@@ -40,57 +40,59 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
|
40 |
*/
|
41 |
public static function login_redirect ($username = FALSE)
|
42 |
{
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
$username = (!$username && is_object ($user = wp_get_current_user ()) && !empty ($user->user_login)) ? strtolower ($user->user_login) : strtolower ($username);
|
48 |
-
|
49 |
if ($username && ((isset ($user) && is_object ($user)) || is_object ($user = new WP_User ($username))) && !empty ($user->ID) && ($user_id = $user->ID))
|
50 |
{
|
51 |
-
|
|
|
|
|
52 |
update_user_option ($user_id, "s2member_registration_ip", $_SERVER["REMOTE_ADDR"]);
|
53 |
-
|
54 |
if (($logins = (int)get_user_option ("s2member_login_counter", $user_id) + 1) >= 1 || ($logins = 1))
|
55 |
update_user_option ($user_id, "s2member_login_counter", $logins);
|
56 |
-
|
57 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
58 |
delete_user_setting ("default_password_nag") . update_user_option ($user_id, "default_password_nag", false, true);
|
59 |
-
|
60 |
$disable_login_ip_restrictions = apply_filters ("ws_plugin__s2member_disable_login_ip_restrictions", false, get_defined_vars ());
|
61 |
-
|
62 |
if (($ok = true) && !is_super_admin ($user_id) && $username !== "demo" && !$disable_login_ip_restrictions)
|
63 |
$ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $username);
|
64 |
-
|
65 |
if (($redirect = apply_filters ("ws_plugin__s2member_login_redirect", (($user->has_cap ("edit_posts")) ? false : true), get_defined_vars ())))
|
66 |
{
|
67 |
$obey_redirect_to = apply_filters ("ws_plugin__s2member_obey_login_redirect_to", /* By default, we obey this. */ true, get_defined_vars ());
|
68 |
-
|
69 |
if (!$obey_redirect_to || empty ($_REQUEST["redirect_to"]) || !is_string ($_REQUEST["redirect_to"]) || $_REQUEST["redirect_to"] === admin_url () || preg_match ("/^\/?wp-admin\/?$/", $_REQUEST["redirect_to"]))
|
70 |
{
|
71 |
-
|
72 |
do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
|
73 |
-
unset
|
74 |
-
|
75 |
-
if ($redirect && is_string ($redirect))
|
76 |
-
wp_redirect
|
77 |
-
|
78 |
else if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
|
79 |
-
wp_redirect
|
80 |
-
|
81 |
-
else
|
82 |
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
83 |
-
|
84 |
-
exit
|
85 |
}
|
86 |
}
|
87 |
}
|
88 |
-
|
89 |
-
|
90 |
do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
|
91 |
-
unset
|
92 |
-
|
93 |
-
return
|
94 |
}
|
95 |
/**
|
96 |
* Parses a Special Login Redirection URL.
|
@@ -104,13 +106,13 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
|
104 |
*/
|
105 |
public static function login_redirection_url ($user = FALSE, $root_returns_false = FALSE)
|
106 |
{
|
107 |
-
|
108 |
do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
|
109 |
-
unset
|
110 |
-
|
111 |
$url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
|
112 |
$url = c_ws_plugin__s2member_login_redirects::fill_login_redirect_rc_vars ($url, $user, $root_returns_false);
|
113 |
-
|
114 |
return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
|
115 |
}
|
116 |
/**
|
@@ -125,13 +127,13 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
|
125 |
*/
|
126 |
public static function login_redirection_uri ($user = FALSE, $root_returns_false = FALSE)
|
127 |
{
|
128 |
-
|
129 |
do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
|
130 |
-
unset
|
131 |
-
|
132 |
if (($url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user, $root_returns_false)))
|
133 |
$uri = c_ws_plugin__s2member_utils_urls::parse_uri ($url);
|
134 |
-
|
135 |
return apply_filters ("ws_plugin__s2member_login_redirection_uri", ((!empty ($uri)) ? $uri : false), get_defined_vars ());
|
136 |
}
|
137 |
/**
|
@@ -147,36 +149,36 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
|
147 |
*/
|
148 |
public static function fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE, $root_returns_false = FALSE)
|
149 |
{
|
150 |
-
|
151 |
do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
|
152 |
-
unset
|
153 |
-
|
154 |
-
$url =
|
155 |
-
$orig_url =
|
156 |
-
|
157 |
$user = ((is_object ($user) || is_object ($user = (is_user_logged_in ()) ? wp_get_current_user () : false)) && !empty ($user->ID)) ? $user : false;
|
158 |
-
|
159 |
$user_id = ($user) ? (string)$user->ID : "";
|
160 |
$user_login = ($user) ? (string)strtolower ($user->user_login) : "";
|
161 |
-
|
162 |
$user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
|
163 |
$user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
|
164 |
$user_ccaps = (string)implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
165 |
$user_logins = ($user) ? (string)(int)get_user_option ("s2member_login_counter", $user_id) : "-1";
|
166 |
-
|
167 |
$url = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $url);
|
168 |
$url = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $url);
|
169 |
$url = preg_replace ("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_level), $url);
|
170 |
$url = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $url);
|
171 |
$url = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $url);
|
172 |
$url = preg_replace ("/%%current_user_logins%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_logins), $url);
|
173 |
-
|
174 |
if ( /* Only if s2Member's fault » */$url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url ($url, -1, false)) || (!empty ($parse["path"]) && strpos ($parse["path"], "//") !== false)))
|
175 |
-
$url =
|
176 |
-
|
177 |
if ($root_returns_false /* Used by s2Member's security gate. */ && c_ws_plugin__s2member_utils_conds::is_site_root ($url))
|
178 |
-
$url =
|
179 |
-
|
180 |
return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
|
181 |
}
|
182 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
|
21 |
{
|
22 |
/**
|
40 |
*/
|
41 |
public static function login_redirect ($username = FALSE)
|
42 |
{
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
$username = (!$username && is_object ($user = wp_get_current_user ()) && !empty ($user->user_login)) ? strtolower ($user->user_login) : strtolower ($username);
|
48 |
+
|
49 |
if ($username && ((isset ($user) && is_object ($user)) || is_object ($user = new WP_User ($username))) && !empty ($user->ID) && ($user_id = $user->ID))
|
50 |
{
|
51 |
+
update_user_option ($user_id, "s2member_last_login_time", time());
|
52 |
+
|
53 |
+
if /* Have we got this yet? */ (!get_user_option ("s2member_registration_ip", $user_id))
|
54 |
update_user_option ($user_id, "s2member_registration_ip", $_SERVER["REMOTE_ADDR"]);
|
55 |
+
|
56 |
if (($logins = (int)get_user_option ("s2member_login_counter", $user_id) + 1) >= 1 || ($logins = 1))
|
57 |
update_user_option ($user_id, "s2member_login_counter", $logins);
|
58 |
+
|
59 |
+
if /* Nag em? */ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
|
60 |
delete_user_setting ("default_password_nag") . update_user_option ($user_id, "default_password_nag", false, true);
|
61 |
+
|
62 |
$disable_login_ip_restrictions = apply_filters ("ws_plugin__s2member_disable_login_ip_restrictions", false, get_defined_vars ());
|
63 |
+
|
64 |
if (($ok = true) && !is_super_admin ($user_id) && $username !== "demo" && !$disable_login_ip_restrictions)
|
65 |
$ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $username);
|
66 |
+
|
67 |
if (($redirect = apply_filters ("ws_plugin__s2member_login_redirect", (($user->has_cap ("edit_posts")) ? false : true), get_defined_vars ())))
|
68 |
{
|
69 |
$obey_redirect_to = apply_filters ("ws_plugin__s2member_obey_login_redirect_to", /* By default, we obey this. */ true, get_defined_vars ());
|
70 |
+
|
71 |
if (!$obey_redirect_to || empty ($_REQUEST["redirect_to"]) || !is_string ($_REQUEST["redirect_to"]) || $_REQUEST["redirect_to"] === admin_url () || preg_match ("/^\/?wp-admin\/?$/", $_REQUEST["redirect_to"]))
|
72 |
{
|
73 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
74 |
do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
|
75 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
76 |
+
|
77 |
+
if /* Is this a string? */ ($redirect && is_string ($redirect))
|
78 |
+
wp_redirect /* Dynamic URL introduced by a Filter? */ ($redirect);
|
79 |
+
|
80 |
else if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
|
81 |
+
wp_redirect /* Special Redirection URL configured with s2Member. */ ($redirection_url);
|
82 |
+
|
83 |
+
else // Else we use the Login Welcome Page configured for s2Member.
|
84 |
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
|
85 |
+
|
86 |
+
exit /* Clean exit. */ ();
|
87 |
}
|
88 |
}
|
89 |
}
|
90 |
+
|
91 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
92 |
do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
|
93 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
94 |
+
|
95 |
+
return /* Return for uniformity. */;
|
96 |
}
|
97 |
/**
|
98 |
* Parses a Special Login Redirection URL.
|
106 |
*/
|
107 |
public static function login_redirection_url ($user = FALSE, $root_returns_false = FALSE)
|
108 |
{
|
109 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
110 |
do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
|
111 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
112 |
+
|
113 |
$url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
|
114 |
$url = c_ws_plugin__s2member_login_redirects::fill_login_redirect_rc_vars ($url, $user, $root_returns_false);
|
115 |
+
|
116 |
return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
|
117 |
}
|
118 |
/**
|
127 |
*/
|
128 |
public static function login_redirection_uri ($user = FALSE, $root_returns_false = FALSE)
|
129 |
{
|
130 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
131 |
do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
|
132 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
133 |
+
|
134 |
if (($url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user, $root_returns_false)))
|
135 |
$uri = c_ws_plugin__s2member_utils_urls::parse_uri ($url);
|
136 |
+
|
137 |
return apply_filters ("ws_plugin__s2member_login_redirection_uri", ((!empty ($uri)) ? $uri : false), get_defined_vars ());
|
138 |
}
|
139 |
/**
|
149 |
*/
|
150 |
public static function fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE, $root_returns_false = FALSE)
|
151 |
{
|
152 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
153 |
do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
|
154 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
155 |
+
|
156 |
+
$url = /* Force ``$url`` to a string value. */ (string)$url;
|
157 |
+
$orig_url = /* Record the original URL that was passed in. */ $url;
|
158 |
+
|
159 |
$user = ((is_object ($user) || is_object ($user = (is_user_logged_in ()) ? wp_get_current_user () : false)) && !empty ($user->ID)) ? $user : false;
|
160 |
+
|
161 |
$user_id = ($user) ? (string)$user->ID : "";
|
162 |
$user_login = ($user) ? (string)strtolower ($user->user_login) : "";
|
163 |
+
|
164 |
$user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
|
165 |
$user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
|
166 |
$user_ccaps = (string)implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
|
167 |
$user_logins = ($user) ? (string)(int)get_user_option ("s2member_login_counter", $user_id) : "-1";
|
168 |
+
|
169 |
$url = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $url);
|
170 |
$url = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $url);
|
171 |
$url = preg_replace ("/%%current_user_level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_level), $url);
|
172 |
$url = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $url);
|
173 |
$url = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $url);
|
174 |
$url = preg_replace ("/%%current_user_logins%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_logins), $url);
|
175 |
+
|
176 |
if ( /* Only if s2Member's fault » */$url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url ($url, -1, false)) || (!empty ($parse["path"]) && strpos ($parse["path"], "//") !== false)))
|
177 |
+
$url = /* Defaults to Home Page. We don't return invalid URLs produced by empty Replacement Codes ( i.e. with `//` ). */ site_url ("/");
|
178 |
+
|
179 |
if ($root_returns_false /* Used by s2Member's security gate. */ && c_ws_plugin__s2member_utils_conds::is_site_root ($url))
|
180 |
+
$url = /* In case we need to return false on root URLs (i.e. don't protect the Home Page inadvertently). */ false;
|
181 |
+
|
182 |
return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
|
183 |
}
|
184 |
}
|
includes/classes/menu-pages-rs.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_menu_pages_rs"))
|
21 |
{
|
22 |
/**
|
@@ -38,74 +38,74 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages_rs"))
|
|
38 |
public static function display ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_during_menu_pages_before_right_sections", get_defined_vars ());
|
41 |
-
|
42 |
echo '<div id="ws-menu-page-js-c-w" class="ws-menu-page-js-c-w">' . "\n";
|
43 |
include_once dirname (dirname (__FILE__)) . "/menu-pages/js-c-warning.inc.php";
|
44 |
echo '</div>' . "\n";
|
45 |
-
|
46 |
echo '<script type="text/javascript">' . "\n";
|
47 |
echo "jQuery('div#ws-menu-page-js-c-w').hide();" . "\n";
|
48 |
echo '</script>' . "\n";
|
49 |
-
|
50 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["updates"])
|
51 |
{
|
52 |
echo '<div class="ws-menu-page-updates">' . "\n";
|
53 |
include_once dirname (dirname (__FILE__)) . "/menu-pages/updates.inc.php";
|
54 |
echo '</div>' . "\n";
|
55 |
}
|
56 |
-
|
57 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["upsell-pro"])
|
58 |
{
|
59 |
echo '<div class="ws-menu-page-others">' . "\n";
|
60 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Pro Module / Prices")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-upsell-pro.png" alt="." /></a>' . "\n";
|
61 |
echo '</div>' . "\n";
|
62 |
}
|
63 |
-
|
64 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["installation"])
|
65 |
{
|
66 |
echo '<div class="ws-menu-page-installation">' . "\n";
|
67 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Professional Installation URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-installation.png" alt="." /></a>' . "\n";
|
68 |
echo '</div>' . "\n";
|
69 |
}
|
70 |
-
|
71 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["tools"])
|
72 |
{
|
73 |
echo '<div class="ws-menu-page-tools">' . "\n";
|
74 |
echo '<img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-tools.png" alt="." />' . "\n";
|
75 |
echo '</div>' . "\n";
|
76 |
}
|
77 |
-
|
78 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["kb"])
|
79 |
{
|
80 |
echo '<div class="ws-menu-page-kb">' . "\n";
|
81 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Knowledge Base")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-kb.png" alt="." /></a>' . "\n";
|
82 |
echo '</div>' . "\n";
|
83 |
}
|
84 |
-
|
85 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["videos"])
|
86 |
{
|
87 |
echo '<div class="ws-menu-page-videos">' . "\n";
|
88 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Video Tutorials")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-videos.png" alt="." /></a>' . "\n";
|
89 |
echo '</div>' . "\n";
|
90 |
}
|
91 |
-
|
92 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["support"])
|
93 |
{
|
94 |
echo '<div class="ws-menu-page-support">' . "\n";
|
95 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Forum URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-support.png" alt="." /></a>' . "\n";
|
96 |
echo '</div>' . "\n";
|
97 |
}
|
98 |
-
|
99 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["donations"])
|
100 |
{
|
101 |
echo '<div class="ws-menu-page-donations">' . "\n";
|
102 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Donate link")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-donations.png" alt="." /></a>' . "\n";
|
103 |
echo '</div>' . "\n";
|
104 |
}
|
105 |
-
|
106 |
do_action ("ws_plugin__s2member_during_menu_pages_after_right_sections", get_defined_vars ());
|
107 |
-
|
108 |
-
return
|
109 |
}
|
110 |
}
|
111 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_menu_pages_rs"))
|
21 |
{
|
22 |
/**
|
38 |
public static function display ()
|
39 |
{
|
40 |
do_action ("ws_plugin__s2member_during_menu_pages_before_right_sections", get_defined_vars ());
|
41 |
+
|
42 |
echo '<div id="ws-menu-page-js-c-w" class="ws-menu-page-js-c-w">' . "\n";
|
43 |
include_once dirname (dirname (__FILE__)) . "/menu-pages/js-c-warning.inc.php";
|
44 |
echo '</div>' . "\n";
|
45 |
+
|
46 |
echo '<script type="text/javascript">' . "\n";
|
47 |
echo "jQuery('div#ws-menu-page-js-c-w').hide();" . "\n";
|
48 |
echo '</script>' . "\n";
|
49 |
+
|
50 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["updates"])
|
51 |
{
|
52 |
echo '<div class="ws-menu-page-updates">' . "\n";
|
53 |
include_once dirname (dirname (__FILE__)) . "/menu-pages/updates.inc.php";
|
54 |
echo '</div>' . "\n";
|
55 |
}
|
56 |
+
|
57 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["upsell-pro"])
|
58 |
{
|
59 |
echo '<div class="ws-menu-page-others">' . "\n";
|
60 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Pro Module / Prices")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-upsell-pro.png" alt="." /></a>' . "\n";
|
61 |
echo '</div>' . "\n";
|
62 |
}
|
63 |
+
|
64 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["installation"])
|
65 |
{
|
66 |
echo '<div class="ws-menu-page-installation">' . "\n";
|
67 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Professional Installation URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-installation.png" alt="." /></a>' . "\n";
|
68 |
echo '</div>' . "\n";
|
69 |
}
|
70 |
+
|
71 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["tools"])
|
72 |
{
|
73 |
echo '<div class="ws-menu-page-tools">' . "\n";
|
74 |
echo '<img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-tools.png" alt="." />' . "\n";
|
75 |
echo '</div>' . "\n";
|
76 |
}
|
77 |
+
|
78 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["kb"])
|
79 |
{
|
80 |
echo '<div class="ws-menu-page-kb">' . "\n";
|
81 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Knowledge Base")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-kb.png" alt="." /></a>' . "\n";
|
82 |
echo '</div>' . "\n";
|
83 |
}
|
84 |
+
|
85 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["videos"])
|
86 |
{
|
87 |
echo '<div class="ws-menu-page-videos">' . "\n";
|
88 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Video Tutorials")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-videos.png" alt="." /></a>' . "\n";
|
89 |
echo '</div>' . "\n";
|
90 |
}
|
91 |
+
|
92 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["support"])
|
93 |
{
|
94 |
echo '<div class="ws-menu-page-support">' . "\n";
|
95 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Forum URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-support.png" alt="." /></a>' . "\n";
|
96 |
echo '</div>' . "\n";
|
97 |
}
|
98 |
+
|
99 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["donations"])
|
100 |
{
|
101 |
echo '<div class="ws-menu-page-donations">' . "\n";
|
102 |
echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Donate link")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-donations.png" alt="." /></a>' . "\n";
|
103 |
echo '</div>' . "\n";
|
104 |
}
|
105 |
+
|
106 |
do_action ("ws_plugin__s2member_during_menu_pages_after_right_sections", get_defined_vars ());
|
107 |
+
|
108 |
+
return /* Return for uniformity. */;
|
109 |
}
|
110 |
}
|
111 |
}
|
includes/classes/menu-pages.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
21 |
{
|
22 |
/**
|
@@ -38,7 +38,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
38 |
public static $pre_display_errors = array();
|
39 |
/**
|
40 |
* Saves all options from any menu page.
|
41 |
-
*
|
42 |
* Can also be self-verified; and configured extensively with function parameters.
|
43 |
*
|
44 |
* @package s2Member\Menu_Pages
|
@@ -55,82 +55,81 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
55 |
*/
|
56 |
public static function update_all_options($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
|
57 |
{
|
58 |
-
$updated_all_options = false;
|
59 |
-
|
60 |
-
|
61 |
-
do_action("ws_plugin__s2member_before_update_all_options", get_defined_vars());
|
62 |
-
unset
|
63 |
-
|
64 |
if($verified || (!empty($_POST["ws_plugin__s2member_options_save"]) && ($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-options-save")))
|
65 |
{
|
66 |
-
$options =
|
67 |
-
|
68 |
$new_options = (is_array($new_options)) ? $new_options : ((!empty($_POST) && is_array($_POST)) ? stripslashes_deep($_POST) : array());
|
69 |
$new_options = c_ws_plugin__s2member_utils_strings::trim_deep($new_options);
|
70 |
-
|
71 |
-
foreach
|
72 |
-
if
|
73 |
-
|
74 |
-
if
|
75 |
($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = $value).update_option("ws_plugin__s2member_configured", $value);
|
76 |
-
|
77 |
else if(!is_array($value) || (is_array($value) && /* Updating an array? */ array_shift($value) === "update-signal"))
|
78 |
$options[preg_replace("/^".preg_quote("ws_plugin__s2member_", "/")."/", "", $key)] = $value;
|
79 |
-
|
80 |
-
unset
|
81 |
-
|
82 |
-
|
83 |
-
do_action("ws_plugin__s2member_during_update_all_options", get_defined_vars());
|
84 |
-
unset
|
85 |
-
|
86 |
$options = ws_plugin__s2member_configure_options_and_their_defaults(($options = array_merge($options, array("options_version" => (string)($options["options_version"] + 0.001)))));
|
87 |
update_option("ws_plugin__s2member_options", $options).((is_multisite() && is_main_site()) ? update_site_option("ws_plugin__s2member_options", $options) : null).update_option("ws_plugin__s2member_cache", array());
|
88 |
-
|
89 |
-
if($update_other === true || in_array("auto_eot_system", (array)$update_other))
|
90 |
($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();
|
91 |
-
|
92 |
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>'))
|
93 |
($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);
|
94 |
-
|
95 |
-
if(empty($_GET["page"]) || $_GET["page"] !== "ws-plugin--s2member-mms-ops")
|
96 |
{
|
97 |
-
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
|
98 |
($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);
|
99 |
-
|
100 |
-
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
|
101 |
($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);
|
102 |
-
|
103 |
-
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 (
|
104 |
($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);
|
105 |
-
|
106 |
-
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 (
|
107 |
($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);
|
108 |
-
|
109 |
-
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 (
|
110 |
($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);
|
111 |
-
|
112 |
-
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 (
|
113 |
($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);
|
114 |
-
|
115 |
-
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
|
116 |
($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);
|
117 |
}
|
118 |
-
|
119 |
-
$updated_all_options = true; /* Flag indicating this routine was processed successfully; and that all s2Member options have been updated successfully.*/
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
do_action("ws_plugin__s2member_after_update_all_options", get_defined_vars());
|
124 |
-
unset
|
125 |
-
|
126 |
return apply_filters("ws_plugin__s2member_update_all_options", (($updated_all_options) ? true : false), get_defined_vars());
|
127 |
}
|
128 |
/**
|
129 |
* Adds option menus / sub-menus.
|
130 |
-
*
|
131 |
* @package s2Member\Menu_Pages
|
132 |
* @since 3.5
|
133 |
-
*
|
134 |
* @attaches-to ``add_action("admin_menu");``
|
135 |
*
|
136 |
* @return null
|
@@ -138,95 +137,101 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
138 |
public static function add_admin_options()
|
139 |
{
|
140 |
do_action("ws_plugin__s2member_before_add_admin_options", get_defined_vars());
|
141 |
-
|
142 |
add_filter("plugin_action_links", "c_ws_plugin__s2member_menu_pages::_add_settings_link", 10, 2);
|
143 |
-
|
144 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars()))
|
145 |
{
|
146 |
if((is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) || apply_filters("ws_plugin__s2member_during_add_admin_options_clear_right_side", false, get_defined_vars()))
|
147 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] =
|
148 |
-
|
149 |
$menu = apply_filters("ws_plugin__s2member_during_add_admin_options_menu_slug", "ws-plugin--s2member-start", get_defined_vars());
|
150 |
-
|
151 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_menu_page", true, get_defined_vars()))
|
152 |
add_menu_page("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::start_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images/brand-favicon.png");
|
153 |
-
|
154 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars()))
|
155 |
-
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");
|
156 |
-
|
157 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_1", true, get_defined_vars()))
|
158 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
159 |
-
|
160 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_mms_ops_page", (!is_multisite() || is_main_site()), get_defined_vars()))
|
161 |
-
add_submenu_page($menu, "s2Member Multisite Configuration", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-ops", "c_ws_plugin__s2member_menu_pages::mms_ops_page");
|
162 |
-
|
163 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_gen_ops_page", true, get_defined_vars()))
|
164 |
-
add_submenu_page($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-gen-ops", "c_ws_plugin__s2member_menu_pages::gen_ops_page");
|
165 |
-
|
166 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_res_ops_page", true, get_defined_vars()))
|
167 |
-
add_submenu_page($menu, "s2Member Restriction Options", "Restriction Options", "create_users", "ws-plugin--s2member-res-ops", "c_ws_plugin__s2member_menu_pages::res_ops_page");
|
168 |
-
|
169 |
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()))
|
170 |
-
add_submenu_page($menu, "s2Member Download Options", "Download Options", "create_users", "ws-plugin--s2member-down-ops", "c_ws_plugin__s2member_menu_pages::down_ops_page");
|
171 |
-
|
172 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_2", true, get_defined_vars()))
|
173 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
174 |
-
|
175 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars()))
|
176 |
-
add_submenu_page($menu, "s2Member / Add A Member", "Add A Member", "create_users", "user-new.php");
|
177 |
-
|
178 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_browse_users_page", true, get_defined_vars()))
|
179 |
-
add_submenu_page($menu, "s2Member / Browse Members", "Browse Members", "create_users", "users.php");
|
180 |
-
|
181 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_3", true, get_defined_vars()))
|
182 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
183 |
-
|
184 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars()))
|
185 |
-
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");
|
186 |
-
|
187 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars()))
|
188 |
-
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");
|
189 |
-
|
190 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_4", true, get_defined_vars()))
|
191 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
192 |
-
|
193 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars()))
|
194 |
-
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");
|
195 |
-
|
196 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_els_ops_page", true, get_defined_vars()))
|
197 |
-
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");
|
198 |
-
|
199 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_api_ops_page", true, get_defined_vars()))
|
200 |
-
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");
|
201 |
-
|
202 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars()))
|
203 |
-
add_submenu_page($menu, "s2Member API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "c_ws_plugin__s2member_menu_pages::scripting_page");
|
204 |
-
|
205 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_5", true, get_defined_vars()))
|
206 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
207 |
-
|
208 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_integrations_page", (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()), get_defined_vars()))
|
209 |
-
add_submenu_page($menu, "s2Member / Other Integrations", "Other Integrations", "create_users", "ws-plugin--s2member-integrations", "c_ws_plugin__s2member_menu_pages::integrations_page");
|
210 |
-
|
211 |
-
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_6", true, get_defined_vars()))
|
212 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
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()))
|
215 |
-
add_submenu_page($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
216 |
-
|
217 |
do_action("ws_plugin__s2member_during_add_admin_options_additional_pages", get_defined_vars());
|
218 |
}
|
219 |
-
|
220 |
do_action("ws_plugin__s2member_after_add_admin_options", get_defined_vars());
|
221 |
-
|
222 |
-
return
|
223 |
}
|
224 |
/**
|
225 |
* Adds network option menus / sub-menus.
|
226 |
-
*
|
227 |
* @package s2Member\Menu_Pages
|
228 |
* @since 3.5
|
229 |
-
*
|
230 |
* @attaches-to ``add_action("network_admin_menu");``
|
231 |
*
|
232 |
* @return null
|
@@ -234,34 +239,34 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
234 |
public static function add_network_admin_options()
|
235 |
{
|
236 |
do_action("ws_plugin__s2member_before_add_network_admin_options", get_defined_vars());
|
237 |
-
|
238 |
if(apply_filters("ws_plugin__s2member_during_add_network_admin_options_create_menu_items", true, get_defined_vars()))
|
239 |
{
|
240 |
if((is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) || apply_filters("ws_plugin__s2member_during_add_network_admin_options_clear_right_side", false, get_defined_vars()))
|
241 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] =
|
242 |
-
|
243 |
-
$menu =
|
244 |
-
|
245 |
add_menu_page("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::mms_ops_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images/brand-favicon.png");
|
246 |
-
|
247 |
-
add_submenu_page($menu, "s2Member Multisite (
|
248 |
-
|
249 |
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()))
|
250 |
add_submenu_page($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
251 |
-
|
252 |
do_action("ws_plugin__s2member_during_add_network_admin_options_additional_pages", get_defined_vars());
|
253 |
}
|
254 |
-
|
255 |
do_action("ws_plugin__s2member_after_add_network_admin_options", get_defined_vars());
|
256 |
-
|
257 |
-
return
|
258 |
}
|
259 |
/**
|
260 |
* A sort of callback function to add the settings link.
|
261 |
-
*
|
262 |
* @package s2Member\Menu_Pages
|
263 |
* @since 3.5
|
264 |
-
*
|
265 |
* @attaches-to ``add_filter("plugin_action_links");``
|
266 |
*
|
267 |
* @param array $actions Expects an existing array of actions links, passed in by the Filter.
|
@@ -270,28 +275,28 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
270 |
*/
|
271 |
public static function _add_settings_link($actions = FALSE, $plugin_file = FALSE)
|
272 |
{
|
273 |
-
|
274 |
do_action("_ws_plugin__s2member_before_add_settings_link", get_defined_vars());
|
275 |
-
unset
|
276 |
-
|
277 |
if($plugin_file === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["plugin_basename"] && is_array($actions))
|
278 |
{
|
279 |
$settings = '<a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-gen-ops")).'">Settings</a>';
|
280 |
array_unshift($actions, apply_filters("ws_plugin__s2member_add_settings_link", $settings, get_defined_vars()));
|
281 |
-
|
282 |
-
|
283 |
do_action("_ws_plugin__s2member_during_add_settings_link", get_defined_vars());
|
284 |
-
unset
|
285 |
}
|
286 |
-
|
287 |
return apply_filters("_ws_plugin__s2member_add_settings_link", $actions, get_defined_vars());
|
288 |
}
|
289 |
/**
|
290 |
* Enqueue scripts for administrative menu pages.
|
291 |
-
*
|
292 |
* @package s2Member\Menu_Pages
|
293 |
* @since 3.5
|
294 |
-
*
|
295 |
* @attaches-to ``add_action("admin_print_scripts");``
|
296 |
*
|
297 |
* @return null
|
@@ -299,7 +304,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
299 |
public static function add_admin_scripts()
|
300 |
{
|
301 |
do_action("ws_plugin__s2member_before_add_admin_scripts", get_defined_vars());
|
302 |
-
|
303 |
if(!empty($_GET["page"]) && preg_match("/ws-plugin--s2member-/", $_GET["page"]))
|
304 |
{
|
305 |
wp_enqueue_script("jquery");
|
@@ -310,20 +315,20 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
310 |
wp_enqueue_script("jquery-json-ps", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/includes/jquery/jquery.json-ps/jquery.json-ps-min.js", array("jquery"), c_ws_plugin__s2member_utilities::ver_checksum());
|
311 |
wp_enqueue_script("jquery-ui-effects", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/includes/jquery/jquery.ui-effects/jquery.ui-effects-min.js", array("jquery", "jquery-ui-core"), c_ws_plugin__s2member_utilities::ver_checksum());
|
312 |
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-sprintf", "jquery-json-ps", "jquery-ui-core", "jquery-ui-effects", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum());
|
313 |
-
|
314 |
do_action("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars());
|
315 |
}
|
316 |
-
|
317 |
do_action("ws_plugin__s2member_after_add_admin_scripts", get_defined_vars());
|
318 |
-
|
319 |
-
return
|
320 |
}
|
321 |
/**
|
322 |
* Enqueue styles for administrative menu pages.
|
323 |
-
*
|
324 |
* @package s2Member\Menu_Pages
|
325 |
* @since 3.5
|
326 |
-
*
|
327 |
* @attaches-to ``add_action("admin_print_styles");``
|
328 |
*
|
329 |
* @return null
|
@@ -331,339 +336,569 @@ if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
|
331 |
public static function add_admin_styles()
|
332 |
{
|
333 |
do_action("ws_plugin__s2member_before_add_admin_styles", get_defined_vars());
|
334 |
-
|
335 |
if(!empty($_GET["page"]) && preg_match("/ws-plugin--s2member-/", $_GET["page"]))
|
336 |
{
|
337 |
wp_enqueue_style("thickbox");
|
338 |
wp_enqueue_style("ws-plugin--s2member-menu-pages", site_url("/?ws_plugin__s2member_menu_pages_css=".urlencode(mt_rand())), array("thickbox"), c_ws_plugin__s2member_utilities::ver_checksum(), "all");
|
339 |
-
|
340 |
do_action("ws_plugin__s2member_during_add_admin_styles", get_defined_vars());
|
341 |
}
|
342 |
-
|
343 |
do_action("ws_plugin__s2member_after_add_admin_styles", get_defined_vars());
|
344 |
-
|
345 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
/**
|
348 |
* Builds and handles the Quick Start page.
|
349 |
-
*
|
350 |
* @package s2Member\Menu_Pages
|
351 |
* @since 3.5
|
352 |
-
*
|
353 |
* @return null
|
354 |
*/
|
355 |
public static function start_page()
|
356 |
{
|
357 |
do_action("ws_plugin__s2member_before_start_page", get_defined_vars());
|
358 |
-
|
359 |
include_once dirname(dirname(__FILE__))."/menu-pages/start.inc.php";
|
360 |
-
|
361 |
do_action("ws_plugin__s2member_after_start_page", get_defined_vars());
|
362 |
-
|
363 |
-
return
|
364 |
}
|
365 |
/**
|
366 |
* Builds and handles the Main Multisite Options page.
|
367 |
-
*
|
368 |
* @package s2Member\Menu_Pages
|
369 |
* @since 3.5
|
370 |
-
*
|
371 |
* @return null
|
372 |
*/
|
373 |
public static function mms_ops_page()
|
374 |
{
|
375 |
do_action("ws_plugin__s2member_before_mms_ops_page", get_defined_vars());
|
376 |
-
|
377 |
if(c_ws_plugin__s2member_menu_pages::update_all_options())
|
378 |
c_ws_plugin__s2member_mms_patches::mms_patches(true);
|
379 |
-
|
380 |
include_once dirname(dirname(__FILE__))."/menu-pages/mms-ops.inc.php";
|
381 |
-
|
382 |
do_action("ws_plugin__s2member_after_mms_ops_page", get_defined_vars());
|
383 |
-
|
384 |
-
return
|
385 |
}
|
386 |
/**
|
387 |
* Builds and handles the General Options page.
|
388 |
-
*
|
389 |
* @package s2Member\Menu_Pages
|
390 |
* @since 3.5
|
391 |
-
*
|
392 |
* @return null
|
393 |
*/
|
394 |
public static function gen_ops_page()
|
395 |
{
|
396 |
do_action("ws_plugin__s2member_before_gen_ops_page", get_defined_vars());
|
397 |
-
|
398 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
399 |
-
|
400 |
include_once dirname(dirname(__FILE__))."/menu-pages/gen-ops.inc.php";
|
401 |
-
|
402 |
do_action("ws_plugin__s2member_after_gen_ops_page", get_defined_vars());
|
403 |
-
|
404 |
-
return
|
405 |
}
|
406 |
/**
|
407 |
* Builds and handles the Restriction Options page.
|
408 |
-
*
|
409 |
* @package s2Member\Menu_Pages
|
410 |
* @since 3.5
|
411 |
-
*
|
412 |
* @return null
|
413 |
*/
|
414 |
public static function res_ops_page()
|
415 |
{
|
416 |
do_action("ws_plugin__s2member_before_res_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/res-ops.inc.php";
|
421 |
-
|
422 |
do_action("ws_plugin__s2member_after_res_ops_page", get_defined_vars());
|
423 |
-
|
424 |
-
return
|
425 |
}
|
426 |
/**
|
427 |
* Builds and handles the Paypal Options page.
|
428 |
-
*
|
429 |
* @package s2Member\Menu_Pages
|
430 |
* @since 3.5
|
431 |
-
*
|
432 |
* @return null
|
433 |
*/
|
434 |
public static function paypal_ops_page()
|
435 |
{
|
436 |
do_action("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars());
|
437 |
-
|
438 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
439 |
-
|
440 |
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
441 |
-
|
442 |
if(!is_dir($logs_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir))))
|
443 |
mkdir($logs_dir, 0777, true).clearstatcache();
|
444 |
-
|
445 |
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]."/.htaccess";
|
446 |
$htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"])));
|
447 |
-
|
448 |
if(is_dir($logs_dir) && is_writable($logs_dir) && !file_exists($htaccess))
|
449 |
file_put_contents($htaccess, $htaccess_contents).clearstatcache();
|
450 |
-
|
451 |
-
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
452 |
{
|
453 |
-
if
|
454 |
-
c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled logs directory (
|
455 |
-
|
456 |
-
else if
|
457 |
-
c_ws_plugin__s2member_admin_notices::display_admin_notice('Permissions error. The security-enabled logs directory (
|
458 |
-
|
459 |
-
if
|
460 |
-
c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (
|
461 |
-
|
462 |
-
else if
|
463 |
-
c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (
|
464 |
}
|
465 |
-
|
466 |
include_once dirname(dirname(__FILE__))."/menu-pages/paypal-ops.inc.php";
|
467 |
-
|
468 |
do_action("ws_plugin__s2member_after_paypal_ops_page", get_defined_vars());
|
469 |
-
|
470 |
-
return
|
471 |
}
|
472 |
/**
|
473 |
* Builds and handles the Download Options page.
|
474 |
-
*
|
475 |
* @package s2Member\Menu_Pages
|
476 |
* @since 3.5
|
477 |
-
*
|
478 |
* @return null
|
479 |
*/
|
480 |
public static function down_ops_page()
|
481 |
{
|
482 |
do_action("ws_plugin__s2member_before_down_ops_page", get_defined_vars());
|
483 |
-
|
484 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
485 |
-
|
486 |
$files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
|
487 |
-
|
488 |
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/.htaccess";
|
489 |
$htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"])));
|
490 |
-
|
491 |
$no_gzip_htaccess = /* Always located in the absolute root path for WordPress®. */ ABSPATH.".htaccess";
|
492 |
$no_gzip_htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_no_gzip_htaccess"])));
|
493 |
-
|
494 |
if(!c_ws_plugin__s2member_files::no_gzip_rules_in_root_htaccess() /* If s2Member's GZIP exclusions do NOT yet exist in the root `.htaccess` file. */)
|
495 |
c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess(). /* Handle the root `.htaccess` file now. */clearstatcache();
|
496 |
-
|
497 |
if(!is_dir($files_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir))))
|
498 |
mkdir($files_dir, 0777, true). /* Create this directory structure now. */clearstatcache();
|
499 |
-
|
500 |
if(is_dir($files_dir) && is_writable($files_dir) && !file_exists($htaccess) /* This file does NOT exist yet? */)
|
501 |
file_put_contents($htaccess, $htaccess_contents). /* Create the `.htaccess` file now. */clearstatcache();
|
502 |
-
|
503 |
if(!c_ws_plugin__s2member_files::no_gzip_rules_in_root_htaccess /* If s2Member's GZIP exclusions do NOT yet exist in the root `.htaccess` file. */())
|
504 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Possible GZIP conflict on server. Unable to write GZIP exclusions into root .htaccess file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($no_gzip_htaccess)).'</code>). Please read the panel below: <strong>Preventing GZIP Conflicts</strong>, and add this section yourself:<br /><pre>'.esc_html($no_gzip_htaccess_contents).'</pre>', true);
|
505 |
-
|
506 |
-
if
|
507 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled files directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($files_dir)).'</code>) does not exist. Please create this directory manually.', true);
|
508 |
-
|
509 |
-
if
|
510 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
511 |
-
|
512 |
-
else if
|
513 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
514 |
-
|
515 |
if(!empty($_POST["ws_plugin__s2member_amazon_cf_files_auto_configure_distros"]) && ($nonce = $_POST["ws_plugin__s2member_amazon_cf_files_auto_configure_distros"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-amazon-cf-files-auto-configure-distros"))
|
516 |
if(($amazon_cf_auto_configure_distros = c_ws_plugin__s2member_files_in::amazon_cf_auto_configure_distros()) && $amazon_cf_auto_configure_distros["success"])
|
517 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Amazon® CloudFront Distributions auto-configured successfully. Please allow 30 minutes for propagation.'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]) ? '<br /><em>Downloads Distribution CNAME: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]).' —» '.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_dname"]).'</code></em>' : '').(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) ? '<br /><em>Streaming Distribution CNAME: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]).' —» '.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_dname"]).'</code></em>' : ''));
|
518 |
-
else
|
519 |
(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"] = true).c_ws_plugin__s2member_admin_notices::display_admin_notice('Unable to auto-configure Amazon® CloudFront Distributions.<br />Error code: <code>'.esc_html($amazon_cf_auto_configure_distros["code"]).'</code>. Error Message: <code>'.esc_html($amazon_cf_auto_configure_distros["message"]).'</code>', true);
|
520 |
-
|
521 |
if(!empty($_POST["ws_plugin__s2member_amazon_s3_files_auto_configure_acls"]) && ($nonce = $_POST["ws_plugin__s2member_amazon_s3_files_auto_configure_acls"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-amazon-s3-files-auto-configure-acls"))
|
522 |
if(($amazon_s3_auto_configure_acls = c_ws_plugin__s2member_files_in::amazon_s3_auto_configure_acls()) && $amazon_s3_auto_configure_acls["success"])
|
523 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Amazon® S3 ACLs auto-configured successfully.');
|
524 |
-
else
|
525 |
(c_ws_plugin__s2member_menu_pages::$pre_display_errors["s3_files_auto_configure_acls"] = true).c_ws_plugin__s2member_admin_notices::display_admin_notice('Unable to auto-configure Amazon® S3 ACLs.<br />Error code: <code>'.esc_html($amazon_s3_auto_configure_acls["code"]).'</code>. Error Message: <code>'.esc_html($amazon_s3_auto_configure_acls["message"]).'</code>', true);
|
526 |
-
|
527 |
include_once dirname(dirname(__FILE__))."/menu-pages/down-ops.inc.php";
|
528 |
-
|
529 |
do_action("ws_plugin__s2member_after_down_ops_page", get_defined_vars());
|
530 |
-
|
531 |
-
return
|
532 |
}
|
533 |
/**
|
534 |
* Builds and handles the API Tracking options page.
|
535 |
-
*
|
536 |
* @package s2Member\Menu_Pages
|
537 |
* @since 3.5
|
538 |
-
*
|
539 |
* @return null
|
540 |
*/
|
541 |
public static function trk_ops_page()
|
542 |
{
|
543 |
do_action("ws_plugin__s2member_before_trk_ops_page", get_defined_vars());
|
544 |
-
|
545 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
546 |
-
|
547 |
include_once dirname(dirname(__FILE__))."/menu-pages/trk-ops.inc.php";
|
548 |
-
|
549 |
do_action("ws_plugin__s2member_after_trk_ops_page", get_defined_vars());
|
550 |
-
|
551 |
-
return
|
552 |
}
|
553 |
/**
|
554 |
* Builds and handles the API List Server options page.
|
555 |
-
*
|
556 |
* @package s2Member\Menu_Pages
|
557 |
* @since 3.5
|
558 |
-
*
|
559 |
* @return null
|
560 |
*/
|
561 |
public static function els_ops_page()
|
562 |
{
|
563 |
do_action("ws_plugin__s2member_before_els_ops_page", get_defined_vars());
|
564 |
-
|
565 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
566 |
-
|
567 |
include_once dirname(dirname(__FILE__))."/menu-pages/els-ops.inc.php";
|
568 |
-
|
569 |
do_action("ws_plugin__s2member_after_els_ops_page", get_defined_vars());
|
570 |
-
|
571 |
-
return
|
572 |
}
|
573 |
/**
|
574 |
* Builds and handles the API Notifications page.
|
575 |
-
*
|
576 |
* @package s2Member\Menu_Pages
|
577 |
* @since 3.5
|
578 |
-
*
|
579 |
* @return null
|
580 |
*/
|
581 |
public static function api_ops_page()
|
582 |
{
|
583 |
do_action("ws_plugin__s2member_before_api_ops_page", get_defined_vars());
|
584 |
-
|
585 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
586 |
-
|
587 |
include_once dirname(dirname(__FILE__))."/menu-pages/api-ops.inc.php";
|
588 |
-
|
589 |
do_action("ws_plugin__s2member_after_api_ops_page", get_defined_vars());
|
590 |
-
|
591 |
-
return
|
592 |
}
|
593 |
/**
|
594 |
* Builds and handles the PayPal Button Generator page.
|
595 |
-
*
|
596 |
* @package s2Member\Menu_Pages
|
597 |
* @since 3.5
|
598 |
-
*
|
599 |
* @return null
|
600 |
*/
|
601 |
public static function paypal_buttons_page()
|
602 |
{
|
603 |
do_action("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars());
|
604 |
-
|
605 |
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"])
|
606 |
-
c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member
|
607 |
-
|
608 |
include_once dirname(dirname(__FILE__))."/menu-pages/paypal-buttons.inc.php";
|
609 |
-
|
610 |
do_action("ws_plugin__s2member_after_paypal_buttons_page", get_defined_vars());
|
611 |
-
|
612 |
-
return
|
613 |
}
|
614 |
/**
|
615 |
* Builds and handles the API Scripting page.
|
616 |
-
*
|
617 |
* @package s2Member\Menu_Pages
|
618 |
* @since 3.5
|
619 |
-
*
|
620 |
* @return null
|
621 |
*/
|
622 |
public static function scripting_page()
|
623 |
{
|
624 |
do_action("ws_plugin__s2member_before_scripting_page", get_defined_vars());
|
625 |
-
|
626 |
include_once dirname(dirname(__FILE__))."/menu-pages/scripting.inc.php";
|
627 |
-
|
628 |
do_action("ws_plugin__s2member_after_scripting_page", get_defined_vars());
|
629 |
-
|
630 |
-
return
|
631 |
}
|
632 |
/**
|
633 |
* Builds and handles the Integrations page.
|
634 |
-
*
|
635 |
* @package s2Member\Menu_Pages
|
636 |
* @since 3.5
|
637 |
-
*
|
638 |
* @return null
|
639 |
*/
|
640 |
public static function integrations_page()
|
641 |
{
|
642 |
do_action("ws_plugin__s2member_before_integrations_page", get_defined_vars());
|
643 |
-
|
644 |
include_once dirname(dirname(__FILE__))."/menu-pages/integrations.inc.php";
|
645 |
-
|
646 |
do_action("ws_plugin__s2member_after_integrations_page", get_defined_vars());
|
647 |
-
|
648 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
}
|
650 |
/**
|
651 |
* Builds and handles the s2Member Info page.
|
652 |
-
*
|
653 |
* @package s2Member\Menu_Pages
|
654 |
* @since 3.5
|
655 |
-
*
|
656 |
* @return null
|
657 |
*/
|
658 |
public static function info_page()
|
659 |
{
|
660 |
do_action("ws_plugin__s2member_before_info_page", get_defined_vars());
|
661 |
-
|
662 |
include_once dirname(dirname(__FILE__))."/menu-pages/info.inc.php";
|
663 |
-
|
664 |
do_action("ws_plugin__s2member_after_info_page", get_defined_vars());
|
665 |
-
|
666 |
-
return
|
667 |
}
|
668 |
}
|
669 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_menu_pages"))
|
21 |
{
|
22 |
/**
|
38 |
public static $pre_display_errors = array();
|
39 |
/**
|
40 |
* Saves all options from any menu page.
|
41 |
+
*
|
42 |
* Can also be self-verified; and configured extensively with function parameters.
|
43 |
*
|
44 |
* @package s2Member\Menu_Pages
|
55 |
*/
|
56 |
public static function update_all_options($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
|
57 |
{
|
58 |
+
$updated_all_options = false; // Initialize this to a value of false. Initializing this variable here makes it an available reference-variable to Hooks/Filters.
|
59 |
+
|
60 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
61 |
+
do_action("ws_plugin__s2member_before_update_all_options", get_defined_vars()); // If you use this Hook, be sure to use ``wp_verify_nonce()``.
|
62 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
63 |
+
|
64 |
if($verified || (!empty($_POST["ws_plugin__s2member_options_save"]) && ($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-options-save")))
|
65 |
{
|
66 |
+
$options = /* Acquire the full existing configuration options array here. */ $GLOBALS["WS_PLUGIN__"]["s2member"]["o"];
|
67 |
+
|
68 |
$new_options = (is_array($new_options)) ? $new_options : ((!empty($_POST) && is_array($_POST)) ? stripslashes_deep($_POST) : array());
|
69 |
$new_options = c_ws_plugin__s2member_utils_strings::trim_deep($new_options);
|
70 |
+
|
71 |
+
foreach /* Find all keys contained within ``$new_options`` matching `^ws_plugin__s2member_`. */($new_options as $key => $value)
|
72 |
+
if /* A relevant ``$new_options`` key matching `^ws_plugin__s2member_`? */(strpos($key, "ws_plugin__s2member_") === 0)
|
73 |
+
|
74 |
+
if /* s2Member is now configured (according to these options)? */($key === "ws_plugin__s2member_configured")
|
75 |
($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = $value).update_option("ws_plugin__s2member_configured", $value);
|
76 |
+
|
77 |
else if(!is_array($value) || (is_array($value) && /* Updating an array? */ array_shift($value) === "update-signal"))
|
78 |
$options[preg_replace("/^".preg_quote("ws_plugin__s2member_", "/")."/", "", $key)] = $value;
|
79 |
+
|
80 |
+
unset /* Unset these utility variables now. This prevents bleeding vars into Hooks/Filters that are of no use. */($key, $value);
|
81 |
+
|
82 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
83 |
+
do_action("ws_plugin__s2member_during_update_all_options", get_defined_vars()); // If you use this Hook, be sure to use ``wp_verify_nonce()``.
|
84 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
85 |
+
|
86 |
$options = ws_plugin__s2member_configure_options_and_their_defaults(($options = array_merge($options, array("options_version" => (string)($options["options_version"] + 0.001)))));
|
87 |
update_option("ws_plugin__s2member_options", $options).((is_multisite() && is_main_site()) ? update_site_option("ws_plugin__s2member_options", $options) : null).update_option("ws_plugin__s2member_cache", array());
|
88 |
+
|
89 |
+
if($update_other === true || in_array("auto_eot_system", (array)$update_other)) // Handle the Auto-EOT System now (enable/disable).
|
90 |
($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();
|
91 |
+
|
92 |
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>'))
|
93 |
($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);
|
94 |
+
|
95 |
+
if(empty($_GET["page"]) || $_GET["page"] !== "ws-plugin--s2member-mms-ops") // Do NOT display page-conflict-warnings on the Main Multisite Configuration panel.
|
96 |
{
|
97 |
+
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>.'))
|
98 |
($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);
|
99 |
+
|
100 |
+
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>.'))
|
101 |
($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);
|
102 |
+
|
103 |
+
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>.'))
|
104 |
($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);
|
105 |
+
|
106 |
+
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>.'))
|
107 |
($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);
|
108 |
+
|
109 |
+
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>.'))
|
110 |
($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);
|
111 |
+
|
112 |
+
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>.'))
|
113 |
($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);
|
114 |
+
|
115 |
+
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>.'))
|
116 |
($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);
|
117 |
}
|
118 |
+
$updated_all_options = /* Flag indicating this routine was processed successfully; and that all s2Member options have been updated successfully.*/ true;
|
|
|
119 |
}
|
120 |
+
|
121 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
122 |
+
do_action("ws_plugin__s2member_after_update_all_options", get_defined_vars()); // If you use this Hook, be sure to use ``wp_verify_nonce()``.
|
123 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
124 |
+
|
125 |
return apply_filters("ws_plugin__s2member_update_all_options", (($updated_all_options) ? true : false), get_defined_vars());
|
126 |
}
|
127 |
/**
|
128 |
* Adds option menus / sub-menus.
|
129 |
+
*
|
130 |
* @package s2Member\Menu_Pages
|
131 |
* @since 3.5
|
132 |
+
*
|
133 |
* @attaches-to ``add_action("admin_menu");``
|
134 |
*
|
135 |
* @return null
|
137 |
public static function add_admin_options()
|
138 |
{
|
139 |
do_action("ws_plugin__s2member_before_add_admin_options", get_defined_vars());
|
140 |
+
|
141 |
add_filter("plugin_action_links", "c_ws_plugin__s2member_menu_pages::_add_settings_link", 10, 2);
|
142 |
+
|
143 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars()))
|
144 |
{
|
145 |
if((is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) || apply_filters("ws_plugin__s2member_during_add_admin_options_clear_right_side", false, get_defined_vars()))
|
146 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = /* Clear right side. */ array();
|
147 |
+
|
148 |
$menu = apply_filters("ws_plugin__s2member_during_add_admin_options_menu_slug", "ws-plugin--s2member-start", get_defined_vars());
|
149 |
+
|
150 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_menu_page", true, get_defined_vars()))
|
151 |
add_menu_page("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::start_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images/brand-favicon.png");
|
152 |
+
|
153 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars()))
|
154 |
+
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");
|
155 |
+
|
156 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_1", true, get_defined_vars()))
|
157 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
158 |
+
|
159 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_mms_ops_page", (!is_multisite() || is_main_site()), get_defined_vars()))
|
160 |
+
add_submenu_page($menu, "s2Member® Multisite Configuration", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-ops", "c_ws_plugin__s2member_menu_pages::mms_ops_page");
|
161 |
+
|
162 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_gen_ops_page", true, get_defined_vars()))
|
163 |
+
add_submenu_page($menu, "s2Member® General Options", "General Options", "create_users", "ws-plugin--s2member-gen-ops", "c_ws_plugin__s2member_menu_pages::gen_ops_page");
|
164 |
+
|
165 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_res_ops_page", true, get_defined_vars()))
|
166 |
+
add_submenu_page($menu, "s2Member® Restriction Options", "Restriction Options", "create_users", "ws-plugin--s2member-res-ops", "c_ws_plugin__s2member_menu_pages::res_ops_page");
|
167 |
+
|
168 |
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()))
|
169 |
+
add_submenu_page($menu, "s2Member® Download Options", "Download Options", "create_users", "ws-plugin--s2member-down-ops", "c_ws_plugin__s2member_menu_pages::down_ops_page");
|
170 |
+
|
171 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_2", true, get_defined_vars()))
|
172 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
173 |
+
|
174 |
+
if /* Shortcut. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars()))
|
175 |
+
add_submenu_page($menu, "s2Member® / Add A Member", "Add A Member", "create_users", "user-new.php");
|
176 |
+
|
177 |
+
if /* Shortcut. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_browse_users_page", true, get_defined_vars()))
|
178 |
+
add_submenu_page($menu, "s2Member® / Browse Members", "Browse Members", "create_users", "users.php");
|
179 |
+
|
180 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_3", true, get_defined_vars()))
|
181 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
182 |
+
|
183 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars()))
|
184 |
+
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");
|
185 |
+
|
186 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars()))
|
187 |
+
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");
|
188 |
+
|
189 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_4", true, get_defined_vars()))
|
190 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
191 |
+
|
192 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars()))
|
193 |
+
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");
|
194 |
+
|
195 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_els_ops_page", true, get_defined_vars()))
|
196 |
+
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");
|
197 |
+
|
198 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_api_ops_page", true, get_defined_vars()))
|
199 |
+
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");
|
200 |
+
|
201 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars()))
|
202 |
+
add_submenu_page($menu, "s2Member® API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "c_ws_plugin__s2member_menu_pages::scripting_page");
|
203 |
+
|
204 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_5", true, get_defined_vars()))
|
205 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
206 |
+
|
207 |
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_integrations_page", (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()), get_defined_vars()))
|
208 |
+
add_submenu_page($menu, "s2Member® / Other Integrations", "Other Integrations", "create_users", "ws-plugin--s2member-integrations", "c_ws_plugin__s2member_menu_pages::integrations_page");
|
209 |
+
|
210 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_6", true, get_defined_vars()))
|
211 |
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
212 |
+
|
213 |
+
if(apply_filters("ws_plugin__s2member_during_add_admin_options_add_logs_page", (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()), get_defined_vars()))
|
214 |
+
add_submenu_page($menu, "s2Member® Logs", "Log Files (Debug)", "create_users", "ws-plugin--s2member-logs", "c_ws_plugin__s2member_menu_pages::logs_page");
|
215 |
+
|
216 |
+
if /* Divider. */(apply_filters("ws_plugin__s2member_during_add_admin_options_add_divider_7", (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()), get_defined_vars()))
|
217 |
+
add_submenu_page($menu, "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
|
218 |
+
|
219 |
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()))
|
220 |
+
add_submenu_page($menu, "s2Member® Information", "s2Member® Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
221 |
+
|
222 |
do_action("ws_plugin__s2member_during_add_admin_options_additional_pages", get_defined_vars());
|
223 |
}
|
224 |
+
|
225 |
do_action("ws_plugin__s2member_after_add_admin_options", get_defined_vars());
|
226 |
+
|
227 |
+
return /* Return for uniformity. */;
|
228 |
}
|
229 |
/**
|
230 |
* Adds network option menus / sub-menus.
|
231 |
+
*
|
232 |
* @package s2Member\Menu_Pages
|
233 |
* @since 3.5
|
234 |
+
*
|
235 |
* @attaches-to ``add_action("network_admin_menu");``
|
236 |
*
|
237 |
* @return null
|
239 |
public static function add_network_admin_options()
|
240 |
{
|
241 |
do_action("ws_plugin__s2member_before_add_network_admin_options", get_defined_vars());
|
242 |
+
|
243 |
if(apply_filters("ws_plugin__s2member_during_add_network_admin_options_create_menu_items", true, get_defined_vars()))
|
244 |
{
|
245 |
if((is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) || apply_filters("ws_plugin__s2member_during_add_network_admin_options_clear_right_side", false, get_defined_vars()))
|
246 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = /* Clear right side. */ array();
|
247 |
+
|
248 |
+
$menu = /* Used below for nesting additional sub-menu pages. */ "ws-plugin--s2member-mms-ops";
|
249 |
+
|
250 |
add_menu_page("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::mms_ops_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images/brand-favicon.png");
|
251 |
+
|
252 |
+
add_submenu_page($menu, "s2Member Multisite (Configuration)", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-ops", "c_ws_plugin__s2member_menu_pages::mms_ops_page");
|
253 |
+
|
254 |
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()))
|
255 |
add_submenu_page($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
|
256 |
+
|
257 |
do_action("ws_plugin__s2member_during_add_network_admin_options_additional_pages", get_defined_vars());
|
258 |
}
|
259 |
+
|
260 |
do_action("ws_plugin__s2member_after_add_network_admin_options", get_defined_vars());
|
261 |
+
|
262 |
+
return /* Return for uniformity. */;
|
263 |
}
|
264 |
/**
|
265 |
* A sort of callback function to add the settings link.
|
266 |
+
*
|
267 |
* @package s2Member\Menu_Pages
|
268 |
* @since 3.5
|
269 |
+
*
|
270 |
* @attaches-to ``add_filter("plugin_action_links");``
|
271 |
*
|
272 |
* @param array $actions Expects an existing array of actions links, passed in by the Filter.
|
275 |
*/
|
276 |
public static function _add_settings_link($actions = FALSE, $plugin_file = FALSE)
|
277 |
{
|
278 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
279 |
do_action("_ws_plugin__s2member_before_add_settings_link", get_defined_vars());
|
280 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
281 |
+
|
282 |
if($plugin_file === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["plugin_basename"] && is_array($actions))
|
283 |
{
|
284 |
$settings = '<a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-gen-ops")).'">Settings</a>';
|
285 |
array_unshift($actions, apply_filters("ws_plugin__s2member_add_settings_link", $settings, get_defined_vars()));
|
286 |
+
|
287 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
288 |
do_action("_ws_plugin__s2member_during_add_settings_link", get_defined_vars());
|
289 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
290 |
}
|
291 |
+
|
292 |
return apply_filters("_ws_plugin__s2member_add_settings_link", $actions, get_defined_vars());
|
293 |
}
|
294 |
/**
|
295 |
* Enqueue scripts for administrative menu pages.
|
296 |
+
*
|
297 |
* @package s2Member\Menu_Pages
|
298 |
* @since 3.5
|
299 |
+
*
|
300 |
* @attaches-to ``add_action("admin_print_scripts");``
|
301 |
*
|
302 |
* @return null
|
304 |
public static function add_admin_scripts()
|
305 |
{
|
306 |
do_action("ws_plugin__s2member_before_add_admin_scripts", get_defined_vars());
|
307 |
+
|
308 |
if(!empty($_GET["page"]) && preg_match("/ws-plugin--s2member-/", $_GET["page"]))
|
309 |
{
|
310 |
wp_enqueue_script("jquery");
|
315 |
wp_enqueue_script("jquery-json-ps", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/includes/jquery/jquery.json-ps/jquery.json-ps-min.js", array("jquery"), c_ws_plugin__s2member_utilities::ver_checksum());
|
316 |
wp_enqueue_script("jquery-ui-effects", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/includes/jquery/jquery.ui-effects/jquery.ui-effects-min.js", array("jquery", "jquery-ui-core"), c_ws_plugin__s2member_utilities::ver_checksum());
|
317 |
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-sprintf", "jquery-json-ps", "jquery-ui-core", "jquery-ui-effects", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum());
|
318 |
+
|
319 |
do_action("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars());
|
320 |
}
|
321 |
+
|
322 |
do_action("ws_plugin__s2member_after_add_admin_scripts", get_defined_vars());
|
323 |
+
|
324 |
+
return /* Return for uniformity. */;
|
325 |
}
|
326 |
/**
|
327 |
* Enqueue styles for administrative menu pages.
|
328 |
+
*
|
329 |
* @package s2Member\Menu_Pages
|
330 |
* @since 3.5
|
331 |
+
*
|
332 |
* @attaches-to ``add_action("admin_print_styles");``
|
333 |
*
|
334 |
* @return null
|
336 |
public static function add_admin_styles()
|
337 |
{
|
338 |
do_action("ws_plugin__s2member_before_add_admin_styles", get_defined_vars());
|
339 |
+
|
340 |
if(!empty($_GET["page"]) && preg_match("/ws-plugin--s2member-/", $_GET["page"]))
|
341 |
{
|
342 |
wp_enqueue_style("thickbox");
|
343 |
wp_enqueue_style("ws-plugin--s2member-menu-pages", site_url("/?ws_plugin__s2member_menu_pages_css=".urlencode(mt_rand())), array("thickbox"), c_ws_plugin__s2member_utilities::ver_checksum(), "all");
|
344 |
+
|
345 |
do_action("ws_plugin__s2member_during_add_admin_styles", get_defined_vars());
|
346 |
}
|
347 |
+
|
348 |
do_action("ws_plugin__s2member_after_add_admin_styles", get_defined_vars());
|
349 |
+
|
350 |
+
return /* Return for uniformity. */;
|
351 |
+
}
|
352 |
+
/**
|
353 |
+
* Handles log file downloads.
|
354 |
+
*
|
355 |
+
* @package s2Member\Menu_Pages
|
356 |
+
* @since 120310
|
357 |
+
*
|
358 |
+
* @return null
|
359 |
+
*/
|
360 |
+
public static function log_file_downloader()
|
361 |
+
{
|
362 |
+
if(!current_user_can("create_users")) return;
|
363 |
+
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
364 |
+
return; // We do NOT provide this functionality on Child Blogs of a Blog Farm Network.
|
365 |
+
|
366 |
+
if(!empty($_GET["ws_plugin__s2member_download_log_file"]) && is_string($log_file = $_GET["ws_plugin__s2member_download_log_file"]) && strpos($log_file, "..") === false && strpos(basename($log_file), ".") !== 0)
|
367 |
+
if(!empty($_GET["ws_plugin__s2member_download_log_file_v"]) && is_string($nonce = $_GET["ws_plugin__s2member_download_log_file_v"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-download-log-file-v"))
|
368 |
+
{
|
369 |
+
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
370 |
+
|
371 |
+
if(file_exists($logs_dir."/".$log_file))
|
372 |
+
$log_file_contents = file_get_contents($logs_dir."/".$log_file);
|
373 |
+
else $log_file_contents = "";
|
374 |
+
|
375 |
+
@set_time_limit(0);
|
376 |
+
@ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
|
377 |
+
|
378 |
+
@ini_set("zlib.output_compression", 0);
|
379 |
+
if(function_exists("apache_setenv"))
|
380 |
+
@apache_setenv("no-gzip", "1");
|
381 |
+
|
382 |
+
while (@ob_end_clean ());
|
383 |
+
|
384 |
+
status_header(200); // 200 OK status header.
|
385 |
+
|
386 |
+
header("Content-Encoding: none");
|
387 |
+
header("Accept-Ranges: none");
|
388 |
+
header("Content-Type: text/plain; charset=UTF-8");
|
389 |
+
header("Content-Length: ".strlen($log_file_contents));
|
390 |
+
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
391 |
+
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
392 |
+
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
393 |
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
394 |
+
header("Pragma: no-cache");
|
395 |
+
|
396 |
+
header('Content-Disposition: attachment; filename="'.$log_file.'"');
|
397 |
+
|
398 |
+
exit($log_file_contents); // Log file.
|
399 |
+
}
|
400 |
+
}
|
401 |
+
/**
|
402 |
+
* Handles log file downloads (in ZIP format).
|
403 |
+
*
|
404 |
+
* @package s2Member\Menu_Pages
|
405 |
+
* @since 120310
|
406 |
+
*
|
407 |
+
* @return null
|
408 |
+
*/
|
409 |
+
public static function logs_zip_downloader()
|
410 |
+
{
|
411 |
+
if(!current_user_can("create_users")) return;
|
412 |
+
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
413 |
+
return; // We do NOT provide this functionality on Child Blogs of a Blog Farm Network.
|
414 |
+
|
415 |
+
if(!empty($_POST["ws_plugin__s2member_logs_download_zip"]) && is_string($nonce = $_POST["ws_plugin__s2member_logs_download_zip"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-logs-download-zip"))
|
416 |
+
{
|
417 |
+
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
418 |
+
$s2member_logs_zip = $logs_dir."/".$_SERVER["HTTP_HOST"]."--s2member-logs.zip";
|
419 |
+
|
420 |
+
if(is_dir($logs_dir)) // Do we have a logs directory?
|
421 |
+
{
|
422 |
+
include_once ABSPATH . "wp-admin/includes/class-pclzip.php";
|
423 |
+
|
424 |
+
if(file_exists($s2member_logs_zip) && is_writable($s2member_logs_zip))
|
425 |
+
unlink($s2member_logs_zip);
|
426 |
+
|
427 |
+
$archive = new PclZip($s2member_logs_zip);
|
428 |
+
$archive->create($logs_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
|
429 |
+
}
|
430 |
+
|
431 |
+
if(file_exists($s2member_logs_zip))
|
432 |
+
$s2member_logs_zip_size = filesize($s2member_logs_zip);
|
433 |
+
else $s2member_logs_zip_size = 0;
|
434 |
+
|
435 |
+
@set_time_limit(0);
|
436 |
+
@ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
|
437 |
+
|
438 |
+
@ini_set("zlib.output_compression", 0);
|
439 |
+
if(function_exists("apache_setenv"))
|
440 |
+
@apache_setenv("no-gzip", "1");
|
441 |
+
|
442 |
+
while (@ob_end_clean ());
|
443 |
+
|
444 |
+
status_header(200); // 200 OK status header.
|
445 |
+
|
446 |
+
header("Content-Encoding: none");
|
447 |
+
header("Accept-Ranges: none");
|
448 |
+
header("Content-Type: application/zip");
|
449 |
+
header("Content-Length: ".$s2member_logs_zip_size);
|
450 |
+
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
|
451 |
+
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
452 |
+
header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
453 |
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
454 |
+
header("Pragma: no-cache");
|
455 |
+
|
456 |
+
header('Content-Disposition: attachment; filename="'.basename($s2member_logs_zip).'"');
|
457 |
+
|
458 |
+
if($s2member_logs_zip_size && is_resource($resource = fopen($s2member_logs_zip, "rb")))
|
459 |
+
{
|
460 |
+
$_bytes_to_read = $s2member_logs_zip_size; // Total bytes we need to read for this file.
|
461 |
+
|
462 |
+
$chunk_size = apply_filters("ws_plugin__s2member_file_downloads_chunk_size", 2097152, get_defined_vars());
|
463 |
+
|
464 |
+
while /* We have bytes to read here. */($_bytes_to_read)
|
465 |
+
{
|
466 |
+
$_bytes_to_read -= ($_reading = ($_bytes_to_read > $chunk_size) ? $chunk_size : $_bytes_to_read);
|
467 |
+
echo /* Serve file in chunks (default chunk size is 2MB). */ fread($resource, $_reading);
|
468 |
+
flush /* Flush each chunk to the browser as it is served (avoids high memory consumption). */();
|
469 |
+
}
|
470 |
+
fclose /* Close file resource handle. */($resource);
|
471 |
+
unset /* Housekeeping. */($_bytes_to_read, $_reading);
|
472 |
+
}
|
473 |
+
exit; // Clean exit after serving file.
|
474 |
+
}
|
475 |
+
}
|
476 |
+
/**
|
477 |
+
* Archives existing log files and starts fresh with new logs.
|
478 |
+
*
|
479 |
+
* @package s2Member\Menu_Pages
|
480 |
+
* @since 120310
|
481 |
+
*
|
482 |
+
* @return null
|
483 |
+
*/
|
484 |
+
public static function archive_logs_start_fresh()
|
485 |
+
{
|
486 |
+
if(!current_user_can("create_users")) return;
|
487 |
+
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
488 |
+
return; // We do NOT provide this functionality on Child Blogs of a Blog Farm Network.
|
489 |
+
|
490 |
+
if(!empty($_POST["ws_plugin__s2member_logs_archive_start_fresh"]) && is_string($nonce = $_POST["ws_plugin__s2member_logs_archive_start_fresh"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-logs-archive-start-fresh"))
|
491 |
+
{
|
492 |
+
if(is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
493 |
+
foreach(scandir($logs_dir) as $log_file) // Archive existing log files here.
|
494 |
+
{
|
495 |
+
if(preg_match("/\.log$/", $log_file) && stripos($log_file, "-ARCHIVED-") === FALSE)
|
496 |
+
if(is_file ($log_dir_file = $logs_dir . "/" . $log_file) && is_writable($log_dir_file))
|
497 |
+
if(!rename ($log_dir_file, preg_replace ("/\.log$/i", "", $log_dir_file) . "-ARCHIVED-" . date ("m-d-Y") . "-" . time () . ".log"))
|
498 |
+
$error = true;
|
499 |
+
}
|
500 |
+
if(!empty($error))
|
501 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice("Unknown error when attempting to archive log files. Please check directory permissions.", true);
|
502 |
+
else c_ws_plugin__s2member_admin_notices::display_admin_notice("All log files have been archived succesfully.");
|
503 |
+
}
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Deletes existing log files and starts fresh with new logs.
|
508 |
+
*
|
509 |
+
* @package s2Member\Menu_Pages
|
510 |
+
* @since 120312
|
511 |
+
*
|
512 |
+
* @return null
|
513 |
+
*/
|
514 |
+
public static function delete_logs_start_fresh()
|
515 |
+
{
|
516 |
+
if(!current_user_can("create_users")) return;
|
517 |
+
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site())
|
518 |
+
return; // We do NOT provide this functionality on Child Blogs of a Blog Farm Network.
|
519 |
+
|
520 |
+
if(!empty($_POST["ws_plugin__s2member_logs_delete_start_fresh"]) && is_string($nonce = $_POST["ws_plugin__s2member_logs_delete_start_fresh"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-logs-delete-start-fresh"))
|
521 |
+
{
|
522 |
+
if(is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
523 |
+
foreach(scandir($logs_dir) as $log_file) // Delete existing log files here.
|
524 |
+
{
|
525 |
+
if(preg_match("/\.log$/", $log_file))
|
526 |
+
if(is_file ($log_dir_file = $logs_dir . "/" . $log_file) && is_writable($log_dir_file))
|
527 |
+
if(!unlink($log_dir_file)) $error = true;
|
528 |
+
}
|
529 |
+
if(!empty($error))
|
530 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice("Unknown error when attempting to delete log files. Please check directory permissions.", true);
|
531 |
+
else c_ws_plugin__s2member_admin_notices::display_admin_notice("All log files have been deleted succesfully.");
|
532 |
+
}
|
533 |
}
|
534 |
/**
|
535 |
* Builds and handles the Quick Start page.
|
536 |
+
*
|
537 |
* @package s2Member\Menu_Pages
|
538 |
* @since 3.5
|
539 |
+
*
|
540 |
* @return null
|
541 |
*/
|
542 |
public static function start_page()
|
543 |
{
|
544 |
do_action("ws_plugin__s2member_before_start_page", get_defined_vars());
|
545 |
+
|
546 |
include_once dirname(dirname(__FILE__))."/menu-pages/start.inc.php";
|
547 |
+
|
548 |
do_action("ws_plugin__s2member_after_start_page", get_defined_vars());
|
549 |
+
|
550 |
+
return /* Return for uniformity. */;
|
551 |
}
|
552 |
/**
|
553 |
* Builds and handles the Main Multisite Options page.
|
554 |
+
*
|
555 |
* @package s2Member\Menu_Pages
|
556 |
* @since 3.5
|
557 |
+
*
|
558 |
* @return null
|
559 |
*/
|
560 |
public static function mms_ops_page()
|
561 |
{
|
562 |
do_action("ws_plugin__s2member_before_mms_ops_page", get_defined_vars());
|
563 |
+
|
564 |
if(c_ws_plugin__s2member_menu_pages::update_all_options())
|
565 |
c_ws_plugin__s2member_mms_patches::mms_patches(true);
|
566 |
+
|
567 |
include_once dirname(dirname(__FILE__))."/menu-pages/mms-ops.inc.php";
|
568 |
+
|
569 |
do_action("ws_plugin__s2member_after_mms_ops_page", get_defined_vars());
|
570 |
+
|
571 |
+
return /* Return for uniformity. */;
|
572 |
}
|
573 |
/**
|
574 |
* Builds and handles the General Options page.
|
575 |
+
*
|
576 |
* @package s2Member\Menu_Pages
|
577 |
* @since 3.5
|
578 |
+
*
|
579 |
* @return null
|
580 |
*/
|
581 |
public static function gen_ops_page()
|
582 |
{
|
583 |
do_action("ws_plugin__s2member_before_gen_ops_page", get_defined_vars());
|
584 |
+
|
585 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
586 |
+
|
587 |
include_once dirname(dirname(__FILE__))."/menu-pages/gen-ops.inc.php";
|
588 |
+
|
589 |
do_action("ws_plugin__s2member_after_gen_ops_page", get_defined_vars());
|
590 |
+
|
591 |
+
return /* Return for uniformity. */;
|
592 |
}
|
593 |
/**
|
594 |
* Builds and handles the Restriction Options page.
|
595 |
+
*
|
596 |
* @package s2Member\Menu_Pages
|
597 |
* @since 3.5
|
598 |
+
*
|
599 |
* @return null
|
600 |
*/
|
601 |
public static function res_ops_page()
|
602 |
{
|
603 |
do_action("ws_plugin__s2member_before_res_ops_page", get_defined_vars());
|
604 |
+
|
605 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
606 |
+
|
607 |
include_once dirname(dirname(__FILE__))."/menu-pages/res-ops.inc.php";
|
608 |
+
|
609 |
do_action("ws_plugin__s2member_after_res_ops_page", get_defined_vars());
|
610 |
+
|
611 |
+
return /* Return for uniformity. */;
|
612 |
}
|
613 |
/**
|
614 |
* Builds and handles the Paypal Options page.
|
615 |
+
*
|
616 |
* @package s2Member\Menu_Pages
|
617 |
* @since 3.5
|
618 |
+
*
|
619 |
* @return null
|
620 |
*/
|
621 |
public static function paypal_ops_page()
|
622 |
{
|
623 |
do_action("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars());
|
624 |
+
|
625 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
626 |
+
|
627 |
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
628 |
+
|
629 |
if(!is_dir($logs_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir))))
|
630 |
mkdir($logs_dir, 0777, true).clearstatcache();
|
631 |
+
|
632 |
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]."/.htaccess";
|
633 |
$htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"])));
|
634 |
+
|
635 |
if(is_dir($logs_dir) && is_writable($logs_dir) && !file_exists($htaccess))
|
636 |
file_put_contents($htaccess, $htaccess_contents).clearstatcache();
|
637 |
+
|
638 |
+
if /* Logging enabled? */($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
639 |
{
|
640 |
+
if /* If the security-enabled logs directory does not exist yet. */(!is_dir($logs_dir))
|
641 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled logs directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)).'</code>) does not exist. Please create this directory manually & make it writable (chmod 777).', true);
|
642 |
+
|
643 |
+
else if /* If the logs directory is not writable yet. */(!is_writable($logs_dir))
|
644 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('Permissions error. The security-enabled logs directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)).'</code>) is not writable. Please make this directory writable (chmod 777).', true);
|
645 |
+
|
646 |
+
if /* If the .htaccess file has not been created yet. */(!file_exists($htaccess))
|
647 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
648 |
+
|
649 |
+
else if /* Else if the .htaccess file does not offer the required protection. */(!preg_match("/deny from all/i", file_get_contents($htaccess)))
|
650 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
651 |
}
|
652 |
+
|
653 |
include_once dirname(dirname(__FILE__))."/menu-pages/paypal-ops.inc.php";
|
654 |
+
|
655 |
do_action("ws_plugin__s2member_after_paypal_ops_page", get_defined_vars());
|
656 |
+
|
657 |
+
return /* Return for uniformity. */;
|
658 |
}
|
659 |
/**
|
660 |
* Builds and handles the Download Options page.
|
661 |
+
*
|
662 |
* @package s2Member\Menu_Pages
|
663 |
* @since 3.5
|
664 |
+
*
|
665 |
* @return null
|
666 |
*/
|
667 |
public static function down_ops_page()
|
668 |
{
|
669 |
do_action("ws_plugin__s2member_before_down_ops_page", get_defined_vars());
|
670 |
+
|
671 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
672 |
+
|
673 |
$files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
|
674 |
+
|
675 |
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]."/.htaccess";
|
676 |
$htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"])));
|
677 |
+
|
678 |
$no_gzip_htaccess = /* Always located in the absolute root path for WordPress®. */ ABSPATH.".htaccess";
|
679 |
$no_gzip_htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_no_gzip_htaccess"])));
|
680 |
+
|
681 |
if(!c_ws_plugin__s2member_files::no_gzip_rules_in_root_htaccess() /* If s2Member's GZIP exclusions do NOT yet exist in the root `.htaccess` file. */)
|
682 |
c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess(). /* Handle the root `.htaccess` file now. */clearstatcache();
|
683 |
+
|
684 |
if(!is_dir($files_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir))))
|
685 |
mkdir($files_dir, 0777, true). /* Create this directory structure now. */clearstatcache();
|
686 |
+
|
687 |
if(is_dir($files_dir) && is_writable($files_dir) && !file_exists($htaccess) /* This file does NOT exist yet? */)
|
688 |
file_put_contents($htaccess, $htaccess_contents). /* Create the `.htaccess` file now. */clearstatcache();
|
689 |
+
|
690 |
if(!c_ws_plugin__s2member_files::no_gzip_rules_in_root_htaccess /* If s2Member's GZIP exclusions do NOT yet exist in the root `.htaccess` file. */())
|
691 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Possible GZIP conflict on server. Unable to write GZIP exclusions into root .htaccess file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($no_gzip_htaccess)).'</code>). Please read the panel below: <strong>Preventing GZIP Conflicts</strong>, and add this section yourself:<br /><pre>'.esc_html($no_gzip_htaccess_contents).'</pre>', true);
|
692 |
+
|
693 |
+
if /* If the security-enabled files directory does not exist yet. */(!is_dir($files_dir))
|
694 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled files directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($files_dir)).'</code>) does not exist. Please create this directory manually.', true);
|
695 |
+
|
696 |
+
if /* If the `.htaccess` file has not been created yet. */(!file_exists($htaccess))
|
697 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
698 |
+
|
699 |
+
else if /* Else if the `.htaccess` file does not offer the required protection. */(!preg_match("/deny from all/i", file_get_contents($htaccess)))
|
700 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
701 |
+
|
702 |
if(!empty($_POST["ws_plugin__s2member_amazon_cf_files_auto_configure_distros"]) && ($nonce = $_POST["ws_plugin__s2member_amazon_cf_files_auto_configure_distros"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-amazon-cf-files-auto-configure-distros"))
|
703 |
if(($amazon_cf_auto_configure_distros = c_ws_plugin__s2member_files_in::amazon_cf_auto_configure_distros()) && $amazon_cf_auto_configure_distros["success"])
|
704 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Amazon® CloudFront Distributions auto-configured successfully. Please allow 30 minutes for propagation.'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]) ? '<br /><em>Downloads Distribution CNAME: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]).' —» '.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_dname"]).'</code></em>' : '').(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) ? '<br /><em>Streaming Distribution CNAME: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]).' —» '.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_dname"]).'</code></em>' : ''));
|
705 |
+
else // Else there was an error. We need to report this back to the site owner so they can understand what's going on.
|
706 |
(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"] = true).c_ws_plugin__s2member_admin_notices::display_admin_notice('Unable to auto-configure Amazon® CloudFront Distributions.<br />Error code: <code>'.esc_html($amazon_cf_auto_configure_distros["code"]).'</code>. Error Message: <code>'.esc_html($amazon_cf_auto_configure_distros["message"]).'</code>', true);
|
707 |
+
|
708 |
if(!empty($_POST["ws_plugin__s2member_amazon_s3_files_auto_configure_acls"]) && ($nonce = $_POST["ws_plugin__s2member_amazon_s3_files_auto_configure_acls"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-amazon-s3-files-auto-configure-acls"))
|
709 |
if(($amazon_s3_auto_configure_acls = c_ws_plugin__s2member_files_in::amazon_s3_auto_configure_acls()) && $amazon_s3_auto_configure_acls["success"])
|
710 |
c_ws_plugin__s2member_admin_notices::display_admin_notice('Amazon® S3 ACLs auto-configured successfully.');
|
711 |
+
else // Else there was an error. We need to report this back to the site owner so they can understand what's going on.
|
712 |
(c_ws_plugin__s2member_menu_pages::$pre_display_errors["s3_files_auto_configure_acls"] = true).c_ws_plugin__s2member_admin_notices::display_admin_notice('Unable to auto-configure Amazon® S3 ACLs.<br />Error code: <code>'.esc_html($amazon_s3_auto_configure_acls["code"]).'</code>. Error Message: <code>'.esc_html($amazon_s3_auto_configure_acls["message"]).'</code>', true);
|
713 |
+
|
714 |
include_once dirname(dirname(__FILE__))."/menu-pages/down-ops.inc.php";
|
715 |
+
|
716 |
do_action("ws_plugin__s2member_after_down_ops_page", get_defined_vars());
|
717 |
+
|
718 |
+
return /* Return for uniformity. */;
|
719 |
}
|
720 |
/**
|
721 |
* Builds and handles the API Tracking options page.
|
722 |
+
*
|
723 |
* @package s2Member\Menu_Pages
|
724 |
* @since 3.5
|
725 |
+
*
|
726 |
* @return null
|
727 |
*/
|
728 |
public static function trk_ops_page()
|
729 |
{
|
730 |
do_action("ws_plugin__s2member_before_trk_ops_page", get_defined_vars());
|
731 |
+
|
732 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
733 |
+
|
734 |
include_once dirname(dirname(__FILE__))."/menu-pages/trk-ops.inc.php";
|
735 |
+
|
736 |
do_action("ws_plugin__s2member_after_trk_ops_page", get_defined_vars());
|
737 |
+
|
738 |
+
return /* Return for uniformity. */;
|
739 |
}
|
740 |
/**
|
741 |
* Builds and handles the API List Server options page.
|
742 |
+
*
|
743 |
* @package s2Member\Menu_Pages
|
744 |
* @since 3.5
|
745 |
+
*
|
746 |
* @return null
|
747 |
*/
|
748 |
public static function els_ops_page()
|
749 |
{
|
750 |
do_action("ws_plugin__s2member_before_els_ops_page", get_defined_vars());
|
751 |
+
|
752 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
753 |
+
|
754 |
include_once dirname(dirname(__FILE__))."/menu-pages/els-ops.inc.php";
|
755 |
+
|
756 |
do_action("ws_plugin__s2member_after_els_ops_page", get_defined_vars());
|
757 |
+
|
758 |
+
return /* Return for uniformity. */;
|
759 |
}
|
760 |
/**
|
761 |
* Builds and handles the API Notifications page.
|
762 |
+
*
|
763 |
* @package s2Member\Menu_Pages
|
764 |
* @since 3.5
|
765 |
+
*
|
766 |
* @return null
|
767 |
*/
|
768 |
public static function api_ops_page()
|
769 |
{
|
770 |
do_action("ws_plugin__s2member_before_api_ops_page", get_defined_vars());
|
771 |
+
|
772 |
c_ws_plugin__s2member_menu_pages::update_all_options();
|
773 |
+
|
774 |
include_once dirname(dirname(__FILE__))."/menu-pages/api-ops.inc.php";
|
775 |
+
|
776 |
do_action("ws_plugin__s2member_after_api_ops_page", get_defined_vars());
|
777 |
+
|
778 |
+
return /* Return for uniformity. */;
|
779 |
}
|
780 |
/**
|
781 |
* Builds and handles the PayPal Button Generator page.
|
782 |
+
*
|
783 |
* @package s2Member\Menu_Pages
|
784 |
* @since 3.5
|
785 |
+
*
|
786 |
* @return null
|
787 |
*/
|
788 |
public static function paypal_buttons_page()
|
789 |
{
|
790 |
do_action("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars());
|
791 |
+
|
792 |
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"])
|
793 |
+
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);
|
794 |
+
|
795 |
include_once dirname(dirname(__FILE__))."/menu-pages/paypal-buttons.inc.php";
|
796 |
+
|
797 |
do_action("ws_plugin__s2member_after_paypal_buttons_page", get_defined_vars());
|
798 |
+
|
799 |
+
return /* Return for uniformity. */;
|
800 |
}
|
801 |
/**
|
802 |
* Builds and handles the API Scripting page.
|
803 |
+
*
|
804 |
* @package s2Member\Menu_Pages
|
805 |
* @since 3.5
|
806 |
+
*
|
807 |
* @return null
|
808 |
*/
|
809 |
public static function scripting_page()
|
810 |
{
|
811 |
do_action("ws_plugin__s2member_before_scripting_page", get_defined_vars());
|
812 |
+
|
813 |
include_once dirname(dirname(__FILE__))."/menu-pages/scripting.inc.php";
|
814 |
+
|
815 |
do_action("ws_plugin__s2member_after_scripting_page", get_defined_vars());
|
816 |
+
|
817 |
+
return /* Return for uniformity. */;
|
818 |
}
|
819 |
/**
|
820 |
* Builds and handles the Integrations page.
|
821 |
+
*
|
822 |
* @package s2Member\Menu_Pages
|
823 |
* @since 3.5
|
824 |
+
*
|
825 |
* @return null
|
826 |
*/
|
827 |
public static function integrations_page()
|
828 |
{
|
829 |
do_action("ws_plugin__s2member_before_integrations_page", get_defined_vars());
|
830 |
+
|
831 |
include_once dirname(dirname(__FILE__))."/menu-pages/integrations.inc.php";
|
832 |
+
|
833 |
do_action("ws_plugin__s2member_after_integrations_page", get_defined_vars());
|
834 |
+
|
835 |
+
return /* Return for uniformity. */;
|
836 |
+
}
|
837 |
+
/**
|
838 |
+
* Builds and handles the Logs page.
|
839 |
+
*
|
840 |
+
* @package s2Member\Menu_Pages
|
841 |
+
* @since 120310
|
842 |
+
*
|
843 |
+
* @return null
|
844 |
+
*/
|
845 |
+
public static function logs_page()
|
846 |
+
{
|
847 |
+
do_action("ws_plugin__s2member_before_logs_page", get_defined_vars());
|
848 |
+
|
849 |
+
c_ws_plugin__s2member_menu_pages::update_all_options();
|
850 |
+
c_ws_plugin__s2member_menu_pages::archive_logs_start_fresh();
|
851 |
+
c_ws_plugin__s2member_menu_pages::delete_logs_start_fresh();
|
852 |
+
|
853 |
+
$logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
|
854 |
+
|
855 |
+
if(!is_dir($logs_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir))))
|
856 |
+
mkdir($logs_dir, 0777, true).clearstatcache();
|
857 |
+
|
858 |
+
$htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]."/.htaccess";
|
859 |
+
$htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"])));
|
860 |
+
|
861 |
+
if(is_dir($logs_dir) && is_writable($logs_dir) && !file_exists($htaccess))
|
862 |
+
file_put_contents($htaccess, $htaccess_contents).clearstatcache();
|
863 |
+
|
864 |
+
if /* If the security-enabled logs directory does not exist yet. */(!is_dir($logs_dir))
|
865 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled logs directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)).'</code>) does not exist. Please create this directory manually & make it writable (chmod 777).', true);
|
866 |
+
|
867 |
+
else if /* If the logs directory is not writable yet. */(!is_writable($logs_dir))
|
868 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('Permissions error. The security-enabled logs directory (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)).'</code>) is not writable. Please make this directory writable (chmod 777).', true);
|
869 |
+
|
870 |
+
if /* If the .htaccess file has not been created yet. */(!file_exists($htaccess))
|
871 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
872 |
+
|
873 |
+
else if /* Else if the .htaccess file does not offer the required protection. */(!preg_match("/deny from all/i", file_get_contents($htaccess)))
|
874 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>'.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)).'</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>'.esc_html($htaccess_contents).'</pre>', true);
|
875 |
+
|
876 |
+
if /* Logging disabled? */(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
877 |
+
c_ws_plugin__s2member_admin_notices::display_admin_notice('Logging is currently disabled by your configuration.', true);
|
878 |
+
|
879 |
+
include_once dirname(dirname(__FILE__))."/menu-pages/logs.inc.php";
|
880 |
+
|
881 |
+
do_action("ws_plugin__s2member_after_logs_page", get_defined_vars());
|
882 |
+
|
883 |
+
return /* Return for uniformity. */;
|
884 |
}
|
885 |
/**
|
886 |
* Builds and handles the s2Member Info page.
|
887 |
+
*
|
888 |
* @package s2Member\Menu_Pages
|
889 |
* @since 3.5
|
890 |
+
*
|
891 |
* @return null
|
892 |
*/
|
893 |
public static function info_page()
|
894 |
{
|
895 |
do_action("ws_plugin__s2member_before_info_page", get_defined_vars());
|
896 |
+
|
897 |
include_once dirname(dirname(__FILE__))."/menu-pages/info.inc.php";
|
898 |
+
|
899 |
do_action("ws_plugin__s2member_after_info_page", get_defined_vars());
|
900 |
+
|
901 |
+
return /* Return for uniformity. */;
|
902 |
}
|
903 |
}
|
904 |
}
|
includes/classes/meta-box-saves.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
|
21 |
{
|
22 |
/**
|
@@ -40,108 +40,108 @@ if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
|
|
40 |
*/
|
41 |
public static function save_meta_boxes ($post_id = FALSE)
|
42 |
{
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
if ($post_id && !empty ($_POST["ws_plugin__s2member_security_meta_box_save"]) && ($nonce = $_POST["ws_plugin__s2member_security_meta_box_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-security-meta-box-save"))
|
48 |
if (!empty ($_POST["ws_plugin__s2member_security_meta_box_save_id"]) && $post_id == $_POST["ws_plugin__s2member_security_meta_box_save_id"] && !empty ($_POST["post_type"]))
|
49 |
-
|
50 |
{
|
51 |
-
$_p =
|
52 |
-
|
53 |
if (($_p["post_type"] === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id))
|
54 |
{
|
55 |
-
if ($_p["post_type"] === "page" && ($page_id = $post_id))
|
56 |
{
|
57 |
-
if (isset ($_p["ws_plugin__s2member_security_meta_box_level"]))
|
58 |
{
|
59 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
60 |
$pages[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"]));
|
61 |
-
|
62 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
63 |
$posts[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]));
|
64 |
-
|
65 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
66 |
if (($i = array_search ($page_id, $pages[$n])) !== false)
|
67 |
unset($pages[$n][$i]);
|
68 |
-
|
69 |
if (isset ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]) && is_array ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
70 |
if ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all")&& !in_array ("all-pages", $posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
71 |
array_push ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]], (string)$page_id);
|
72 |
-
|
73 |
for ($n = 0, $new_options = array (); $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
74 |
$new_options = array_merge ($new_options, array ("ws_plugin__s2member_level" . $n . "_pages" => trim (implode (",", $pages[$n]))));
|
75 |
-
|
76 |
-
|
77 |
do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
|
78 |
-
unset
|
79 |
-
|
80 |
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true);
|
81 |
}
|
82 |
}
|
83 |
-
|
84 |
-
else
|
85 |
{
|
86 |
-
if (isset ($_p["ws_plugin__s2member_security_meta_box_level"]))
|
87 |
{
|
88 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
89 |
$posts[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]));
|
90 |
-
|
91 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
92 |
if (($i = array_search ($post_id, $posts[$n])) !== false)
|
93 |
unset($posts[$n][$i]);
|
94 |
-
|
95 |
if (isset ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]) && is_array ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
96 |
if ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all")&& !in_array ("all-" . $_p["post_type"] . "s", $posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
97 |
array_push ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]], (string)$post_id);
|
98 |
-
|
99 |
for ($n = 0, $new_options = array (); $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
100 |
$new_options = array_merge ($new_options, array ("ws_plugin__s2member_level" . $n . "_posts" => trim (implode (",", $posts[$n]))));
|
101 |
-
|
102 |
-
|
103 |
do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
|
104 |
-
unset
|
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))
|
111 |
{
|
112 |
-
if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"]))
|
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), ",");
|
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
|
121 |
delete_post_meta ($page_id, "s2member_ccaps_req");
|
122 |
}
|
123 |
}
|
124 |
-
|
125 |
-
else
|
126 |
{
|
127 |
-
if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"]))
|
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), ",");
|
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
|
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
|
145 |
}
|
146 |
}
|
147 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
|
21 |
{
|
22 |
/**
|
40 |
*/
|
41 |
public static function save_meta_boxes ($post_id = FALSE)
|
42 |
{
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
if ($post_id && !empty ($_POST["ws_plugin__s2member_security_meta_box_save"]) && ($nonce = $_POST["ws_plugin__s2member_security_meta_box_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-security-meta-box-save"))
|
48 |
if (!empty ($_POST["ws_plugin__s2member_security_meta_box_save_id"]) && $post_id == $_POST["ws_plugin__s2member_security_meta_box_save_id"] && !empty ($_POST["post_type"]))
|
49 |
+
// We do NOT process historical revisions here; because it causes confusion in the General Options panel for s2Member.
|
50 |
{
|
51 |
+
$_p = /* Clean and create a local copy. */ c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
|
52 |
+
|
53 |
if (($_p["post_type"] === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id))
|
54 |
{
|
55 |
+
if /* OK. So we're dealing with a Page classification? */ ($_p["post_type"] === "page" && ($page_id = $post_id))
|
56 |
{
|
57 |
+
if /* CAN be empty. */ (isset ($_p["ws_plugin__s2member_security_meta_box_level"]))
|
58 |
{
|
59 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
60 |
$pages[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"]));
|
61 |
+
|
62 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
63 |
$posts[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]));
|
64 |
+
|
65 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
66 |
if (($i = array_search ($page_id, $pages[$n])) !== false)
|
67 |
unset($pages[$n][$i]);
|
68 |
+
|
69 |
if (isset ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]) && is_array ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
70 |
if ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all")&& !in_array ("all-pages", $posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
71 |
array_push ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]], (string)$page_id);
|
72 |
+
|
73 |
for ($n = 0, $new_options = array (); $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
74 |
$new_options = array_merge ($new_options, array ("ws_plugin__s2member_level" . $n . "_pages" => trim (implode (",", $pages[$n]))));
|
75 |
+
|
76 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
77 |
do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
|
78 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
79 |
+
|
80 |
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true);
|
81 |
}
|
82 |
}
|
83 |
+
|
84 |
+
else // Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page.
|
85 |
{
|
86 |
+
if /* CAN be empty. */ (isset ($_p["ws_plugin__s2member_security_meta_box_level"]))
|
87 |
{
|
88 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
89 |
$posts[$n] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]));
|
90 |
+
|
91 |
for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
92 |
if (($i = array_search ($post_id, $posts[$n])) !== false)
|
93 |
unset($posts[$n][$i]);
|
94 |
+
|
95 |
if (isset ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]) && is_array ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
96 |
if ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all")&& !in_array ("all-" . $_p["post_type"] . "s", $posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
|
97 |
array_push ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]], (string)$post_id);
|
98 |
+
|
99 |
for ($n = 0, $new_options = array (); $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
100 |
$new_options = array_merge ($new_options, array ("ws_plugin__s2member_level" . $n . "_posts" => trim (implode (",", $posts[$n]))));
|
101 |
+
|
102 |
+
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 /* Unset defined __refs, __v. */ ($__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 /* OK. So we're dealing with a Page classification? */ ($_p["post_type"] === "page" && ($page_id = $post_id))
|
111 |
{
|
112 |
+
if /* CAN be empty. */ (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"]))
|
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), ",");
|
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"])) // 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), ",");
|
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 |
}
|
includes/classes/meta-box-security.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_meta_box_security"))
|
21 |
{
|
22 |
/**
|
@@ -38,103 +38,103 @@ if(!class_exists("c_ws_plugin__s2member_meta_box_security"))
|
|
38 |
*/
|
39 |
public static function security_meta_box($post = FALSE)
|
40 |
{
|
41 |
-
|
42 |
do_action("ws_plugin__s2member_before_security_meta_box", get_defined_vars());
|
43 |
-
unset
|
44 |
-
|
45 |
if(is_object($post) && ($post_id = $post->ID) && (($post->post_type === "page" && current_user_can("edit_page", $post_id)) || current_user_can("edit_post", $post_id)))
|
46 |
{
|
47 |
-
if($post->post_type === "page" && ($page_id = $post_id))
|
48 |
{
|
49 |
if(!in_array($page_id, array_merge(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"]), preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"]))))
|
50 |
{
|
51 |
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";
|
52 |
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";
|
53 |
-
|
54 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
55 |
$pages[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_pages"]));
|
56 |
-
|
57 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
58 |
$posts[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_posts"]));
|
59 |
-
|
60 |
echo '<p style="margin-left:2px;"><strong>Page Level Restriction?</strong></p>'."\n";
|
61 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>'."\n";
|
62 |
echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">'."\n";
|
63 |
-
echo
|
64 |
-
|
65 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
66 |
-
echo ($pages[$n] !== array("all")) ?
|
67 |
-
((!in_array("all-pages", $posts[$n]))
|
68 |
-
? '<option value="'.$n.'"'.((in_array($page_id, $pages[$n])) ? ' selected="selected"' : '').'>'.(($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Require Highest Level #'.$n : 'Require Level #'.$n.' (
|
69 |
-
: '<option value="" disabled="disabled">Level #'.$n.' (
|
70 |
-
: '<option value="" disabled="disabled">Level #'.$n.' (
|
71 |
-
|
72 |
-
echo '</select><br /><small>* see: <code>Restriction Options
|
73 |
-
|
74 |
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site())
|
75 |
-
|
76 |
{
|
77 |
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>'."\n";
|
78 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>'."\n";
|
79 |
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="'.format_to_edit(trim(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";
|
80 |
-
echo '<br /><small>* see: <code>API Scripting
|
81 |
}
|
82 |
}
|
83 |
-
|
84 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
85 |
-
echo 'This Page is your:<br /><strong>Membership Options Page</strong><br />(
|
86 |
-
|
87 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
|
88 |
-
echo 'This Page is your:<br /><strong>Login Welcome Page</strong><br />(
|
89 |
-
|
90 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
|
91 |
-
echo 'This Page is your:<br /><strong>Download Limit Exceeded Page</strong><br />(
|
92 |
-
|
93 |
else if(in_array($page_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
94 |
-
echo 'This Page is a:<br /><strong>Specific Post/Page for sale</strong><br />(
|
95 |
}
|
96 |
-
else
|
97 |
{
|
98 |
if(!in_array($post_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
99 |
{
|
100 |
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";
|
101 |
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";
|
102 |
-
|
103 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
104 |
$posts[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_posts"]));
|
105 |
-
|
106 |
echo '<p style="margin-left:2px;"><strong>Post Level Restriction?</strong></p>'."\n";
|
107 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>'."\n";
|
108 |
echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">'."\n";
|
109 |
-
echo '<option value=""></option>'."\n";
|
110 |
-
|
111 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
112 |
-
echo ($posts[$n] !== array("all")) ?
|
113 |
-
((!in_array("all-".$post->post_type."s", $posts[$n]))
|
114 |
-
? '<option value="'.$n.'"'.((in_array($post_id, $posts[$n])) ? ' selected="selected"' : '').'>'.(($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Require Highest Level #'.$n : 'Require Level #'.$n.' (
|
115 |
-
: '<option value="" disabled="disabled">Level #'.$n.' (
|
116 |
-
: '<option value="" disabled="disabled">Level #'.$n.' (
|
117 |
-
|
118 |
-
echo '</select><br /><small>* see: <code>Restriction Options
|
119 |
-
|
120 |
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site())
|
121 |
-
|
122 |
{
|
123 |
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>'."\n";
|
124 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>'."\n";
|
125 |
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="'.format_to_edit(trim(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";
|
126 |
-
echo '<br /><small>* see: <code>API Scripting
|
127 |
}
|
128 |
}
|
129 |
-
|
130 |
else if(in_array($post_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
131 |
-
echo 'This Post is a:<br /><strong>Specific Post/Page for sale</strong><br />(
|
132 |
}
|
133 |
}
|
134 |
-
|
135 |
do_action("ws_plugin__s2member_after_security_meta_box", get_defined_vars());
|
136 |
-
|
137 |
-
return
|
138 |
}
|
139 |
}
|
140 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_meta_box_security"))
|
21 |
{
|
22 |
/**
|
38 |
*/
|
39 |
public static function security_meta_box($post = FALSE)
|
40 |
{
|
41 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
42 |
do_action("ws_plugin__s2member_before_security_meta_box", get_defined_vars());
|
43 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
44 |
+
|
45 |
if(is_object($post) && ($post_id = $post->ID) && (($post->post_type === "page" && current_user_can("edit_page", $post_id)) || current_user_can("edit_post", $post_id)))
|
46 |
{
|
47 |
+
if /* OK. So we're dealing with a Page classification. */($post->post_type === "page" && ($page_id = $post_id))
|
48 |
{
|
49 |
if(!in_array($page_id, array_merge(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"]), preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"]))))
|
50 |
{
|
51 |
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";
|
52 |
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";
|
53 |
+
|
54 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
55 |
$pages[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_pages"]));
|
56 |
+
|
57 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
58 |
$posts[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_posts"]));
|
59 |
+
|
60 |
echo '<p style="margin-left:2px;"><strong>Page Level Restriction?</strong></p>'."\n";
|
61 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>'."\n";
|
62 |
echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">'."\n";
|
63 |
+
echo /* By default, we allow public access to any Post/Page. */'<option value=""></option>'."\n";
|
64 |
+
|
65 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
66 |
+
echo ($pages[$n] !== array("all")) ? // Protecting `all` Pages, of any kind?
|
67 |
+
((!in_array("all-pages", $posts[$n])) // Protecting Posts of type: `page` ( i.e. `all-pages` )?
|
68 |
+
? '<option value="'.$n.'"'.((in_array($page_id, $pages[$n])) ? ' selected="selected"' : '').'>'.(($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Require Highest Level #'.$n : 'Require Level #'.$n.' (or higher)').'</option>'."\n"
|
69 |
+
: '<option value="" disabled="disabled">Level #'.$n.' (already protects "all" Posts of this type)</option>'."\n")
|
70 |
+
: '<option value="" disabled="disabled">Level #'.$n.' (already protects "all" Pages)</option>'."\n";
|
71 |
+
|
72 |
+
echo '</select><br /><small>* see: <code>Restriction Options -› Pages</code></small>'."\n";
|
73 |
+
|
74 |
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site())
|
75 |
+
// ^ Will change once Custom Capabilities are compatible with a Blog Farm.
|
76 |
{
|
77 |
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>'."\n";
|
78 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>'."\n";
|
79 |
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="'.format_to_edit(trim(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";
|
80 |
+
echo '<br /><small>* see: <code>API Scripting -› Custom Capabilities</code></small>'."\n";
|
81 |
}
|
82 |
}
|
83 |
+
|
84 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
85 |
+
echo 'This Page is your:<br /><strong>Membership Options Page</strong><br />(always publicly available)';
|
86 |
+
|
87 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
|
88 |
+
echo 'This Page is your:<br /><strong>Login Welcome Page</strong><br />(automatically guarded by s2Member)';
|
89 |
+
|
90 |
else if($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
|
91 |
+
echo 'This Page is your:<br /><strong>Download Limit Exceeded Page</strong><br />(automatically guarded by s2Member)';
|
92 |
+
|
93 |
else if(in_array($page_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
94 |
+
echo 'This Page is a:<br /><strong>Specific Post/Page for sale</strong><br />(already guarded by s2Member)';
|
95 |
}
|
96 |
+
else // Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page.
|
97 |
{
|
98 |
if(!in_array($post_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
99 |
{
|
100 |
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";
|
101 |
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";
|
102 |
+
|
103 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
104 |
$posts[$n] = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_posts"]));
|
105 |
+
|
106 |
echo '<p style="margin-left:2px;"><strong>Post Level Restriction?</strong></p>'."\n";
|
107 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>'."\n";
|
108 |
echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">'."\n";
|
109 |
+
echo '<option value=""></option>'."\n"; // By default, we allow public access to any Post/Page.
|
110 |
+
|
111 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
|
112 |
+
echo ($posts[$n] !== array("all")) ? // Protecting `all` Posts, of any kind?
|
113 |
+
((!in_array("all-".$post->post_type."s", $posts[$n])) // Protecting Posts `all-[of-this-type]` ( don't forget plural `s` )?
|
114 |
+
? '<option value="'.$n.'"'.((in_array($post_id, $posts[$n])) ? ' selected="selected"' : '').'>'.(($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Require Highest Level #'.$n : 'Require Level #'.$n.' (or higher)').'</option>'."\n"
|
115 |
+
: '<option value="" disabled="disabled">Level #'.$n.' (already protects "all" Posts of this type)</option>'."\n")
|
116 |
+
: '<option value="" disabled="disabled">Level #'.$n.' (already protects "all" Posts)</option>'."\n";
|
117 |
+
|
118 |
+
echo '</select><br /><small>* see: <code>Restriction Options -› Posts</code></small>'."\n";
|
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 |
echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>'."\n";
|
124 |
echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>'."\n";
|
125 |
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="'.format_to_edit(trim(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";
|
126 |
+
echo '<br /><small>* see: <code>API Scripting -› Custom Capabilities</code></small>'."\n";
|
127 |
}
|
128 |
}
|
129 |
+
|
130 |
else if(in_array($post_id, preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
|
131 |
+
echo 'This Post is a:<br /><strong>Specific Post/Page for sale</strong><br />(already guarded by s2Member)';
|
132 |
}
|
133 |
}
|
134 |
+
|
135 |
do_action("ws_plugin__s2member_after_security_meta_box", get_defined_vars());
|
136 |
+
|
137 |
+
return /* Return for uniformity. */;
|
138 |
}
|
139 |
}
|
140 |
}
|
includes/classes/meta-boxes.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_meta_boxes"))
|
21 |
{
|
22 |
/**
|
@@ -44,16 +44,16 @@ if (!class_exists ("c_ws_plugin__s2member_meta_boxes"))
|
|
44 |
public static function add_meta_boxes ($type = FALSE)
|
45 |
{
|
46 |
do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
|
47 |
-
|
48 |
$excluded_types = array ("link", "comment", "revision", "attachment", "nav_menu_item");
|
49 |
$excluded_types = apply_filters ("ws_plugin__s2member_add_meta_boxes_excluded_types", $excluded_types, get_defined_vars ());
|
50 |
-
|
51 |
if (in_array ($type, array_keys (get_post_types ())) && !in_array ($type, $excluded_types))
|
52 |
add_meta_box ("ws-plugin--s2member-security", "s2Member®", "c_ws_plugin__s2member_meta_box_security::security_meta_box", $type, "side", "high");
|
53 |
-
|
54 |
do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
|
55 |
-
|
56 |
-
return
|
57 |
}
|
58 |
}
|
59 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_meta_boxes"))
|
21 |
{
|
22 |
/**
|
44 |
public static function add_meta_boxes ($type = FALSE)
|
45 |
{
|
46 |
do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
|
47 |
+
|
48 |
$excluded_types = array ("link", "comment", "revision", "attachment", "nav_menu_item");
|
49 |
$excluded_types = apply_filters ("ws_plugin__s2member_add_meta_boxes_excluded_types", $excluded_types, get_defined_vars ());
|
50 |
+
|
51 |
if (in_array ($type, array_keys (get_post_types ())) && !in_array ($type, $excluded_types))
|
52 |
add_meta_box ("ws-plugin--s2member-security", "s2Member®", "c_ws_plugin__s2member_meta_box_security::security_meta_box", $type, "side", "high");
|
53 |
+
|
54 |
do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
|
55 |
+
|
56 |
+
return /* Return for uniformity. */;
|
57 |
}
|
58 |
}
|
59 |
}
|
includes/classes/mms-patches.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
|
21 |
{
|
22 |
/**
|
@@ -40,16 +40,16 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
|
|
40 |
*/
|
41 |
public static function sync_mms_patches ($message = FALSE)
|
42 |
{
|
43 |
-
global $pagenow;
|
44 |
-
|
45 |
-
|
46 |
do_action ("ws_plugin__s2member_before_sync_mms_patches", get_defined_vars ());
|
47 |
-
unset
|
48 |
-
|
49 |
if (is_multisite () && is_network_admin () && $pagenow === "update-core.php")
|
50 |
if ($message === "Upgrading database…" && c_ws_plugin__s2member_mms_patches::mms_patches ())
|
51 |
apply_filters ("update_feedback", "s2 Multisite patches applied…");
|
52 |
-
|
53 |
return apply_filters ("ws_plugin__s2member_sync_mms_patches", $message, get_defined_vars ());
|
54 |
}
|
55 |
/**
|
@@ -63,86 +63,86 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
|
|
63 |
*/
|
64 |
public static function mms_patches ($display_notices = FALSE)
|
65 |
{
|
66 |
-
|
67 |
do_action ("ws_plugin__s2member_before_mms_patches", get_defined_vars ());
|
68 |
-
unset
|
69 |
-
|
70 |
if (is_multisite () && is_admin () && is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"])
|
71 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] && (!defined ("DISALLOW_FILE_MODS") || !DISALLOW_FILE_MODS))
|
72 |
{
|
73 |
do_action ("ws_plugin__s2member_during_mms_patches_before", get_defined_vars ());
|
74 |
-
|
75 |
-
$wp_login_file = ABSPATH . "wp-login.php";
|
76 |
$wp_login_section = "/([\r\n\t\s ]+)(wp_redirect( *?)\(( *?)apply_filters( *?)\(( *?)['\"]wp_signup_location['\"],( *?)(site_url( *?)\(( *?)['\"]wp-signup\.php['\"]( *?)\)|network_site_url( *?)\(( *?)['\"]wp-signup\.php['\"]( *?)\)|get_bloginfo( *?)\(['\"]wpurl['\"]\)( *?)\.( *?)['\"]\/wp-signup\.php['\"])( *?)\)( *?)\);)([\r\n\t\s ]+)(exit;)/";
|
77 |
$wp_login_replace = "\n\t\t// Modified for full plugin compatiblity.\n\t\t//wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) );\n\t\t//exit;";
|
78 |
-
|
79 |
if (file_exists ($wp_login_file) && ($wp_login = file_get_contents ($wp_login_file)) && is_writable ($wp_login_file))
|
80 |
{
|
81 |
if ((($wp_login_written = file_put_contents ($wp_login_file, preg_replace ($wp_login_section, $wp_login_replace, $wp_login, 1, $wp_login_patched))) && $wp_login_patched) || ($wp_login_patched_already = $wp_login_patched = strpos ($wp_login, $wp_login_replace)))
|
82 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file ' . (($wp_login_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
83 |
-
else if (!$wp_login_written)
|
84 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
85 |
-
else if (!$wp_login_patched)
|
86 |
($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;
|
87 |
}
|
88 |
-
else
|
89 |
($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;
|
90 |
-
|
91 |
$load_file = ABSPATH . WPINC . "/load.php";
|
92 |
$load_section = "/([\r\n\t\s ]+)(if( *?)\(( *?)empty( *?)\(( *?)\\\$active_plugins( *?)\)( *?)\|\|( *?)defined( *?)\(( *?)['\"]WP_INSTALLING['\"]( *?)\)( *?)\))/";
|
93 |
$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\"]) ) )";
|
94 |
-
|
95 |
if (file_exists ($load_file) && ($load = file_get_contents ($load_file)) && is_writable ($load_file))
|
96 |
{
|
97 |
if ((($load_written = file_put_contents ($load_file, preg_replace ($load_section, $load_replace, $load, 1, $load_patched))) && $load_patched) || ($load_patched_already = $load_patched = strpos ($load, $load_replace)))
|
98 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file ' . (($load_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
99 |
-
else if (!$load_written)
|
100 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
101 |
-
else if (!$load_patched)
|
102 |
($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;
|
103 |
}
|
104 |
-
else
|
105 |
($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;
|
106 |
-
|
107 |
$user_new_file = ABSPATH . "wp-admin/user-new.php";
|
108 |
$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'( *?)\]( *?)\)( *?)\);)/";
|
109 |
$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' ] ) ) );";
|
110 |
-
|
111 |
if (file_exists ($user_new_file) && ($user_new = file_get_contents ($user_new_file)) && is_writable ($user_new_file))
|
112 |
{
|
113 |
if ((($user_new_written = file_put_contents ($user_new_file, preg_replace ($user_new_section, $user_new_replace, $user_new, 1, $user_new_patched))) && $user_new_patched) || ($user_new_patched_already = $user_new_patched = strpos ($user_new, $user_new_replace)))
|
114 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file ' . (($user_new_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
115 |
-
else if (!$user_new_written)
|
116 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
117 |
-
else if (!$user_new_patched)
|
118 |
($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;
|
119 |
}
|
120 |
-
else
|
121 |
($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;
|
122 |
-
|
123 |
$ms_functions_file = ABSPATH . "wp-includes/ms-functions.php";
|
124 |
$ms_functions_section = "/([\r\n\t\s ]+)(return new WP_Error( *?)\(( *?)'user_already_exists'( *?),( *?)__( *?)\(( *?)'That username is already activated.'( *?)\),( *?)\\\$signup( *?)\);)/";
|
125 |
$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());";
|
126 |
-
|
127 |
if (file_exists ($ms_functions_file) && ($ms_functions = file_get_contents ($ms_functions_file)) && is_writable ($ms_functions_file))
|
128 |
{
|
129 |
if ((($ms_functions_written = file_put_contents ($ms_functions_file, preg_replace ($ms_functions_section, $ms_functions_replace, $ms_functions, 1, $ms_functions_patched))) && $ms_functions_patched) || ($ms_functions_patched_already = $ms_functions_patched = strpos ($ms_functions, $ms_functions_replace)))
|
130 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file ' . (($ms_functions_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
131 |
-
else if (!$ms_functions_written)
|
132 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
133 |
-
else if (!$ms_functions_patched)
|
134 |
($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;
|
135 |
}
|
136 |
-
else
|
137 |
($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;
|
138 |
-
|
139 |
-
$ran_mms_patches = true;
|
140 |
-
|
141 |
do_action ("ws_plugin__s2member_during_mms_patches_after", get_defined_vars ());
|
142 |
}
|
143 |
-
|
144 |
do_action ("ws_plugin__s2member_after_mms_patches", get_defined_vars ());
|
145 |
-
|
146 |
return !empty ($ran_mms_patches) ? $ran_mms_patches : false;
|
147 |
}
|
148 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
|
21 |
{
|
22 |
/**
|
40 |
*/
|
41 |
public static function sync_mms_patches ($message = FALSE)
|
42 |
{
|
43 |
+
global $pagenow; // Need access to this global var.
|
44 |
+
|
45 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
46 |
do_action ("ws_plugin__s2member_before_sync_mms_patches", get_defined_vars ());
|
47 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
48 |
+
|
49 |
if (is_multisite () && is_network_admin () && $pagenow === "update-core.php")
|
50 |
if ($message === "Upgrading database…" && c_ws_plugin__s2member_mms_patches::mms_patches ())
|
51 |
apply_filters ("update_feedback", "s2 Multisite patches applied…");
|
52 |
+
|
53 |
return apply_filters ("ws_plugin__s2member_sync_mms_patches", $message, get_defined_vars ());
|
54 |
}
|
55 |
/**
|
63 |
*/
|
64 |
public static function mms_patches ($display_notices = FALSE)
|
65 |
{
|
66 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
67 |
do_action ("ws_plugin__s2member_before_mms_patches", get_defined_vars ());
|
68 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
69 |
+
|
70 |
if (is_multisite () && is_admin () && is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"])
|
71 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] && (!defined ("DISALLOW_FILE_MODS") || !DISALLOW_FILE_MODS))
|
72 |
{
|
73 |
do_action ("ws_plugin__s2member_during_mms_patches_before", get_defined_vars ());
|
74 |
+
|
75 |
+
$wp_login_file = ABSPATH . "wp-login.php"; // This works for both WordPress® 3.0 and 3.1. WordPress® 3.1+ uses: `site_url('wp-signup.php')`. WordPress® 3.5+ uses: `network_site_url('wp-signup.php')`.
|
76 |
$wp_login_section = "/([\r\n\t\s ]+)(wp_redirect( *?)\(( *?)apply_filters( *?)\(( *?)['\"]wp_signup_location['\"],( *?)(site_url( *?)\(( *?)['\"]wp-signup\.php['\"]( *?)\)|network_site_url( *?)\(( *?)['\"]wp-signup\.php['\"]( *?)\)|get_bloginfo( *?)\(['\"]wpurl['\"]\)( *?)\.( *?)['\"]\/wp-signup\.php['\"])( *?)\)( *?)\);)([\r\n\t\s ]+)(exit;)/";
|
77 |
$wp_login_replace = "\n\t\t// Modified for full plugin compatiblity.\n\t\t//wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) );\n\t\t//exit;";
|
78 |
+
|
79 |
if (file_exists ($wp_login_file) && ($wp_login = file_get_contents ($wp_login_file)) && is_writable ($wp_login_file))
|
80 |
{
|
81 |
if ((($wp_login_written = file_put_contents ($wp_login_file, preg_replace ($wp_login_section, $wp_login_replace, $wp_login, 1, $wp_login_patched))) && $wp_login_patched) || ($wp_login_patched_already = $wp_login_patched = strpos ($wp_login, $wp_login_replace)))
|
82 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file ' . (($wp_login_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
83 |
+
else if (!$wp_login_written) // Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error.
|
84 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
85 |
+
else if (!$wp_login_patched) // Otherwise, we need to report that /wp-login.php could NOT be updated. Wrong WordPress® version?
|
86 |
($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;
|
87 |
}
|
88 |
+
else // Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error.
|
89 |
($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;
|
90 |
+
|
91 |
$load_file = ABSPATH . WPINC . "/load.php";
|
92 |
$load_section = "/([\r\n\t\s ]+)(if( *?)\(( *?)empty( *?)\(( *?)\\\$active_plugins( *?)\)( *?)\|\|( *?)defined( *?)\(( *?)['\"]WP_INSTALLING['\"]( *?)\)( *?)\))/";
|
93 |
$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\"]) ) )";
|
94 |
+
|
95 |
if (file_exists ($load_file) && ($load = file_get_contents ($load_file)) && is_writable ($load_file))
|
96 |
{
|
97 |
if ((($load_written = file_put_contents ($load_file, preg_replace ($load_section, $load_replace, $load, 1, $load_patched))) && $load_patched) || ($load_patched_already = $load_patched = strpos ($load, $load_replace)))
|
98 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file ' . (($load_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
99 |
+
else if (!$load_written) // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error.
|
100 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
101 |
+
else if (!$load_patched) // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Wrong WordPress® version?
|
102 |
($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;
|
103 |
}
|
104 |
+
else // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error.
|
105 |
($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;
|
106 |
+
|
107 |
$user_new_file = ABSPATH . "wp-admin/user-new.php";
|
108 |
$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'( *?)\]( *?)\)( *?)\);)/";
|
109 |
$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' ] ) ) );";
|
110 |
+
|
111 |
if (file_exists ($user_new_file) && ($user_new = file_get_contents ($user_new_file)) && is_writable ($user_new_file))
|
112 |
{
|
113 |
if ((($user_new_written = file_put_contents ($user_new_file, preg_replace ($user_new_section, $user_new_replace, $user_new, 1, $user_new_patched))) && $user_new_patched) || ($user_new_patched_already = $user_new_patched = strpos ($user_new, $user_new_replace)))
|
114 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file ' . (($user_new_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
115 |
+
else if (!$user_new_written) // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error.
|
116 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
117 |
+
else if (!$user_new_patched) // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Wrong WordPress® version?
|
118 |
($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;
|
119 |
}
|
120 |
+
else // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error.
|
121 |
($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;
|
122 |
+
|
123 |
$ms_functions_file = ABSPATH . "wp-includes/ms-functions.php";
|
124 |
$ms_functions_section = "/([\r\n\t\s ]+)(return new WP_Error( *?)\(( *?)'user_already_exists'( *?),( *?)__( *?)\(( *?)'That username is already activated.'( *?)\),( *?)\\\$signup( *?)\);)/";
|
125 |
$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());";
|
126 |
+
|
127 |
if (file_exists ($ms_functions_file) && ($ms_functions = file_get_contents ($ms_functions_file)) && is_writable ($ms_functions_file))
|
128 |
{
|
129 |
if ((($ms_functions_written = file_put_contents ($ms_functions_file, preg_replace ($ms_functions_section, $ms_functions_replace, $ms_functions, 1, $ms_functions_patched))) && $ms_functions_patched) || ($ms_functions_patched_already = $ms_functions_patched = strpos ($ms_functions, $ms_functions_replace)))
|
130 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file ' . (($ms_functions_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
|
131 |
+
else if (!$ms_functions_written) // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error.
|
132 |
($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Patch NOT written.', true) : null;
|
133 |
+
else if (!$ms_functions_patched) // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Wrong WordPress® version?
|
134 |
($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;
|
135 |
}
|
136 |
+
else // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error.
|
137 |
($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;
|
138 |
+
|
139 |
+
$ran_mms_patches = true; // Flag indicating this routine was indeed processed.
|
140 |
+
|
141 |
do_action ("ws_plugin__s2member_during_mms_patches_after", get_defined_vars ());
|
142 |
}
|
143 |
+
|
144 |
do_action ("ws_plugin__s2member_after_mms_patches", get_defined_vars ());
|
145 |
+
|
146 |
return !empty ($ran_mms_patches) ? $ran_mms_patches : false;
|
147 |
}
|
148 |
}
|
includes/classes/mo-page-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Membership Options Page (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* Membership Options Page (
|
24 |
*
|
25 |
* @package s2Member\Membership_Options_Page
|
26 |
* @since 3.5
|
@@ -47,19 +47,19 @@ if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
|
|
47 |
public static function membership_options_page /* Real Membership Options Page. */ ()
|
48 |
{
|
49 |
do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ());
|
50 |
-
|
51 |
if (!empty ($_GET["s2member_membership_options_page"]) && is_array ($_g = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_GET))))
|
52 |
{
|
53 |
$args = /* Initialize this to an empty array value. */ array ();
|
54 |
-
|
55 |
-
foreach ($_g as $var => $value)
|
56 |
-
|
57 |
if (preg_match ("/^_?s2member_/", $var) && $var !== "s2member_membership_options_page")
|
58 |
$args[$var] = /* Supports nested arrays. */ $value;
|
59 |
-
|
60 |
wp_redirect (add_query_arg (urlencode_deep ($args), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), 301) . exit ();
|
61 |
}
|
62 |
-
|
63 |
do_action ("ws_plugin__s2member_after_membership_options_page", get_defined_vars ());
|
64 |
}
|
65 |
/**
|
@@ -85,20 +85,20 @@ if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
|
|
85 |
public static function wp_redirect_w_mop_vars ($seeking_type = FALSE, $seeking_type_value = FALSE, $req_type = FALSE, $req_type_value = FALSE, $seeking_uri = FALSE, $res_type = FALSE)
|
86 |
{
|
87 |
do_action ("ws_plugin__s2member_before_wp_redirect_w_mop_vars", get_defined_vars ());
|
88 |
-
|
89 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ());
|
90 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_wp_redirect_w_mop_vars_status", $status, get_defined_vars ());
|
91 |
-
|
92 |
$seeking_uri = (strlen ((string)$seeking_uri) /* URIs are base64 encoded. */) ? base64_encode ((string)$seeking_uri) : (string)$seeking_uri;
|
93 |
$seeking_type_value = ((string)$seeking_type /* URIs are base64 encoded. */ === "ruri") ? base64_encode ((string)$seeking_type_value) : (string)$seeking_type_value;
|
94 |
-
|
95 |
$res_type = (!(string)$res_type) ? /* Restriction type preventing access. Defaults to ``$seeking_type`` if NOT passed in explicitly. */ (string)$seeking_type : (string)$res_type;
|
96 |
-
|
97 |
wp_redirect (add_query_arg (urlencode_deep (array ("_s2member_seeking" => array ("type" => (string)$seeking_type, urlencode ((string)$seeking_type)=> (string)$seeking_type_value, "_uri" => (string)$seeking_uri), "_s2member_req" => array ("type" => (string)$req_type, urlencode ((string)$req_type)=> (string)$req_type_value), "_s2member_res" => array ("type" => (string)$res_type), "s2member_seeking" => (string)$seeking_type . "-" . (string)$seeking_type_value, "s2member_" . urlencode ((string)$req_type) . "_req" => (string)$req_type_value)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), $status);
|
98 |
-
|
99 |
do_action ("ws_plugin__s2member_after_wp_redirect_w_mop_vars", get_defined_vars ());
|
100 |
-
|
101 |
-
return true;
|
102 |
}
|
103 |
}
|
104 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Membership Options Page (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* Membership Options Page (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\Membership_Options_Page
|
26 |
* @since 3.5
|
47 |
public static function membership_options_page /* Real Membership Options Page. */ ()
|
48 |
{
|
49 |
do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ());
|
50 |
+
|
51 |
if (!empty ($_GET["s2member_membership_options_page"]) && is_array ($_g = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_GET))))
|
52 |
{
|
53 |
$args = /* Initialize this to an empty array value. */ array ();
|
54 |
+
|
55 |
+
foreach ($_g as $var => $value) // Include all of the `_?s2member_` variables.
|
56 |
+
// Do NOT include `s2member_membership_options_page`; creates a redirection loop.
|
57 |
if (preg_match ("/^_?s2member_/", $var) && $var !== "s2member_membership_options_page")
|
58 |
$args[$var] = /* Supports nested arrays. */ $value;
|
59 |
+
|
60 |
wp_redirect (add_query_arg (urlencode_deep ($args), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), 301) . exit ();
|
61 |
}
|
62 |
+
|
63 |
do_action ("ws_plugin__s2member_after_membership_options_page", get_defined_vars ());
|
64 |
}
|
65 |
/**
|
85 |
public static function wp_redirect_w_mop_vars ($seeking_type = FALSE, $seeking_type_value = FALSE, $req_type = FALSE, $req_type_value = FALSE, $seeking_uri = FALSE, $res_type = FALSE)
|
86 |
{
|
87 |
do_action ("ws_plugin__s2member_before_wp_redirect_w_mop_vars", get_defined_vars ());
|
88 |
+
|
89 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ());
|
90 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_wp_redirect_w_mop_vars_status", $status, get_defined_vars ());
|
91 |
+
|
92 |
$seeking_uri = (strlen ((string)$seeking_uri) /* URIs are base64 encoded. */) ? base64_encode ((string)$seeking_uri) : (string)$seeking_uri;
|
93 |
$seeking_type_value = ((string)$seeking_type /* URIs are base64 encoded. */ === "ruri") ? base64_encode ((string)$seeking_type_value) : (string)$seeking_type_value;
|
94 |
+
|
95 |
$res_type = (!(string)$res_type) ? /* Restriction type preventing access. Defaults to ``$seeking_type`` if NOT passed in explicitly. */ (string)$seeking_type : (string)$res_type;
|
96 |
+
|
97 |
wp_redirect (add_query_arg (urlencode_deep (array ("_s2member_seeking" => array ("type" => (string)$seeking_type, urlencode ((string)$seeking_type)=> (string)$seeking_type_value, "_uri" => (string)$seeking_uri), "_s2member_req" => array ("type" => (string)$req_type, urlencode ((string)$req_type)=> (string)$req_type_value), "_s2member_res" => array ("type" => (string)$res_type), "s2member_seeking" => (string)$seeking_type . "-" . (string)$seeking_type_value, "s2member_" . urlencode ((string)$req_type) . "_req" => (string)$req_type_value)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), $status);
|
98 |
+
|
99 |
do_action ("ws_plugin__s2member_after_wp_redirect_w_mop_vars", get_defined_vars ());
|
100 |
+
|
101 |
+
return true; // Always returns true here.
|
102 |
}
|
103 |
}
|
104 |
}
|
includes/classes/mo-page.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mo_page"))
|
21 |
{
|
22 |
/**
|
@@ -42,7 +42,7 @@ if (!class_exists ("c_ws_plugin__s2member_mo_page"))
|
|
42 |
*/
|
43 |
public static function membership_options_page ()
|
44 |
{
|
45 |
-
if (!empty ($_GET["s2member_membership_options_page"]))
|
46 |
{
|
47 |
return c_ws_plugin__s2member_mo_page_in::membership_options_page ();
|
48 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_mo_page"))
|
21 |
{
|
22 |
/**
|
42 |
*/
|
43 |
public static function membership_options_page ()
|
44 |
{
|
45 |
+
if (!empty ($_GET["s2member_membership_options_page"]))
|
46 |
{
|
47 |
return c_ws_plugin__s2member_mo_page_in::membership_options_page ();
|
48 |
}
|
includes/classes/no-cache.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
21 |
{
|
22 |
/**
|
@@ -51,12 +51,12 @@ if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
|
51 |
public static function no_cache ($no_cache = FALSE)
|
52 |
{
|
53 |
do_action ("ws_plugin__s2member_before_no_cache", get_defined_vars ());
|
54 |
-
|
55 |
c_ws_plugin__s2member_no_cache::no_cache_constants ($no_cache) . c_ws_plugin__s2member_no_cache::no_cache_headers ($no_cache);
|
56 |
-
|
57 |
do_action ("ws_plugin__s2member_after_no_cache", get_defined_vars ());
|
58 |
-
|
59 |
-
return true;
|
60 |
}
|
61 |
/**
|
62 |
* Defines no-cache constants for various WordPress® plugins.
|
@@ -82,12 +82,12 @@ if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
|
82 |
*/
|
83 |
public static function no_cache_constants ($no_cache = FALSE)
|
84 |
{
|
85 |
-
static $once;
|
86 |
-
|
87 |
-
|
88 |
do_action ("ws_plugin__s2member_before_no_cache_constants", get_defined_vars ());
|
89 |
-
unset
|
90 |
-
|
91 |
if (!$once && empty ($_GET["qcAC"]) && ($no_cache || is_user_logged_in () || c_ws_plugin__s2member_systematics::is_s2_systematic_use_page ()))
|
92 |
{
|
93 |
/**
|
@@ -130,20 +130,20 @@ if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
|
130 |
*/
|
131 |
if (!defined ("QUICK_CACHE_ALLOWED"))
|
132 |
define ("QUICK_CACHE_ALLOWED", false);
|
133 |
-
|
134 |
-
$once = true;
|
135 |
-
|
136 |
c_ws_plugin__s2member_no_cache::$headers = /* Headers required too. */ true;
|
137 |
-
|
138 |
do_action ("ws_plugin__s2member_during_no_cache_constants", get_defined_vars ());
|
139 |
}
|
140 |
-
|
141 |
do_action ("ws_plugin__s2member_after_no_cache_constants", get_defined_vars ());
|
142 |
-
|
143 |
-
return true;
|
144 |
}
|
145 |
/**
|
146 |
-
* Sends Cache-Control (
|
147 |
*
|
148 |
* Disallow browser caching if the ``$no_cache`` parameter is passed in as ``true``, by other routines.
|
149 |
* Disallow browser caching when/if no-cache Constants are set by {@link s2Member\No_Cache\c_ws_plugin__s2member_no_cache::no_cache_constants()},
|
@@ -162,34 +162,34 @@ if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
|
162 |
*/
|
163 |
public static function no_cache_headers ($no_cache = FALSE)
|
164 |
{
|
165 |
-
static $once;
|
166 |
-
|
167 |
-
|
168 |
do_action ("ws_plugin__s2member_before_no_cache_headers", get_defined_vars ());
|
169 |
-
unset
|
170 |
-
|
171 |
$using_selective_behavior = /* Off by default. */ apply_filters ("ws_plugin__s2member_no_cache_headers_selective", false, get_defined_vars ());
|
172 |
-
|
173 |
if (!$once && !headers_sent () && empty ($_GET["qcABC"]) && ($no_cache || !$using_selective_behavior || c_ws_plugin__s2member_no_cache::$headers))
|
174 |
if ( /* Give Filters a chance. */!apply_filters ("ws_plugin__s2member_disable_no_cache_headers", false, get_defined_vars ()))
|
175 |
{
|
176 |
-
foreach (headers_list () as $header)
|
177 |
-
if (stripos ($header, "no-cache") !== false)
|
178 |
{
|
179 |
-
$no_cache_headers_already_sent = true;
|
180 |
-
break;
|
181 |
}
|
182 |
-
if (!isset ($no_cache_headers_already_sent))
|
183 |
-
nocache_headers ();
|
184 |
-
|
185 |
-
$once = true;
|
186 |
-
|
187 |
do_action ("ws_plugin__s2member_during_no_cache_headers", get_defined_vars ());
|
188 |
}
|
189 |
-
|
190 |
do_action ("ws_plugin__s2member_after_no_cache_headers", get_defined_vars ());
|
191 |
-
|
192 |
-
return true;
|
193 |
}
|
194 |
}
|
195 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_no_cache"))
|
21 |
{
|
22 |
/**
|
51 |
public static function no_cache ($no_cache = FALSE)
|
52 |
{
|
53 |
do_action ("ws_plugin__s2member_before_no_cache", get_defined_vars ());
|
54 |
+
|
55 |
c_ws_plugin__s2member_no_cache::no_cache_constants ($no_cache) . c_ws_plugin__s2member_no_cache::no_cache_headers ($no_cache);
|
56 |
+
|
57 |
do_action ("ws_plugin__s2member_after_no_cache", get_defined_vars ());
|
58 |
+
|
59 |
+
return true; // Always return true.
|
60 |
}
|
61 |
/**
|
62 |
* Defines no-cache constants for various WordPress® plugins.
|
82 |
*/
|
83 |
public static function no_cache_constants ($no_cache = FALSE)
|
84 |
{
|
85 |
+
static $once; // We only need to set these constants once.
|
86 |
+
|
87 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
88 |
do_action ("ws_plugin__s2member_before_no_cache_constants", get_defined_vars ());
|
89 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
90 |
+
|
91 |
if (!$once && empty ($_GET["qcAC"]) && ($no_cache || is_user_logged_in () || c_ws_plugin__s2member_systematics::is_s2_systematic_use_page ()))
|
92 |
{
|
93 |
/**
|
130 |
*/
|
131 |
if (!defined ("QUICK_CACHE_ALLOWED"))
|
132 |
define ("QUICK_CACHE_ALLOWED", false);
|
133 |
+
|
134 |
+
$once = true; // Only need to set these constants one time.
|
135 |
+
|
136 |
c_ws_plugin__s2member_no_cache::$headers = /* Headers required too. */ true;
|
137 |
+
|
138 |
do_action ("ws_plugin__s2member_during_no_cache_constants", get_defined_vars ());
|
139 |
}
|
140 |
+
|
141 |
do_action ("ws_plugin__s2member_after_no_cache_constants", get_defined_vars ());
|
142 |
+
|
143 |
+
return true; // Always return true.
|
144 |
}
|
145 |
/**
|
146 |
+
* Sends Cache-Control (no-cache) headers.
|
147 |
*
|
148 |
* Disallow browser caching if the ``$no_cache`` parameter is passed in as ``true``, by other routines.
|
149 |
* Disallow browser caching when/if no-cache Constants are set by {@link s2Member\No_Cache\c_ws_plugin__s2member_no_cache::no_cache_constants()},
|
162 |
*/
|
163 |
public static function no_cache_headers ($no_cache = FALSE)
|
164 |
{
|
165 |
+
static $once; // We only need to set these headers one time.
|
166 |
+
|
167 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
168 |
do_action ("ws_plugin__s2member_before_no_cache_headers", get_defined_vars ());
|
169 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
170 |
+
|
171 |
$using_selective_behavior = /* Off by default. */ apply_filters ("ws_plugin__s2member_no_cache_headers_selective", false, get_defined_vars ());
|
172 |
+
|
173 |
if (!$once && !headers_sent () && empty ($_GET["qcABC"]) && ($no_cache || !$using_selective_behavior || c_ws_plugin__s2member_no_cache::$headers))
|
174 |
if ( /* Give Filters a chance. */!apply_filters ("ws_plugin__s2member_disable_no_cache_headers", false, get_defined_vars ()))
|
175 |
{
|
176 |
+
foreach (headers_list () as $header) // No-cache headers already sent? We need to check here.
|
177 |
+
if (stripos ($header, "no-cache") !== false) // No-cache headers already sent?
|
178 |
{
|
179 |
+
$no_cache_headers_already_sent = true; // Yep, sent.
|
180 |
+
break; // Break now, no need to continue further.
|
181 |
}
|
182 |
+
if (!isset ($no_cache_headers_already_sent)) // Not yet?
|
183 |
+
nocache_headers (); // Only if NOT already sent.
|
184 |
+
|
185 |
+
$once = true; // This is static var. Only send headers once.
|
186 |
+
|
187 |
do_action ("ws_plugin__s2member_during_no_cache_headers", get_defined_vars ());
|
188 |
}
|
189 |
+
|
190 |
do_action ("ws_plugin__s2member_after_no_cache_headers", get_defined_vars ());
|
191 |
+
|
192 |
+
return true; // Always return true.
|
193 |
}
|
194 |
}
|
195 |
}
|
includes/classes/op-notices.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_op_notices"))
|
21 |
{
|
22 |
/**
|
@@ -39,26 +39,26 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
|
|
39 |
*/
|
40 |
public static function general_ops_notice ()
|
41 |
{
|
42 |
-
global $pagenow;
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_before_general_ops_notice", get_defined_vars ());
|
45 |
-
|
46 |
-
if (is_blog_admin () && $pagenow === "options-general.php" && !isset ($_GET["page"]) && !is_multisite ())
|
47 |
{
|
48 |
-
$notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_option ("users_can_register")) . "</code>, and <code>Default Role = " . esc_html (get_option ("default_role")) . "</code>.<br />For further details, see: <code>s2Member
|
49 |
-
|
50 |
$js = '<script type="text/javascript">';
|
51 |
$js .= "jQuery('input#users_can_register, select#default_role').attr('disabled', 'disabled');";
|
52 |
$js .= '</script>';
|
53 |
-
|
54 |
do_action ("ws_plugin__s2member_during_general_ops_notice", get_defined_vars ());
|
55 |
-
|
56 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "blog:" . $pagenow);
|
57 |
}
|
58 |
-
|
59 |
do_action ("ws_plugin__s2member_after_general_ops_notice", get_defined_vars ());
|
60 |
-
|
61 |
-
return
|
62 |
}
|
63 |
/**
|
64 |
* Describes the Multisite Option overrides for clarity.
|
@@ -72,26 +72,26 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
|
|
72 |
*/
|
73 |
public static function multisite_ops_notice ()
|
74 |
{
|
75 |
-
global $pagenow;
|
76 |
-
|
77 |
do_action ("ws_plugin__s2member_before_multisite_ops_notice", get_defined_vars ());
|
78 |
-
|
79 |
if (is_multisite () && is_network_admin () && in_array ($pagenow, array ("settings.php")) && !isset ($_GET["page"]))
|
80 |
{
|
81 |
-
$notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_site_option ("registration")) . "</code> and <code>Add New Users = " . esc_html (get_site_option ("add_new_users")) . "</code>.<br />Please check: <code>s2Member
|
82 |
-
|
83 |
$js = '<script type="text/javascript">';
|
84 |
$js .= "jQuery('input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
|
85 |
$js .= '</script>';
|
86 |
-
|
87 |
do_action ("ws_plugin__s2member_during_multisite_ops_notice", get_defined_vars ());
|
88 |
-
|
89 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "network:" . $pagenow);
|
90 |
}
|
91 |
-
|
92 |
do_action ("ws_plugin__s2member_after_multisite_ops_notice", get_defined_vars ());
|
93 |
-
|
94 |
-
return
|
95 |
}
|
96 |
/**
|
97 |
* Deals with Reading Option conflicts.
|
@@ -105,34 +105,34 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
|
|
105 |
*/
|
106 |
public static function reading_ops_notice ()
|
107 |
{
|
108 |
-
global $pagenow;
|
109 |
-
|
110 |
do_action ("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars ());
|
111 |
-
|
112 |
if (is_blog_admin () && $pagenow === "options-reading.php" && !isset ($_GET["page"]))
|
113 |
{
|
114 |
-
do_action ("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars ());
|
115 |
-
|
116 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]
|
117 |
-
&& ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Home Page (
|
118 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
119 |
-
|
120 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]
|
121 |
-
&& ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Home Page (
|
122 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
123 |
-
|
124 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]
|
125 |
-
&& ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Posts Page (
|
126 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
127 |
-
|
128 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]
|
129 |
-
&& ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Posts Page (
|
130 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
131 |
}
|
132 |
-
|
133 |
do_action ("ws_plugin__s2member_after_reading_ops_notice", get_defined_vars ());
|
134 |
-
|
135 |
-
return
|
136 |
}
|
137 |
}
|
138 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_op_notices"))
|
21 |
{
|
22 |
/**
|
39 |
*/
|
40 |
public static function general_ops_notice ()
|
41 |
{
|
42 |
+
global $pagenow; // Need this global variable.
|
43 |
+
|
44 |
do_action ("ws_plugin__s2member_before_general_ops_notice", get_defined_vars ());
|
45 |
+
|
46 |
+
if (is_blog_admin () && $pagenow === "options-general.php" && !isset ($_GET["page"]) && !is_multisite ()) // Multisite does NOT provide these options.
|
47 |
{
|
48 |
+
$notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_option ("users_can_register")) . "</code>, and <code>Default Role = " . esc_html (get_option ("default_role")) . "</code>.<br />For further details, see: <code>s2Member -› General Options -› Open Registration</code>.";
|
49 |
+
|
50 |
$js = '<script type="text/javascript">';
|
51 |
$js .= "jQuery('input#users_can_register, select#default_role').attr('disabled', 'disabled');";
|
52 |
$js .= '</script>';
|
53 |
+
|
54 |
do_action ("ws_plugin__s2member_during_general_ops_notice", get_defined_vars ());
|
55 |
+
|
56 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "blog:" . $pagenow);
|
57 |
}
|
58 |
+
|
59 |
do_action ("ws_plugin__s2member_after_general_ops_notice", get_defined_vars ());
|
60 |
+
|
61 |
+
return /* Return for uniformity. */;
|
62 |
}
|
63 |
/**
|
64 |
* Describes the Multisite Option overrides for clarity.
|
72 |
*/
|
73 |
public static function multisite_ops_notice ()
|
74 |
{
|
75 |
+
global $pagenow; // Need this global variable.
|
76 |
+
|
77 |
do_action ("ws_plugin__s2member_before_multisite_ops_notice", get_defined_vars ());
|
78 |
+
|
79 |
if (is_multisite () && is_network_admin () && in_array ($pagenow, array ("settings.php")) && !isset ($_GET["page"]))
|
80 |
{
|
81 |
+
$notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_site_option ("registration")) . "</code> and <code>Add New Users = " . esc_html (get_site_option ("add_new_users")) . "</code>.<br />Please check: <code>s2Member -› Multisite (Config)</code>.";
|
82 |
+
|
83 |
$js = '<script type="text/javascript">';
|
84 |
$js .= "jQuery('input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
|
85 |
$js .= '</script>';
|
86 |
+
|
87 |
do_action ("ws_plugin__s2member_during_multisite_ops_notice", get_defined_vars ());
|
88 |
+
|
89 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice . $js, "network:" . $pagenow);
|
90 |
}
|
91 |
+
|
92 |
do_action ("ws_plugin__s2member_after_multisite_ops_notice", get_defined_vars ());
|
93 |
+
|
94 |
+
return /* Return for uniformity. */;
|
95 |
}
|
96 |
/**
|
97 |
* Deals with Reading Option conflicts.
|
105 |
*/
|
106 |
public static function reading_ops_notice ()
|
107 |
{
|
108 |
+
global $pagenow; // Need this global variable.
|
109 |
+
|
110 |
do_action ("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars ());
|
111 |
+
|
112 |
if (is_blog_admin () && $pagenow === "options-reading.php" && !isset ($_GET["page"]))
|
113 |
{
|
114 |
+
do_action ("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars ()); // Now check for conflicts.
|
115 |
+
|
116 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]
|
117 |
+
&& ($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.'))
|
118 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
119 |
+
|
120 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]
|
121 |
+
&& ($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.'))
|
122 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
123 |
+
|
124 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]
|
125 |
+
&& ($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.'))
|
126 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
127 |
+
|
128 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string)get_option ("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]
|
129 |
+
&& ($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.'))
|
130 |
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "blog:" . $pagenow, true);
|
131 |
}
|
132 |
+
|
133 |
do_action ("ws_plugin__s2member_after_reading_ops_notice", get_defined_vars ());
|
134 |
+
|
135 |
+
return /* Return for uniformity. */;
|
136 |
}
|
137 |
}
|
138 |
}
|
includes/classes/option-forces.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
21 |
{
|
22 |
/**
|
@@ -41,11 +41,11 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
41 |
public static function force_default_role ($default_role = FALSE)
|
42 |
{
|
43 |
do_action ("ws_plugin__s2member_before_force_default_role", get_defined_vars ());
|
44 |
-
|
45 |
return apply_filters ("ws_plugin__s2member_force_default_role", ($default_role = "subscriber"), get_defined_vars ());
|
46 |
}
|
47 |
/**
|
48 |
-
* Forces a default Role for new Multisite registrations (
|
49 |
*
|
50 |
* @package s2Member\Option_Forces
|
51 |
* @since 3.5
|
@@ -58,7 +58,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
58 |
public static function force_mms_default_role ($default_role = FALSE)
|
59 |
{
|
60 |
do_action ("ws_plugin__s2member_before_force_mms_default_role", get_defined_vars ());
|
61 |
-
|
62 |
return apply_filters ("ws_plugin__s2member_force_mms_default_role", ($default_role = "subscriber"), get_defined_vars ());
|
63 |
}
|
64 |
/**
|
@@ -75,7 +75,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
75 |
public static function force_demotion_role ($demotion_role = FALSE)
|
76 |
{
|
77 |
do_action ("ws_plugin__s2member_before_force_demotion_role", get_defined_vars ());
|
78 |
-
|
79 |
return apply_filters ("ws_plugin__s2member_force_demotion_role", ($demotion_role = "subscriber"), get_defined_vars ());
|
80 |
}
|
81 |
/**
|
@@ -92,7 +92,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
92 |
public static function mms_allow_new_users ($allow = FALSE)
|
93 |
{
|
94 |
do_action ("ws_plugin__s2member_before_mms_allow_new_users", get_defined_vars ());
|
95 |
-
|
96 |
return apply_filters ("ws_plugin__s2member_mms_allow_new_users", ($allow = "1"), get_defined_vars ());
|
97 |
}
|
98 |
/**
|
@@ -108,12 +108,12 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
108 |
*/
|
109 |
public static function mms_dashboard_blog ($dashboard_blog = FALSE)
|
110 |
{
|
111 |
-
global
|
112 |
-
|
113 |
do_action ("ws_plugin__s2member_before_mms_dashboard_blog", get_defined_vars ());
|
114 |
-
|
115 |
-
$main_site = ((is_multisite ()) ? $current_site->blog_id : "1");
|
116 |
-
|
117 |
return apply_filters ("ws_plugin__s2member_mms_dashboard_blog", ($dashboard_blog = $main_site), get_defined_vars ());
|
118 |
}
|
119 |
/**
|
@@ -129,18 +129,18 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
129 |
*/
|
130 |
public static function check_register_access ($users_can_register = FALSE)
|
131 |
{
|
132 |
-
global $wpdb;
|
133 |
-
|
134 |
-
|
135 |
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
136 |
-
unset
|
137 |
-
|
138 |
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"];
|
139 |
-
|
140 |
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ())
|
141 |
return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "0"), get_defined_vars ());
|
142 |
-
|
143 |
-
else if (!is_admin () && !$users_can_register)
|
144 |
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site () || current_user_can ("create_users") || is_super_admin ())
|
145 |
{
|
146 |
if (current_user_can ("create_users") || (is_multisite () && is_super_admin ()) || c_ws_plugin__s2member_register_access::reg_cookies_ok ())
|
@@ -148,7 +148,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
148 |
return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "1"), get_defined_vars ());
|
149 |
}
|
150 |
}
|
151 |
-
|
152 |
return apply_filters ("ws_plugin__s2member_check_register_access", $users_can_register, get_defined_vars ());
|
153 |
}
|
154 |
/**
|
@@ -164,38 +164,38 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
164 |
*/
|
165 |
public static function check_mms_register_access ($users_can_register = FALSE)
|
166 |
{
|
167 |
-
global $wpdb;
|
168 |
-
global
|
169 |
-
|
170 |
-
|
171 |
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
172 |
-
unset
|
173 |
-
|
174 |
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"];
|
175 |
-
|
176 |
if (c_ws_plugin__s2member_utils_conds::bp_is_installed () && is_multisite () && /* BP Multisite / but NOT offering Blogs? */ !c_ws_plugin__s2member_utils_conds::is_multisite_farm ())
|
177 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = ((c_ws_plugin__s2member_option_forces::check_register_access ()) ? "user" : "none")), get_defined_vars ());
|
178 |
-
|
179 |
-
else if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm ())
|
180 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
181 |
-
|
182 |
-
else if (!is_network_admin () && $users_can_register !== "all")
|
183 |
{
|
184 |
-
if ((is_main_site () && current_user_can ("create_users")) || is_super_admin ())
|
185 |
{
|
186 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
187 |
}
|
188 |
-
|
189 |
else if (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && $user->ID && is_object ($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID && $user->has_cap ("access_s2member_level1"))
|
190 |
{
|
191 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options ();
|
192 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)];
|
193 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
|
194 |
-
|
195 |
-
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0;
|
196 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
197 |
-
|
198 |
-
if ($user_blogs < $blogs_allowed)
|
199 |
{
|
200 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
201 |
}
|
@@ -206,31 +206,31 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
206 |
{
|
207 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
208 |
}
|
209 |
-
else
|
210 |
{
|
211 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "user"), get_defined_vars ());
|
212 |
}
|
213 |
}
|
214 |
}
|
215 |
-
|
216 |
-
else if (!is_network_admin () && $users_can_register === "all")
|
217 |
{
|
218 |
if (is_user_logged_in () && !(is_main_site () && current_user_can ("create_users")) && !is_super_admin () && is_object ($user = wp_get_current_user ()) && $user->ID && is_object ($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID)
|
219 |
{
|
220 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options ();
|
221 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)];
|
222 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
|
223 |
-
|
224 |
-
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0;
|
225 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
226 |
-
|
227 |
-
if ($user_blogs >= $blogs_allowed)
|
228 |
{
|
229 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
230 |
}
|
231 |
}
|
232 |
}
|
233 |
-
|
234 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", $users_can_register, get_defined_vars ());
|
235 |
}
|
236 |
/**
|
@@ -242,16 +242,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
|
242 |
* @since 3.5
|
243 |
*
|
244 |
* @attaches-to ``add_filter("bp_core_get_root_options");``
|
245 |
-
* @attaches-to ``add_filter("bp_core_get_site_options");`` **(
|
246 |
*
|
247 |
* @param array $site_options Expects array of BuddyPress site options.
|
248 |
* @return array Site options array, after having been Filtered by this routine.
|
249 |
*/
|
250 |
public static function check_bp_mms_register_access ($site_options = FALSE)
|
251 |
{
|
252 |
-
if (is_multisite ())
|
253 |
$site_options["registration"] = c_ws_plugin__s2member_option_forces::check_mms_register_access ($site_options["registration"]);
|
254 |
-
|
255 |
return apply_filters ("ws_plugin__s2member_check_bp_mms_register_access", $site_options, get_defined_vars ());
|
256 |
}
|
257 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_option_forces"))
|
21 |
{
|
22 |
/**
|
41 |
public static function force_default_role ($default_role = FALSE)
|
42 |
{
|
43 |
do_action ("ws_plugin__s2member_before_force_default_role", get_defined_vars ());
|
44 |
+
|
45 |
return apply_filters ("ws_plugin__s2member_force_default_role", ($default_role = "subscriber"), get_defined_vars ());
|
46 |
}
|
47 |
/**
|
48 |
+
* Forces a default Role for new Multisite registrations (on the Main Site) NOT tied to an incoming payment.
|
49 |
*
|
50 |
* @package s2Member\Option_Forces
|
51 |
* @since 3.5
|
58 |
public static function force_mms_default_role ($default_role = FALSE)
|
59 |
{
|
60 |
do_action ("ws_plugin__s2member_before_force_mms_default_role", get_defined_vars ());
|
61 |
+
|
62 |
return apply_filters ("ws_plugin__s2member_force_mms_default_role", ($default_role = "subscriber"), get_defined_vars ());
|
63 |
}
|
64 |
/**
|
75 |
public static function force_demotion_role ($demotion_role = FALSE)
|
76 |
{
|
77 |
do_action ("ws_plugin__s2member_before_force_demotion_role", get_defined_vars ());
|
78 |
+
|
79 |
return apply_filters ("ws_plugin__s2member_force_demotion_role", ($demotion_role = "subscriber"), get_defined_vars ());
|
80 |
}
|
81 |
/**
|
92 |
public static function mms_allow_new_users ($allow = FALSE)
|
93 |
{
|
94 |
do_action ("ws_plugin__s2member_before_mms_allow_new_users", get_defined_vars ());
|
95 |
+
|
96 |
return apply_filters ("ws_plugin__s2member_mms_allow_new_users", ($allow = "1"), get_defined_vars ());
|
97 |
}
|
98 |
/**
|
108 |
*/
|
109 |
public static function mms_dashboard_blog ($dashboard_blog = FALSE)
|
110 |
{
|
111 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
112 |
+
|
113 |
do_action ("ws_plugin__s2member_before_mms_dashboard_blog", get_defined_vars ());
|
114 |
+
|
115 |
+
$main_site = ((is_multisite ()) ? $current_site->blog_id : "1"); // Forces the Main Site.
|
116 |
+
|
117 |
return apply_filters ("ws_plugin__s2member_mms_dashboard_blog", ($dashboard_blog = $main_site), get_defined_vars ());
|
118 |
}
|
119 |
/**
|
129 |
*/
|
130 |
public static function check_register_access ($users_can_register = FALSE)
|
131 |
{
|
132 |
+
global $wpdb; // Global database object reference
|
133 |
+
|
134 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
135 |
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
136 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
137 |
+
|
138 |
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"];
|
139 |
+
|
140 |
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ())
|
141 |
return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "0"), get_defined_vars ());
|
142 |
+
|
143 |
+
else if (!is_admin () && !$users_can_register) // Do NOT run these security checks on option pages; it's confusing.
|
144 |
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site () || current_user_can ("create_users") || is_super_admin ())
|
145 |
{
|
146 |
if (current_user_can ("create_users") || (is_multisite () && is_super_admin ()) || c_ws_plugin__s2member_register_access::reg_cookies_ok ())
|
148 |
return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "1"), get_defined_vars ());
|
149 |
}
|
150 |
}
|
151 |
+
|
152 |
return apply_filters ("ws_plugin__s2member_check_register_access", $users_can_register, get_defined_vars ());
|
153 |
}
|
154 |
/**
|
164 |
*/
|
165 |
public static function check_mms_register_access ($users_can_register = FALSE)
|
166 |
{
|
167 |
+
global $wpdb; // Global database object reference
|
168 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
169 |
+
|
170 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
171 |
do_action ("ws_plugin__s2member_before_check_register_access", get_defined_vars ());
|
172 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
173 |
+
|
174 |
$by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"];
|
175 |
+
|
176 |
if (c_ws_plugin__s2member_utils_conds::bp_is_installed () && is_multisite () && /* BP Multisite / but NOT offering Blogs? */ !c_ws_plugin__s2member_utils_conds::is_multisite_farm ())
|
177 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = ((c_ws_plugin__s2member_option_forces::check_register_access ()) ? "user" : "none")), get_defined_vars ());
|
178 |
+
|
179 |
+
else if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm ()) // Blog Farm?
|
180 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
181 |
+
|
182 |
+
else if (!is_network_admin () && $users_can_register !== "all") // Do NOT run these checks on Network option pages; it's confusing.
|
183 |
{
|
184 |
+
if ((is_main_site () && current_user_can ("create_users")) || is_super_admin ()) // Creates Users on the Main Site?
|
185 |
{
|
186 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
187 |
}
|
188 |
+
|
189 |
else if (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && $user->ID && is_object ($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID && $user->has_cap ("access_s2member_level1"))
|
190 |
{
|
191 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options ();
|
192 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)];
|
193 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
|
194 |
+
|
195 |
+
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; // NOT less than zero.
|
196 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
197 |
+
|
198 |
+
if ($user_blogs < $blogs_allowed) // Are they within their limit?
|
199 |
{
|
200 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
201 |
}
|
206 |
{
|
207 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "all"), get_defined_vars ());
|
208 |
}
|
209 |
+
else // Otherwise, we MUST allow them to at least create an account; they paid for it! Defaults to `user`.
|
210 |
{
|
211 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "user"), get_defined_vars ());
|
212 |
}
|
213 |
}
|
214 |
}
|
215 |
+
|
216 |
+
else if (!is_network_admin () && $users_can_register === "all") // Do NOT run these security checks on option pages; it's confusing to a site owner.
|
217 |
{
|
218 |
if (is_user_logged_in () && !(is_main_site () && current_user_can ("create_users")) && !is_super_admin () && is_object ($user = wp_get_current_user ()) && $user->ID && is_object ($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID)
|
219 |
{
|
220 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options ();
|
221 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)];
|
222 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
|
223 |
+
|
224 |
+
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; // NOT less than zero.
|
225 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
|
226 |
+
|
227 |
+
if ($user_blogs >= $blogs_allowed) // Are they at their limit?
|
228 |
{
|
229 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
|
230 |
}
|
231 |
}
|
232 |
}
|
233 |
+
|
234 |
return apply_filters ("ws_plugin__s2member_check_mms_register_access", $users_can_register, get_defined_vars ());
|
235 |
}
|
236 |
/**
|
242 |
* @since 3.5
|
243 |
*
|
244 |
* @attaches-to ``add_filter("bp_core_get_root_options");``
|
245 |
+
* @attaches-to ``add_filter("bp_core_get_site_options");`` **(before BuddyPress v1.5)**.
|
246 |
*
|
247 |
* @param array $site_options Expects array of BuddyPress site options.
|
248 |
* @return array Site options array, after having been Filtered by this routine.
|
249 |
*/
|
250 |
public static function check_bp_mms_register_access ($site_options = FALSE)
|
251 |
{
|
252 |
+
if (is_multisite ()) // Only if Multisite Networking is enabled. Pointless otherwise.
|
253 |
$site_options["registration"] = c_ws_plugin__s2member_option_forces::check_mms_register_access ($site_options["registration"]);
|
254 |
+
|
255 |
return apply_filters ("ws_plugin__s2member_check_bp_mms_register_access", $site_options, get_defined_vars ());
|
256 |
}
|
257 |
}
|
includes/classes/pages-sp.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's Page protection routines *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's Page protection routines *(
|
24 |
*
|
25 |
* @package s2Member\Pages
|
26 |
* @since 3.5
|
@@ -28,90 +28,90 @@ if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
|
|
28 |
class c_ws_plugin__s2member_pages_sp
|
29 |
{
|
30 |
/**
|
31 |
-
* Handles Page Level Access *(
|
32 |
*
|
33 |
* @package s2Member\Pages
|
34 |
* @since 3.5
|
35 |
*
|
36 |
* @param int|str $page_id Numeric Page ID.
|
37 |
* @param bool $check_user Test permissions against the current User? Defaults to true.
|
38 |
-
* @return null|array Non-empty array (
|
39 |
*
|
40 |
-
* @todo Provide more information in the return array (
|
41 |
*/
|
42 |
public static function check_specific_page_level_access ($page_id = FALSE, $check_user = TRUE)
|
43 |
{
|
44 |
do_action ("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars ());
|
45 |
-
|
46 |
$excluded = apply_filters ("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars ());
|
47 |
-
|
48 |
if (!$excluded && is_numeric ($page_id) && ($page_id = (int)$page_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
49 |
{
|
50 |
-
$page_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_page_link ($page_id));
|
51 |
-
|
52 |
-
if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page ($page_id, $page_uri))
|
53 |
{
|
54 |
-
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
55 |
-
|
56 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
57 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
58 |
-
|
59 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $page_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
60 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
61 |
-
|
62 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
63 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
64 |
-
|
65 |
-
else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page ($page_id, $page_uri))
|
66 |
{
|
67 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
68 |
{
|
69 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
70 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
71 |
-
|
72 |
else if (strpos ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") !== false && in_array ("all-pages", preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
73 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
74 |
-
|
75 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
76 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
77 |
}
|
78 |
-
|
79 |
-
if (has_tag ("", $page_id))
|
80 |
{
|
81 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
82 |
{
|
83 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
84 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
85 |
-
|
86 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $page_id) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
87 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
88 |
}
|
89 |
}
|
90 |
-
|
91 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
92 |
{
|
93 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
94 |
-
|
95 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
96 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $page_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
97 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
98 |
}
|
99 |
-
|
100 |
if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
|
101 |
{
|
102 |
-
foreach ($ccaps_req as $ccap)
|
103 |
if (strlen ($ccap) && (!$check_user || !$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
|
104 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
|
105 |
}
|
106 |
-
|
107 |
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")))
|
108 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_sp_req" => $page_id), get_defined_vars ());
|
109 |
}
|
110 |
-
|
111 |
do_action ("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars ());
|
112 |
}
|
113 |
}
|
114 |
-
|
115 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars ());
|
116 |
}
|
117 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's Page protection routines *(for specific Pages)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's Page protection routines *(for specific Pages)*.
|
24 |
*
|
25 |
* @package s2Member\Pages
|
26 |
* @since 3.5
|
28 |
class c_ws_plugin__s2member_pages_sp
|
29 |
{
|
30 |
/**
|
31 |
+
* Handles Page Level Access *(for specific Pages)*.
|
32 |
*
|
33 |
* @package s2Member\Pages
|
34 |
* @since 3.5
|
35 |
*
|
36 |
* @param int|str $page_id Numeric Page ID.
|
37 |
* @param bool $check_user Test permissions against the current User? Defaults to true.
|
38 |
+
* @return null|array Non-empty array (with details) if access is denied, else null if access is allowed.
|
39 |
*
|
40 |
+
* @todo Provide more information in the return array (like MOP Vars).
|
41 |
*/
|
42 |
public static function check_specific_page_level_access ($page_id = FALSE, $check_user = TRUE)
|
43 |
{
|
44 |
do_action ("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars ());
|
45 |
+
|
46 |
$excluded = apply_filters ("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars ());
|
47 |
+
|
48 |
if (!$excluded && is_numeric ($page_id) && ($page_id = (int)$page_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
49 |
{
|
50 |
+
$page_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_page_link ($page_id)); // Get a full valid URI for this Page now.
|
51 |
+
|
52 |
+
if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page ($page_id, $page_uri)) // Do NOT touch WordPress® Systematics.
|
53 |
{
|
54 |
+
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false; // Current User's object.
|
55 |
+
|
56 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
57 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
58 |
+
|
59 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $page_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
60 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
61 |
+
|
62 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
63 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
|
64 |
+
|
65 |
+
else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page ($page_id, $page_uri)) // However, there are 3 exceptions above.
|
66 |
{
|
67 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Page Level restrictions. Go through each Level.
|
68 |
{
|
69 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
70 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
71 |
+
|
72 |
else if (strpos ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") !== false && in_array ("all-pages", preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
73 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
74 |
+
|
75 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
76 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
77 |
}
|
78 |
+
|
79 |
+
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.
|
80 |
{
|
81 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Tag Level restrictions (possibly through Page Tagger). Go through each Level.
|
82 |
{
|
83 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
84 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
85 |
+
|
86 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $page_id) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
87 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
88 |
}
|
89 |
}
|
90 |
+
|
91 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // URIs. Go through each Level.
|
92 |
{
|
93 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) // URIs configured at this Level?
|
94 |
+
|
95 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
96 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $page_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
|
97 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
|
98 |
}
|
99 |
+
|
100 |
if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
|
101 |
{
|
102 |
+
foreach ($ccaps_req as $ccap) // The ``$user`` MUST satisfy ALL Custom Capabilities.
|
103 |
if (strlen ($ccap) && (!$check_user || !$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
|
104 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
|
105 |
}
|
106 |
+
|
107 |
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")))
|
108 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_sp_req" => $page_id), get_defined_vars ());
|
109 |
}
|
110 |
+
|
111 |
do_action ("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars ());
|
112 |
}
|
113 |
}
|
114 |
+
|
115 |
return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars ());
|
116 |
}
|
117 |
}
|
includes/classes/pages.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's Page protection routines *(
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_pages"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's Page protection routines *(
|
24 |
*
|
25 |
* @package s2Member\Pages
|
26 |
* @since 3.5
|
@@ -28,7 +28,7 @@ if (!class_exists ("c_ws_plugin__s2member_pages"))
|
|
28 |
class c_ws_plugin__s2member_pages
|
29 |
{
|
30 |
/**
|
31 |
-
* Handles Page Level Access permissions *(
|
32 |
*
|
33 |
* @package s2Member\Pages
|
34 |
* @since 3.5
|
@@ -37,80 +37,80 @@ if (!class_exists ("c_ws_plugin__s2member_pages"))
|
|
37 |
*/
|
38 |
public static function check_page_level_access ()
|
39 |
{
|
40 |
-
global $post;
|
41 |
-
|
42 |
do_action ("ws_plugin__s2member_before_check_page_level_access", get_defined_vars ());
|
43 |
-
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars ());
|
45 |
-
|
46 |
if (!$excluded && is_page () && is_object ($post) && !empty ($post->ID) && ($page_id = (int)$post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
-
if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page ())
|
49 |
{
|
50 |
-
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false;
|
51 |
-
|
52 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
53 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
54 |
-
|
55 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
56 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
57 |
-
|
58 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
59 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
60 |
-
|
61 |
-
else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ())
|
62 |
{
|
63 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
64 |
{
|
65 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
66 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
67 |
-
|
68 |
else if (strpos ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") && in_array ("all-pages", preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
69 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "post") . exit ();
|
70 |
-
|
71 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
72 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
73 |
}
|
74 |
-
|
75 |
-
if (has_tag ())
|
76 |
{
|
77 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
78 |
{
|
79 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
80 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit ();
|
81 |
-
|
82 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
83 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit ();
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
-
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--)
|
88 |
{
|
89 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
90 |
-
|
91 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
92 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
93 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit ();
|
94 |
}
|
95 |
-
|
96 |
if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants (true))
|
97 |
{
|
98 |
-
foreach ($ccaps_req as $ccap)
|
99 |
if (strlen ($ccap) && (!$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)) /* Does this ``$user``, have this Custom Capability? */)
|
100 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "ccap", $ccap, $_SERVER["REQUEST_URI"], "ccap") . exit ();
|
101 |
}
|
102 |
-
|
103 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && !c_ws_plugin__s2member_sp_access::sp_access ($page_id))
|
104 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "sp", $page_id, $_SERVER["REQUEST_URI"], "sp") . exit ();
|
105 |
}
|
106 |
-
|
107 |
do_action ("ws_plugin__s2member_during_check_page_level_access", get_defined_vars ());
|
108 |
}
|
109 |
}
|
110 |
-
|
111 |
do_action ("ws_plugin__s2member_after_check_page_level_access", get_defined_vars ());
|
112 |
-
|
113 |
-
return;
|
114 |
}
|
115 |
}
|
116 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's Page protection routines *(for current Page)*.
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_pages"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's Page protection routines *(for current Page)*.
|
24 |
*
|
25 |
* @package s2Member\Pages
|
26 |
* @since 3.5
|
28 |
class c_ws_plugin__s2member_pages
|
29 |
{
|
30 |
/**
|
31 |
+
* Handles Page Level Access permissions *(for current Page)*.
|
32 |
*
|
33 |
* @package s2Member\Pages
|
34 |
* @since 3.5
|
37 |
*/
|
38 |
public static function check_page_level_access ()
|
39 |
{
|
40 |
+
global $post; // ``get_the_ID()`` unavailable outside The Loop.
|
41 |
+
|
42 |
do_action ("ws_plugin__s2member_before_check_page_level_access", get_defined_vars ());
|
43 |
+
|
44 |
$excluded = apply_filters ("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars ());
|
45 |
+
|
46 |
if (!$excluded && is_page () && is_object ($post) && !empty ($post->ID) && ($page_id = (int)$post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
47 |
{
|
48 |
+
if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page ()) // Do NOT touch WordPress® Systematics. This excludes all WordPress® Systematics.
|
49 |
{
|
50 |
+
$user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID)) ? $user : false; // Current User's object.
|
51 |
+
|
52 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
53 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
54 |
+
|
55 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
56 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
57 |
+
|
58 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level0")) && $page_id !== (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
|
59 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
|
60 |
+
|
61 |
+
else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) // Never restrict Systematics. However, there are 3 exceptions above.
|
62 |
{
|
63 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Page Level restrictions. Go through each Level.
|
64 |
{
|
65 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
66 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
67 |
+
|
68 |
else if (strpos ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") && in_array ("all-pages", preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
69 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "post") . exit ();
|
70 |
+
|
71 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
72 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
|
73 |
}
|
74 |
+
|
75 |
+
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.
|
76 |
{
|
77 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Tag Level restrictions (possibly through Page Tagger). Go through each Level.
|
78 |
{
|
79 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
80 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit ();
|
81 |
+
|
82 |
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
83 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit ();
|
84 |
}
|
85 |
}
|
86 |
+
|
87 |
+
for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // URIs. Go through each Level.
|
88 |
{
|
89 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) // URIs configured at this Level?
|
90 |
+
|
91 |
foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
|
92 |
if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && (!$user || !$user->has_cap ("access_s2member_level" . $n)))
|
93 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit ();
|
94 |
}
|
95 |
+
|
96 |
if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants (true))
|
97 |
{
|
98 |
+
foreach ($ccaps_req as $ccap) // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities.
|
99 |
if (strlen ($ccap) && (!$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)) /* Does this ``$user``, have this Custom Capability? */)
|
100 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "ccap", $ccap, $_SERVER["REQUEST_URI"], "ccap") . exit ();
|
101 |
}
|
102 |
+
|
103 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) && !c_ws_plugin__s2member_sp_access::sp_access ($page_id))
|
104 |
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("page", $page_id, "sp", $page_id, $_SERVER["REQUEST_URI"], "sp") . exit ();
|
105 |
}
|
106 |
+
|
107 |
do_action ("ws_plugin__s2member_during_check_page_level_access", get_defined_vars ());
|
108 |
}
|
109 |
}
|
110 |
+
|
111 |
do_action ("ws_plugin__s2member_after_check_page_level_access", get_defined_vars ());
|
112 |
+
|
113 |
+
return; // For uniformity.
|
114 |
}
|
115 |
}
|
116 |
}
|
includes/classes/paypal-notify-in-cart.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_cart"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,54 +28,53 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_cart"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_cart
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract ($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
-
&& (!empty ($paypal["txn_id"]))
|
46 |
{
|
47 |
-
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_cart", get_defined_vars ());
|
49 |
-
unset
|
50 |
-
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `cart` ).";
|
54 |
-
|
55 |
-
$processing = $during = true;
|
56 |
-
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
$paypal["s2member_log"][] = "s2Member Pro handles Cart events on-site, with an IPN proxy.";
|
59 |
-
|
60 |
-
|
61 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_cart", get_defined_vars ());
|
62 |
-
unset
|
63 |
}
|
64 |
-
else
|
65 |
{
|
66 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
67 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `cart` ).";
|
68 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_cart", get_defined_vars ());
|
73 |
-
unset
|
74 |
-
|
75 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_cart", $paypal, get_defined_vars ());
|
76 |
}
|
77 |
-
else
|
78 |
-
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_cart", false, get_defined_vars ());
|
79 |
}
|
80 |
}
|
81 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_cart"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_cart
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^cart$/i", $paypal["txn_type"]))
|
44 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
+
&& (!empty ($paypal["txn_id"])))
|
46 |
{
|
47 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_cart", get_defined_vars ());
|
49 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
50 |
+
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `cart` ).";
|
54 |
+
|
55 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
56 |
+
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
$paypal["s2member_log"][] = "s2Member Pro handles Cart events on-site, with an IPN proxy.";
|
59 |
+
|
60 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
61 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_cart", get_defined_vars ());
|
62 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
63 |
}
|
64 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
65 |
{
|
66 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
67 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `cart` ).";
|
68 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
69 |
}
|
70 |
+
|
71 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_cart", get_defined_vars ());
|
73 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
74 |
+
|
75 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_cart", $paypal, get_defined_vars ());
|
76 |
}
|
77 |
+
else return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_cart", false, get_defined_vars ());
|
|
|
78 |
}
|
79 |
}
|
80 |
}
|
includes/classes/paypal-notify-in-express-checkout.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_express_checkout"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,50 +28,50 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_express_checkout"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_express_checkout
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
-
&& (!empty ($paypal["txn_id"]))
|
46 |
{
|
47 |
-
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_express_checkout", get_defined_vars ());
|
49 |
-
unset
|
50 |
-
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `express_checkout` ).";
|
54 |
-
|
55 |
-
$processing = $during = true;
|
56 |
-
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
$paypal["s2member_log"][] = "s2Member Pro handles Express Checkout events on-site, with an IPN proxy.";
|
59 |
-
|
60 |
-
|
61 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_express_checkout", get_defined_vars ());
|
62 |
-
unset
|
63 |
}
|
64 |
-
else
|
65 |
{
|
66 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
67 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `express_checkout` ).";
|
68 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_express_checkout", get_defined_vars ());
|
73 |
-
unset
|
74 |
-
|
75 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_express_checkout", $paypal, get_defined_vars ());
|
76 |
}
|
77 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_express_checkout"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_express_checkout
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^express_checkout$/i", $paypal["txn_type"]))
|
44 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
+
&& (!empty ($paypal["txn_id"])))
|
46 |
{
|
47 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_express_checkout", get_defined_vars ());
|
49 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
50 |
+
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `express_checkout` ).";
|
54 |
+
|
55 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
56 |
+
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
$paypal["s2member_log"][] = "s2Member Pro handles Express Checkout events on-site, with an IPN proxy.";
|
59 |
+
|
60 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
61 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_express_checkout", get_defined_vars ());
|
62 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
63 |
}
|
64 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
65 |
{
|
66 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
67 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `express_checkout` ).";
|
68 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
69 |
}
|
70 |
+
|
71 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_express_checkout", get_defined_vars ());
|
73 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
74 |
+
|
75 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_express_checkout", $paypal, get_defined_vars ());
|
76 |
}
|
77 |
else
|
includes/classes/paypal-notify-in-rec-profile-creation-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,52 +28,52 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
45 |
-
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
46 |
-
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
47 |
-
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))
|
48 |
{
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
|
56 |
-
|
57 |
-
$processing = $during = true;
|
58 |
-
|
59 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
60 |
$paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
|
61 |
-
|
62 |
-
|
63 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars ());
|
64 |
-
unset
|
65 |
}
|
66 |
-
else
|
67 |
{
|
68 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
69 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
|
70 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
71 |
}
|
72 |
-
|
73 |
-
|
74 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars ());
|
75 |
-
unset
|
76 |
-
|
77 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", $paypal, get_defined_vars ());
|
78 |
}
|
79 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^recurring_payment_profile_created$/i", $paypal["txn_type"]))
|
44 |
+
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
45 |
+
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
46 |
+
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
47 |
+
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"]))))
|
48 |
{
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars ());
|
51 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
52 |
+
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
|
56 |
+
|
57 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
58 |
+
|
59 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
60 |
$paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
|
61 |
+
|
62 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
63 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars ());
|
64 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
65 |
}
|
66 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
67 |
{
|
68 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
69 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
|
70 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
71 |
}
|
72 |
+
|
73 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
74 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars ());
|
75 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
76 |
+
|
77 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", $paypal, get_defined_vars ());
|
78 |
}
|
79 |
else
|
includes/classes/paypal-notify-in-send-money.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_send_money"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,49 +28,49 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_send_money"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_send_money
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
-
&& (!empty ($paypal["txn_id"]))
|
46 |
{
|
47 |
-
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_send_money", get_defined_vars ());
|
49 |
-
unset
|
50 |
-
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `send_money` ).";
|
54 |
-
|
55 |
-
$processing = $during = true;
|
56 |
-
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
-
|
59 |
-
|
60 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_send_money", get_defined_vars ());
|
61 |
-
unset
|
62 |
}
|
63 |
-
else
|
64 |
{
|
65 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
66 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `send_money` ).";
|
67 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
68 |
}
|
69 |
-
|
70 |
-
|
71 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_send_money", get_defined_vars ());
|
72 |
-
unset
|
73 |
-
|
74 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_send_money", $paypal, get_defined_vars ());
|
75 |
}
|
76 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_send_money"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_send_money
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^send_money$/i", $paypal["txn_type"]))
|
44 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
+
&& (!empty ($paypal["txn_id"])))
|
46 |
{
|
47 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_send_money", get_defined_vars ());
|
49 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
50 |
+
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `send_money` ).";
|
54 |
+
|
55 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
56 |
+
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
+
|
59 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
60 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_send_money", get_defined_vars ());
|
61 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
62 |
}
|
63 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
64 |
{
|
65 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
66 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `send_money` ).";
|
67 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
68 |
}
|
69 |
+
|
70 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
71 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_send_money", get_defined_vars ());
|
72 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
73 |
+
|
74 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_send_money", $paypal, get_defined_vars ());
|
75 |
}
|
76 |
else
|
includes/classes/paypal-notify-in-sp-refund-reversal.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,38 +28,38 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract ($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
|| (!empty ($paypal["payment_status"]) && preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in these special situations. */)
|
47 |
-
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
48 |
-
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))
|
49 |
-
&& (!empty ($paypal["payer_email"])) && (!empty ($paypal["parent_txn_id"]))
|
50 |
{
|
51 |
-
|
52 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
|
53 |
-
unset
|
54 |
-
|
55 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
56 |
{
|
57 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
|
58 |
-
|
59 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
-
|
62 |
-
$processing = $during = true;
|
63 |
/*
|
64 |
Refunds and chargeback reversals. This is excluded from the processing check.
|
65 |
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
@@ -69,7 +69,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
69 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
70 |
{
|
71 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url)
|
72 |
-
|
73 |
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)))
|
74 |
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)))
|
75 |
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)))
|
@@ -77,18 +77,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
77 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
78 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
79 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
80 |
-
|
81 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
82 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
83 |
-
|
84 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
|
85 |
}
|
86 |
-
|
87 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
88 |
{
|
89 |
-
$msg = $sbj = "(
|
90 |
-
$msg .= "\n\n";
|
91 |
-
|
92 |
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
93 |
$msg .= "item_number: %%item_number%%\n";
|
94 |
$msg .= "item_name: %%item_name%%\n";
|
@@ -99,7 +99,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
99 |
$msg .= "full_name: %%full_name%%\n";
|
100 |
$msg .= "payer_email: %%payer_email%%\n";
|
101 |
$msg .= "user_ip: %%user_ip%%\n";
|
102 |
-
|
103 |
$msg .= "cv0: %%cv0%%\n";
|
104 |
$msg .= "cv1: %%cv1%%\n";
|
105 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -110,7 +110,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
110 |
$msg .= "cv7: %%cv7%%\n";
|
111 |
$msg .= "cv8: %%cv8%%\n";
|
112 |
$msg .= "cv9: %%cv9%%";
|
113 |
-
|
114 |
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)))
|
115 |
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)))
|
116 |
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)))
|
@@ -118,30 +118,30 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
|
118 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
119 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
120 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
121 |
-
|
122 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
123 |
-
|
124 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"]) as $recipient)
|
125 |
-
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 ()), "Content-Type: text/plain; charset=
|
126 |
-
|
127 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
|
128 |
}
|
129 |
-
|
130 |
-
|
131 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_refund_reversal", get_defined_vars ());
|
132 |
-
unset
|
133 |
}
|
134 |
-
else
|
135 |
{
|
136 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
137 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
|
138 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
139 |
}
|
140 |
-
|
141 |
-
|
142 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_refund_reversal", get_defined_vars ());
|
143 |
-
unset
|
144 |
-
|
145 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal", $paypal, get_defined_vars ());
|
146 |
}
|
147 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if (((!empty ($paypal["txn_type"]) && preg_match ("/^new_case$/i", $paypal["txn_type"]) && !empty ($paypal["case_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"]))
|
46 |
+
|| (!empty ($paypal["payment_status"]) && preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in these special situations. */)
|
47 |
+
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
48 |
+
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))
|
49 |
+
&& (!empty ($paypal["payer_email"])) && (!empty ($paypal["parent_txn_id"])))
|
50 |
{
|
51 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
52 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
|
53 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
54 |
+
|
55 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
56 |
{
|
57 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
|
58 |
+
|
59 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
+
|
62 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
63 |
/*
|
64 |
Refunds and chargeback reversals. This is excluded from the processing check.
|
65 |
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
69 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
70 |
{
|
71 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url)
|
72 |
+
|
73 |
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)))
|
74 |
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)))
|
75 |
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)))
|
77 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
78 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
79 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
80 |
+
|
81 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
82 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
83 |
+
|
84 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
|
85 |
}
|
86 |
+
|
87 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
88 |
{
|
89 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Refund/Reversal";
|
90 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
91 |
+
|
92 |
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
93 |
$msg .= "item_number: %%item_number%%\n";
|
94 |
$msg .= "item_name: %%item_name%%\n";
|
99 |
$msg .= "full_name: %%full_name%%\n";
|
100 |
$msg .= "payer_email: %%payer_email%%\n";
|
101 |
$msg .= "user_ip: %%user_ip%%\n";
|
102 |
+
|
103 |
$msg .= "cv0: %%cv0%%\n";
|
104 |
$msg .= "cv1: %%cv1%%\n";
|
105 |
$msg .= "cv2: %%cv2%%\n";
|
110 |
$msg .= "cv7: %%cv7%%\n";
|
111 |
$msg .= "cv8: %%cv8%%\n";
|
112 |
$msg .= "cv9: %%cv9%%";
|
113 |
+
|
114 |
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)))
|
115 |
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)))
|
116 |
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)))
|
118 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
119 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
120 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
121 |
+
|
122 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
123 |
+
|
124 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"]) as $recipient)
|
125 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
126 |
+
|
127 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
|
128 |
}
|
129 |
+
|
130 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
131 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_refund_reversal", get_defined_vars ());
|
132 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
133 |
}
|
134 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
135 |
{
|
136 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
137 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
|
138 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
139 |
}
|
140 |
+
|
141 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
142 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_refund_reversal", get_defined_vars ());
|
143 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
144 |
+
|
145 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal", $paypal, get_defined_vars ());
|
146 |
}
|
147 |
else
|
includes/classes/paypal-notify-in-subscr-modify-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,114 +28,115 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (!empty ($paypal["subscr_id"])) && (!empty ($paypal["payer_email"]))
|
48 |
{
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ).";
|
56 |
-
|
57 |
list ($paypal["level"], $paypal["ccaps"]/*, $paypal["eotper"] */) = preg_split ("/\:/", $paypal["item_number"], 2);
|
58 |
-
|
59 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
-
|
62 |
-
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D";
|
63 |
-
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
64 |
-
|
65 |
-
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D";
|
66 |
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
67 |
-
$paypal["regular"] = $paypal["mc_amount3"];
|
68 |
-
$paypal["regular_term"] = $paypal["period3"];
|
69 |
-
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
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)
|
74 |
{
|
75 |
-
if (!$user->has_cap ("administrator"))
|
76 |
{
|
77 |
-
$processing = $modifying = $during = true;
|
78 |
-
|
79 |
-
|
80 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars ());
|
81 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
|
82 |
-
unset
|
83 |
-
|
84 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
85 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
86 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
87 |
-
|
88 |
-
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
89 |
{
|
90 |
add_existing_user_to_blog(array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
91 |
$user = new WP_User ($user_id);
|
92 |
}
|
93 |
-
|
94 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
95 |
-
|
96 |
-
if ($current_role !== "s2member_level" . $paypal["level"])
|
97 |
-
$user->set_role ("s2member_level" . $paypal["level"]);
|
98 |
-
|
99 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
100 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
101 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
102 |
$user->remove_cap ($ccap = $cap);
|
103 |
-
|
104 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
105 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
106 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
107 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
108 |
-
|
109 |
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
110 |
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
111 |
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
112 |
-
|
113 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
114 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
115 |
-
|
116 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
117 |
-
|
118 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
119 |
-
|
120 |
delete_user_option ($user_id, "s2member_auto_eot_time");
|
121 |
-
|
122 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
123 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"];
|
124 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
125 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
126 |
-
|
127 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
128 |
-
|
|
|
129 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
|
130 |
-
|
131 |
-
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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=
|
132 |
-
|
133 |
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
134 |
-
|
135 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
136 |
{
|
137 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
|
138 |
-
|
139 |
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)))
|
140 |
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)))
|
141 |
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)))
|
@@ -143,7 +144,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
143 |
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)))
|
144 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
145 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
146 |
-
|
147 |
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)))
|
148 |
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)))
|
149 |
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
@@ -152,22 +153,22 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
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)
|
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 |
$paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
|
164 |
}
|
165 |
-
|
166 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
167 |
{
|
168 |
-
$msg = $sbj = "(
|
169 |
-
$msg .= "\n\n";
|
170 |
-
|
171 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
172 |
$msg .= "initial: %%initial%%\n";
|
173 |
$msg .= "regular: %%regular%%\n";
|
@@ -180,7 +181,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
180 |
$msg .= "last_name: %%last_name%%\n";
|
181 |
$msg .= "full_name: %%full_name%%\n";
|
182 |
$msg .= "payer_email: %%payer_email%%\n";
|
183 |
-
|
184 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
185 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
186 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
@@ -188,11 +189,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
188 |
$msg .= "user_login: %%user_login%%\n";
|
189 |
$msg .= "user_ip: %%user_ip%%\n";
|
190 |
$msg .= "user_id: %%user_id%%\n";
|
191 |
-
|
192 |
if (is_array ($fields) && !empty ($fields))
|
193 |
foreach ($fields as $var => $val)
|
194 |
$msg .= $var . ": %%" . $var . "%%\n";
|
195 |
-
|
196 |
$msg .= "cv0: %%cv0%%\n";
|
197 |
$msg .= "cv1: %%cv1%%\n";
|
198 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -203,7 +204,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
203 |
$msg .= "cv7: %%cv7%%\n";
|
204 |
$msg .= "cv8: %%cv8%%\n";
|
205 |
$msg .= "cv9: %%cv9%%";
|
206 |
-
|
207 |
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)))
|
208 |
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)))
|
209 |
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)))
|
@@ -211,7 +212,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
211 |
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)))
|
212 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
213 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
214 |
-
|
215 |
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)))
|
216 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
217 |
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
@@ -220,19 +221,19 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
220 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
221 |
{
|
222 |
if (is_array ($fields) && !empty ($fields))
|
223 |
-
foreach ($fields as $var => $val)
|
224 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
225 |
break;
|
226 |
-
|
227 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
228 |
-
|
229 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"]) as $recipient)
|
230 |
-
wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "Content-Type: text/plain; charset=
|
231 |
}
|
232 |
-
|
233 |
$paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
|
234 |
}
|
235 |
-
|
236 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
237 |
{
|
238 |
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)))
|
@@ -251,11 +252,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
251 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
252 |
{
|
253 |
if (is_array ($fields) && !empty ($fields))
|
254 |
-
foreach ($fields as $var => $val)
|
255 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
256 |
break;
|
257 |
-
|
258 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))))
|
259 |
{
|
260 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
261 |
set_transient ("s2m_" . md5 ("s2member_transient_modification_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
@@ -263,10 +264,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
263 |
}
|
264 |
}
|
265 |
}
|
266 |
-
|
267 |
-
|
268 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
|
269 |
-
unset
|
270 |
}
|
271 |
else
|
272 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
@@ -274,17 +275,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
|
274 |
else
|
275 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
276 |
}
|
277 |
-
else
|
278 |
{
|
279 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
280 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ).";
|
281 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
282 |
}
|
283 |
-
|
284 |
-
|
285 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_modify", get_defined_vars ());
|
286 |
-
unset
|
287 |
-
|
288 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level", $paypal, get_defined_vars ());
|
289 |
}
|
290 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (!empty ($paypal["subscr_id"])) && (!empty ($paypal["payer_email"])))
|
48 |
{
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars ());
|
51 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
52 |
+
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ).";
|
56 |
+
|
57 |
list ($paypal["level"], $paypal["ccaps"]/*, $paypal["eotper"] */) = preg_split ("/\:/", $paypal["item_number"], 2);
|
58 |
+
|
59 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
+
|
62 |
+
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; // Defaults to "0 D" (zero days).
|
63 |
+
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; // "0.00".
|
64 |
+
|
65 |
+
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; // Defaults to "0 D" (zero days).
|
66 |
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
67 |
+
$paypal["regular"] = $paypal["mc_amount3"]; // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®.
|
68 |
+
$paypal["regular_term"] = $paypal["period3"]; // This is just set to keep a standard; this way both initial_term & regular_term are available.
|
69 |
+
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; // If non-recurring, this should be zero, otherwise Regular.
|
70 |
+
|
71 |
+
$ipn_signup_vars = $paypal; unset($ipn_signup_vars["s2member_log"]); // Create array of IPN signup vars w/o s2member_log.
|
72 |
+
|
73 |
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)
|
74 |
{
|
75 |
+
if (!$user->has_cap ("administrator")) // Do NOT process this routine on Administrators.
|
76 |
{
|
77 |
+
$processing = $modifying = $during = true; // Yes, we ARE processing this.
|
78 |
+
|
79 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
80 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars ());
|
81 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
|
82 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
83 |
+
|
84 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); // These will be needed in the routines below.
|
85 |
+
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); // Original IP during Registration.
|
86 |
+
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally.
|
87 |
+
|
88 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id)) // Must have a Role on this Blog.
|
89 |
{
|
90 |
add_existing_user_to_blog(array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
91 |
$user = new WP_User ($user_id);
|
92 |
}
|
93 |
+
|
94 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
95 |
+
|
96 |
+
if ($current_role !== "s2member_level" . $paypal["level"]) // Only if we need to.
|
97 |
+
$user->set_role ("s2member_level" . $paypal["level"]); // (upgrade/downgrade)
|
98 |
+
|
99 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
100 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
101 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
102 |
$user->remove_cap ($ccap = $cap);
|
103 |
+
|
104 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
105 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
106 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
107 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
108 |
+
|
109 |
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
110 |
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
111 |
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
112 |
+
|
113 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
114 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
115 |
+
|
116 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
117 |
+
|
118 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
119 |
+
|
120 |
delete_user_option ($user_id, "s2member_auto_eot_time");
|
121 |
+
|
122 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
123 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; // Preserves existing.
|
124 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
125 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); // Update now.
|
126 |
+
|
127 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
128 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Paid Subscr\. ID @ time of demotion\:/");
|
129 |
+
|
130 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
|
131 |
+
|
132 |
+
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
133 |
+
|
134 |
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
135 |
+
|
136 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
137 |
{
|
138 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
|
139 |
+
|
140 |
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)))
|
141 |
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)))
|
142 |
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)))
|
144 |
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)))
|
145 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
146 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
147 |
+
|
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)))
|
153 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
154 |
{
|
155 |
if (is_array ($fields) && !empty ($fields))
|
156 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
157 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
158 |
break;
|
159 |
+
|
160 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
161 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
162 |
}
|
163 |
+
|
164 |
$paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
|
165 |
}
|
166 |
+
|
167 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
168 |
{
|
169 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Modification";
|
170 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
171 |
+
|
172 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
173 |
$msg .= "initial: %%initial%%\n";
|
174 |
$msg .= "regular: %%regular%%\n";
|
181 |
$msg .= "last_name: %%last_name%%\n";
|
182 |
$msg .= "full_name: %%full_name%%\n";
|
183 |
$msg .= "payer_email: %%payer_email%%\n";
|
184 |
+
|
185 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
186 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
187 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
189 |
$msg .= "user_login: %%user_login%%\n";
|
190 |
$msg .= "user_ip: %%user_ip%%\n";
|
191 |
$msg .= "user_id: %%user_id%%\n";
|
192 |
+
|
193 |
if (is_array ($fields) && !empty ($fields))
|
194 |
foreach ($fields as $var => $val)
|
195 |
$msg .= $var . ": %%" . $var . "%%\n";
|
196 |
+
|
197 |
$msg .= "cv0: %%cv0%%\n";
|
198 |
$msg .= "cv1: %%cv1%%\n";
|
199 |
$msg .= "cv2: %%cv2%%\n";
|
204 |
$msg .= "cv7: %%cv7%%\n";
|
205 |
$msg .= "cv8: %%cv8%%\n";
|
206 |
$msg .= "cv9: %%cv9%%";
|
207 |
+
|
208 |
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)))
|
209 |
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)))
|
210 |
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)))
|
212 |
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)))
|
213 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
214 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
215 |
+
|
216 |
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)))
|
217 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
218 |
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
221 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
222 |
{
|
223 |
if (is_array ($fields) && !empty ($fields))
|
224 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
225 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
226 |
break;
|
227 |
+
|
228 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
229 |
+
|
230 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"]) as $recipient)
|
231 |
+
wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "Content-Type: text/plain; charset=UTF-8");
|
232 |
}
|
233 |
+
|
234 |
$paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
|
235 |
}
|
236 |
+
|
237 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
238 |
{
|
239 |
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)))
|
252 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
253 |
{
|
254 |
if (is_array ($fields) && !empty ($fields))
|
255 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
256 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
257 |
break;
|
258 |
+
|
259 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) // This gets stored into a Transient Queue.
|
260 |
{
|
261 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
262 |
set_transient ("s2m_" . md5 ("s2member_transient_modification_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
264 |
}
|
265 |
}
|
266 |
}
|
267 |
+
|
268 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
269 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
|
270 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
271 |
}
|
272 |
else
|
273 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
275 |
else
|
276 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
277 |
}
|
278 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
279 |
{
|
280 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
281 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ).";
|
282 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
283 |
}
|
284 |
+
|
285 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
286 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_modify", get_defined_vars ());
|
287 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
288 |
+
|
289 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level", $paypal, get_defined_vars ());
|
290 |
}
|
291 |
else
|
includes/classes/paypal-notify-in-subscr-or-rp-cancellation-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,71 +28,71 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract ($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& !(preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && !empty ($paypal["initial_payment_status"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))
|
47 |
-
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
48 |
-
&& (!empty ($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || ($paypal["period1"] = "0 D"))
|
49 |
-
&& (!empty ($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal)))
|
50 |
-
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
51 |
-
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
52 |
-
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))
|
53 |
{
|
54 |
-
|
55 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", get_defined_vars ());
|
56 |
-
unset
|
57 |
-
|
58 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
59 |
{
|
60 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_cancel|recurring_payment_profile_cancel` ).";
|
61 |
-
|
62 |
-
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"],
|
63 |
-
|
64 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
65 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
66 |
-
|
67 |
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)
|
68 |
{
|
69 |
-
if (!$user->has_cap ("administrator"))
|
70 |
{
|
71 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
72 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
73 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
74 |
-
|
75 |
-
if (!get_user_option ("s2member_auto_eot_time", $user_id))
|
76 |
{
|
77 |
-
$processing = $during = true;
|
78 |
-
|
79 |
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
|
80 |
-
|
81 |
-
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
82 |
-
|
83 |
$paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date ("D M j, Y g:i a T", $auto_eot_time);
|
84 |
-
|
85 |
-
|
86 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars ());
|
87 |
-
unset
|
88 |
}
|
89 |
else
|
90 |
$paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
|
91 |
-
|
92 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
93 |
{
|
94 |
-
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url)
|
95 |
-
|
96 |
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)))
|
97 |
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)))
|
98 |
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)))
|
@@ -103,22 +103,22 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
103 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
104 |
{
|
105 |
if (is_array ($fields) && !empty ($fields))
|
106 |
-
foreach ($fields as $var => $val)
|
107 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
108 |
break;
|
109 |
-
|
110 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
111 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
112 |
}
|
113 |
-
|
114 |
$paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
|
115 |
}
|
116 |
-
|
117 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
118 |
{
|
119 |
-
$msg = $sbj = "(
|
120 |
-
$msg .= "\n\n";
|
121 |
-
|
122 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
123 |
$msg .= "item_number: %%item_number%%\n";
|
124 |
$msg .= "item_name: %%item_name%%\n";
|
@@ -129,11 +129,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
129 |
$msg .= "user_login: %%user_login%%\n";
|
130 |
$msg .= "user_ip: %%user_ip%%\n";
|
131 |
$msg .= "user_id: %%user_id%%\n";
|
132 |
-
|
133 |
if (is_array ($fields) && !empty ($fields))
|
134 |
foreach ($fields as $var => $val)
|
135 |
$msg .= $var . ": %%" . $var . "%%\n";
|
136 |
-
|
137 |
$msg .= "cv0: %%cv0%%\n";
|
138 |
$msg .= "cv1: %%cv1%%\n";
|
139 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -144,7 +144,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
144 |
$msg .= "cv7: %%cv7%%\n";
|
145 |
$msg .= "cv8: %%cv8%%\n";
|
146 |
$msg .= "cv9: %%cv9%%";
|
147 |
-
|
148 |
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)))
|
149 |
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)))
|
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)))
|
@@ -155,16 +155,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
155 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
156 |
{
|
157 |
if (is_array ($fields) && !empty ($fields))
|
158 |
-
foreach ($fields as $var => $val)
|
159 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
160 |
break;
|
161 |
-
|
162 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
163 |
-
|
164 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"]) as $recipient)
|
165 |
-
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 ()), "Content-Type: text/plain; charset=
|
166 |
}
|
167 |
-
|
168 |
$paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
|
169 |
}
|
170 |
}
|
@@ -174,21 +174,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancella
|
|
174 |
else
|
175 |
$paypal["s2member_log"][] = "Unable to handle Cancellation. Could not get the existing User ID from the DB.";
|
176 |
}
|
177 |
-
else
|
178 |
{
|
179 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
180 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_cancel|recurring_payment_profile_cancel` ).";
|
181 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
182 |
}
|
183 |
-
|
184 |
-
|
185 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_cancel", get_defined_vars ());
|
186 |
-
unset
|
187 |
-
|
188 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level", $paypal, get_defined_vars ());
|
189 |
}
|
190 |
-
else
|
191 |
-
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level", false, get_defined_vars ());
|
192 |
}
|
193 |
}
|
194 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i", $paypal["txn_type"]))
|
46 |
+
&& !(preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && !empty ($paypal["initial_payment_status"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))
|
47 |
+
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
48 |
+
&& (!empty ($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || ($paypal["period1"] = "0 D"))
|
49 |
+
&& (!empty ($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal)))
|
50 |
+
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
51 |
+
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
52 |
+
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"]))))
|
53 |
{
|
54 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
55 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", get_defined_vars ());
|
56 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
57 |
+
|
58 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
59 |
{
|
60 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_cancel|recurring_payment_profile_cancel` ).";
|
61 |
+
|
62 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
63 |
+
|
64 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
65 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
66 |
+
|
67 |
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)
|
68 |
{
|
69 |
+
if (!$user->has_cap ("administrator")) // Do NOT process this routine on Administrators.
|
70 |
{
|
71 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); // These will be needed in the routines below.
|
72 |
+
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); // Original IP during Registration.
|
73 |
+
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally.
|
74 |
+
|
75 |
+
if (!get_user_option ("s2member_auto_eot_time", $user_id)) // Respect existing.
|
76 |
{
|
77 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
78 |
+
|
79 |
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
|
80 |
+
|
81 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); // s2Member follows-up later.
|
82 |
+
|
83 |
$paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date ("D M j, Y g:i a T", $auto_eot_time);
|
84 |
+
|
85 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
86 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars ());
|
87 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
88 |
}
|
89 |
else
|
90 |
$paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
|
91 |
+
|
92 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
93 |
{
|
94 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) // Handle Cancellation Notifications.
|
95 |
+
|
96 |
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)))
|
97 |
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)))
|
98 |
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)))
|
103 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
104 |
{
|
105 |
if (is_array ($fields) && !empty ($fields))
|
106 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
107 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
108 |
break;
|
109 |
+
|
110 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
111 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
112 |
}
|
113 |
+
|
114 |
$paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
|
115 |
}
|
116 |
+
|
117 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
118 |
{
|
119 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Cancellation";
|
120 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
121 |
+
|
122 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
123 |
$msg .= "item_number: %%item_number%%\n";
|
124 |
$msg .= "item_name: %%item_name%%\n";
|
129 |
$msg .= "user_login: %%user_login%%\n";
|
130 |
$msg .= "user_ip: %%user_ip%%\n";
|
131 |
$msg .= "user_id: %%user_id%%\n";
|
132 |
+
|
133 |
if (is_array ($fields) && !empty ($fields))
|
134 |
foreach ($fields as $var => $val)
|
135 |
$msg .= $var . ": %%" . $var . "%%\n";
|
136 |
+
|
137 |
$msg .= "cv0: %%cv0%%\n";
|
138 |
$msg .= "cv1: %%cv1%%\n";
|
139 |
$msg .= "cv2: %%cv2%%\n";
|
144 |
$msg .= "cv7: %%cv7%%\n";
|
145 |
$msg .= "cv8: %%cv8%%\n";
|
146 |
$msg .= "cv9: %%cv9%%";
|
147 |
+
|
148 |
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)))
|
149 |
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)))
|
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)))
|
155 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
156 |
{
|
157 |
if (is_array ($fields) && !empty ($fields))
|
158 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
159 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
160 |
break;
|
161 |
+
|
162 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
163 |
+
|
164 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"]) as $recipient)
|
165 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
166 |
}
|
167 |
+
|
168 |
$paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
|
169 |
}
|
170 |
}
|
174 |
else
|
175 |
$paypal["s2member_log"][] = "Unable to handle Cancellation. Could not get the existing User ID from the DB.";
|
176 |
}
|
177 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
178 |
{
|
179 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
180 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_cancel|recurring_payment_profile_cancel` ).";
|
181 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
182 |
}
|
183 |
+
|
184 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
185 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_cancel", get_defined_vars ());
|
186 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
187 |
+
|
188 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level", $paypal, get_defined_vars ());
|
189 |
}
|
190 |
+
else return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level", false, get_defined_vars ());
|
|
|
191 |
}
|
192 |
}
|
193 |
}
|
includes/classes/paypal-notify-in-subscr-or-rp-eots-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,118 +28,119 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp($vars = array())
|
42 |
{
|
43 |
-
extract($vars);
|
44 |
-
|
45 |
-
if(
|
46 |
-
|| (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && !empty($paypal["initial_payment_status"]) && preg_match("/^failed$/i", $paypal["initial_payment_status"]) && ($recurring = true))
|
47 |
-
|| (!empty($paypal["txn_type"]) && preg_match("/^new_case$/i", $paypal["txn_type"]) && !empty($paypal["case_type"]) && preg_match("/^chargeback$/i", $paypal["case_type"]) && !($recurring = false))
|
48 |
-
|| (!empty($paypal["payment_status"]) && preg_match("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"]) && !($recurring = false))
|
49 |
-
&& (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal)) || (!empty($paypal["parent_txn_id"]) && ($paypal["subscr_id"] = $paypal["parent_txn_id"])))
|
50 |
-
&& (!empty($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal, false)) || empty($recurring) || ($paypal["period1"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period1", false, $paypal["subscr_id"])) || ($paypal["period1"] = "0 D"))
|
51 |
-
&& (!empty($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal, false)) || empty($recurring) || ($paypal["period3"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period3", false, $paypal["subscr_id"])) || ($paypal["period3"] = "1 D"))
|
52 |
-
&& ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal)) || ($paypal["item_number"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_number", false, $paypal["subscr_id"])) || ($paypal["item_number"] = "1")) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
53 |
-
&& (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal["item_name"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_name", false, $paypal["subscr_id"])) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))
|
54 |
-
&& (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("payer_email", false, $paypal["subscr_id"])) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))
|
55 |
{
|
56 |
-
|
57 |
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars());
|
58 |
-
unset
|
59 |
-
|
60 |
if(!get_transient($transient_ipn = "s2m_ipn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10))
|
61 |
{
|
62 |
$is_refund = (preg_match("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
63 |
$is_reversal = (preg_match("/^(reversed|reversal)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
64 |
$is_reversal = (!$is_reversal) ? (preg_match("/^new_case$/i", $paypal["txn_type"]) && preg_match("/^chargeback$/i", $paypal["case_type"])) : $is_reversal;
|
65 |
-
$is_refund_or_reversal = ($is_refund || $is_reversal);
|
66 |
$is_delayed_eot = (!$is_refund_or_reversal && preg_match("/^(subscr_eot|recurring_payment_expired)$/i", $paypal["txn_type"]) && preg_match("/^I-/i", $paypal["subscr_id"]));
|
67 |
-
|
68 |
if($is_refund_or_reversal)
|
69 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ".($identified_as = "( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` )").".";
|
70 |
else
|
71 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ".($identified_as = "( `subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment` ) - or - `recurring_payment_profile_cancel` w/ `initial_payment_status` ( `failed` )").".";
|
72 |
-
|
73 |
$paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
|
74 |
-
sleep(5);
|
75 |
-
|
76 |
$paypal["s2member_log"][] = "Awake. It's ".date("D M j, Y g:i:s a T").". s2Member `txn_type` identified as ".$identified_as.".";
|
77 |
-
|
78 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
79 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
80 |
-
|
81 |
if(($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && !empty($user->ID))
|
82 |
{
|
83 |
-
$fields = get_user_option("s2member_custom_fields", $user_id);
|
84 |
-
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
|
85 |
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
86 |
-
|
87 |
-
if(
|
88 |
-
(!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option("s2member_auto_eot_time", $user_id))
|
89 |
-
|| ($is_refund_or_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals")
|
90 |
-
|| ($is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals")
|
91 |
-
|| ($is_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds")
|
92 |
{
|
93 |
-
if(!$user->has_cap("administrator"))
|
94 |
{
|
95 |
-
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
96 |
{
|
97 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
98 |
{
|
99 |
-
$processing = $during = true;
|
100 |
-
|
101 |
-
$eot_del_type = ($is_refund_or_reversal) ?
|
102 |
"ipn-refund-reversal-demotion" : "ipn-cancellation-expiration-demotion";
|
103 |
-
|
104 |
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");
|
105 |
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
106 |
-
|
107 |
-
|
108 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars());
|
109 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), $eot_del_type, "modification", $demotion_role);
|
110 |
do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "modification");
|
111 |
-
unset
|
112 |
-
|
113 |
-
if($existing_role !== $demotion_role)
|
114 |
-
$user->set_role($demotion_role);
|
115 |
-
|
116 |
foreach($user->allcaps as $cap => $cap_enabled)
|
117 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
118 |
$user->remove_cap($ccap = $cap);
|
119 |
-
|
120 |
delete_user_option($user_id, "s2member_custom");
|
121 |
delete_user_option($user_id, "s2member_subscr_id");
|
122 |
delete_user_option($user_id, "s2member_subscr_gateway");
|
123 |
-
|
124 |
delete_user_option($user_id, "s2member_ipn_signup_vars");
|
125 |
if(!apply_filters("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars()))
|
126 |
delete_user_option($user_id, "s2member_paid_registration_times");
|
127 |
-
|
128 |
delete_user_option($user_id, "s2member_last_status_scan");
|
129 |
delete_user_option($user_id, "s2member_first_payment_txn_id");
|
130 |
delete_user_option($user_id, "s2member_last_payment_time");
|
131 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
132 |
-
|
133 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
134 |
-
|
135 |
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Demoted by s2Member: ".date("D M j, Y g:i a T"));
|
136 |
-
|
|
|
137 |
$paypal["s2member_log"][] = "Member Level/Capabilities demoted to: ".ucwords(preg_replace("/_/", " ", $demotion_role)).".";
|
138 |
-
|
139 |
if($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
140 |
{
|
141 |
-
foreach(preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url)
|
142 |
-
|
143 |
if(($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($eot_del_type)), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["subscr_id"])), $url)))
|
144 |
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)))
|
145 |
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)))
|
@@ -149,22 +150,22 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
149 |
if(($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)))
|
150 |
{
|
151 |
if(is_array($fields) && !empty($fields))
|
152 |
-
foreach($fields as $var => $val)
|
153 |
if(!($url = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url)))
|
154 |
break;
|
155 |
-
|
156 |
if(($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))))
|
157 |
c_ws_plugin__s2member_utils_urls::remote($url);
|
158 |
}
|
159 |
-
|
160 |
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
161 |
}
|
162 |
-
|
163 |
if($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
164 |
{
|
165 |
-
$msg = $sbj = "(
|
166 |
-
$msg .= "\n\n";
|
167 |
-
|
168 |
$msg .= "eot_del_type: %%eot_del_type%%\n";
|
169 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
170 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
@@ -174,11 +175,11 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
174 |
$msg .= "user_login: %%user_login%%\n";
|
175 |
$msg .= "user_ip: %%user_ip%%\n";
|
176 |
$msg .= "user_id: %%user_id%%\n";
|
177 |
-
|
178 |
if(is_array($fields) && !empty($fields))
|
179 |
foreach($fields as $var => $val)
|
180 |
$msg .= $var.": %%".$var."%%\n";
|
181 |
-
|
182 |
$msg .= "cv0: %%cv0%%\n";
|
183 |
$msg .= "cv1: %%cv1%%\n";
|
184 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -189,7 +190,7 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
189 |
$msg .= "cv7: %%cv7%%\n";
|
190 |
$msg .= "cv8: %%cv8%%\n";
|
191 |
$msg .= "cv9: %%cv9%%";
|
192 |
-
|
193 |
if(($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($eot_del_type), $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $msg)))
|
194 |
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)))
|
195 |
if(($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name." ".$user->last_name)), $msg)))
|
@@ -199,142 +200,142 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
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)
|
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($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg))))
|
207 |
-
|
208 |
foreach(c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient)
|
209 |
-
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()), "Content-Type: text/plain; charset=
|
210 |
}
|
211 |
-
|
212 |
$paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
|
213 |
}
|
214 |
-
|
215 |
-
|
216 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_demote", get_defined_vars());
|
217 |
-
unset
|
218 |
}
|
219 |
-
|
220 |
else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
221 |
{
|
222 |
-
$processing = $during = true;
|
223 |
-
|
224 |
-
$eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] =
|
225 |
($is_refund_or_reversal) ? "ipn-refund-reversal-deletion" : "ipn-cancellation-expiration-deletion";
|
226 |
-
|
227 |
-
|
228 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_delete", get_defined_vars());
|
229 |
do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "removal-deletion");
|
230 |
-
unset
|
231 |
-
|
232 |
-
if(is_multisite())
|
233 |
{
|
234 |
remove_user_from_blog($user_id, $current_blog->blog_id);
|
235 |
-
|
236 |
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions($user_id, $current_blog->blog_id, "s2says");
|
237 |
}
|
238 |
-
|
239 |
-
else
|
240 |
-
|
241 |
-
wp_delete_user($user_id);
|
242 |
-
|
243 |
$paypal["s2member_log"][] = "This Member's account has been ".((is_multisite()) ? "removed" : "deleted").".";
|
244 |
-
|
245 |
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
246 |
-
|
247 |
-
|
248 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delete", get_defined_vars());
|
249 |
-
unset
|
250 |
}
|
251 |
-
|
252 |
-
|
253 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot", get_defined_vars());
|
254 |
-
unset
|
255 |
}
|
256 |
-
|
257 |
-
else
|
258 |
{
|
259 |
-
$processing = $during = true;
|
260 |
-
|
261 |
update_user_option($user_id, "s2member_auto_eot_time", ($auto_eot_time = strtotime("now")));
|
262 |
-
|
263 |
-
$paypal["s2member_log"][] = "Auto-EOT is currently disabled. Skipping immediate EOT (
|
264 |
$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);
|
265 |
-
|
266 |
-
|
267 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_disabled", get_defined_vars());
|
268 |
-
unset
|
269 |
}
|
270 |
}
|
271 |
else
|
272 |
-
$paypal["s2member_log"][] = "Unable to (
|
273 |
}
|
274 |
-
|
275 |
else if($is_delayed_eot && !get_user_option("s2member_auto_eot_time", $user_id))
|
276 |
{
|
277 |
-
if(!$user->has_cap("administrator"))
|
278 |
{
|
279 |
-
$processing = $during = true;
|
280 |
-
|
281 |
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time($user_id, $paypal["period1"], $paypal["period3"], "", time());
|
282 |
/* We assume the last payment was today, because this is how newer PayPal® accounts function with respect to EOT handling.
|
283 |
Newer PayPal® accounts ( i.e. Subscription IDs starting with `I-`, will have their EOT triggered upon the last payment. */
|
284 |
-
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
285 |
-
|
286 |
-
$paypal["s2member_log"][] = "Auto-EOT Time for this account (
|
287 |
-
|
288 |
-
|
289 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delayed", get_defined_vars());
|
290 |
-
unset
|
291 |
}
|
292 |
else
|
293 |
$paypal["s2member_log"][] = "Ignoring Delayed EOT. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
294 |
}
|
295 |
-
|
296 |
else if(!$is_refund_or_reversal || $is_delayed_eot)
|
297 |
-
$paypal["s2member_log"][] = "Skipping (
|
298 |
-
|
299 |
else if($is_reversal)
|
300 |
-
$paypal["s2member_log"][] = "Skipping (
|
301 |
-
|
302 |
else if($is_refund)
|
303 |
-
$paypal["s2member_log"][] = "Skipping (
|
304 |
}
|
305 |
-
else if($is_delayed_eot)
|
306 |
{
|
307 |
$paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
|
308 |
-
|
309 |
-
$ipn = array("txn_type" => "subscr_eot");
|
310 |
-
|
311 |
foreach($paypal as $var => $val)
|
312 |
if(in_array($var, array("subscr_gateway", "subscr_id", "custom", "invoice", "payer_email", "first_name", "last_name", "item_name", "item_number", /* Exclude; might be defaults. "period1", "period3", */ "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
313 |
$ipn[$var] = $val;
|
314 |
-
|
315 |
$paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
|
316 |
-
|
317 |
set_transient("s2m_".md5("s2member_transient_ipn_subscr_eot_".$paypal["subscr_id"]), $ipn, 43200);
|
318 |
}
|
319 |
-
|
320 |
else
|
321 |
-
$paypal["s2member_log"][] = "Unable to (
|
322 |
/*
|
323 |
Refunds and chargeback reversals. This is excluded from the processing check, because a Member *could* have already been (demoted|deleted).
|
324 |
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
325 |
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
|
326 |
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
|
327 |
*/
|
328 |
-
if($is_refund_or_reversal)
|
329 |
{
|
330 |
-
$fields = ($user_id) ? get_user_option("s2member_custom_fields", $user_id) : array();
|
331 |
-
$user_reg_ip = ($user_id) ? get_user_option("s2member_registration_ip", $user_id) : "";
|
332 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
333 |
-
|
334 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
335 |
{
|
336 |
foreach(preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
|
337 |
-
|
338 |
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)))
|
339 |
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)))
|
340 |
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)))
|
@@ -345,22 +346,22 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
345 |
if(($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)))
|
346 |
{
|
347 |
if(is_array($fields) && !empty($fields))
|
348 |
-
foreach($fields as $var => $val)
|
349 |
if(!($url = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url)))
|
350 |
break;
|
351 |
-
|
352 |
if(($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))))
|
353 |
c_ws_plugin__s2member_utils_urls::remote($url);
|
354 |
}
|
355 |
-
|
356 |
$paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
|
357 |
}
|
358 |
-
|
359 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
360 |
{
|
361 |
-
$msg = $sbj = "(
|
362 |
-
$msg .= "\n\n";
|
363 |
-
|
364 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
365 |
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
366 |
$msg .= "item_number: %%item_number%%\n";
|
@@ -373,11 +374,11 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
373 |
$msg .= "payer_email: %%payer_email%%\n";
|
374 |
$msg .= "user_ip: %%user_ip%%\n";
|
375 |
$msg .= "user_id: %%user_id%%\n";
|
376 |
-
|
377 |
if(is_array($fields) && !empty($fields))
|
378 |
foreach($fields as $var => $val)
|
379 |
$msg .= $var.": %%".$var."%%\n";
|
380 |
-
|
381 |
$msg .= "cv0: %%cv0%%\n";
|
382 |
$msg .= "cv1: %%cv1%%\n";
|
383 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -388,7 +389,7 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
388 |
$msg .= "cv7: %%cv7%%\n";
|
389 |
$msg .= "cv8: %%cv8%%\n";
|
390 |
$msg .= "cv9: %%cv9%%";
|
391 |
-
|
392 |
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)))
|
393 |
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)))
|
394 |
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)))
|
@@ -399,39 +400,38 @@ if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_lev
|
|
399 |
if(($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)))
|
400 |
{
|
401 |
if(is_array($fields) && !empty($fields))
|
402 |
-
foreach($fields as $var => $val)
|
403 |
if(!($msg = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg)))
|
404 |
break;
|
405 |
-
|
406 |
-
if($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg))))
|
407 |
-
|
408 |
foreach(c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"]) as $recipient)
|
409 |
-
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()), "Content-Type: text/plain; charset=
|
410 |
}
|
411 |
-
|
412 |
$paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
|
413 |
}
|
414 |
-
|
415 |
-
|
416 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_refund_reversal", get_defined_vars());
|
417 |
-
unset
|
418 |
}
|
419 |
}
|
420 |
-
else
|
421 |
{
|
422 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
423 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as a type of EOT.";
|
424 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
425 |
}
|
426 |
-
|
427 |
-
|
428 |
do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_eot", get_defined_vars());
|
429 |
-
unset
|
430 |
-
|
431 |
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level", $paypal, get_defined_vars());
|
432 |
}
|
433 |
-
else
|
434 |
-
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level", false, get_defined_vars());
|
435 |
}
|
436 |
}
|
437 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp($vars = array()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if(((!empty($paypal["txn_type"]) && preg_match("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i", $paypal["txn_type"]) && ($recurring = true))
|
46 |
+
|| (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && !empty($paypal["initial_payment_status"]) && preg_match("/^failed$/i", $paypal["initial_payment_status"]) && ($recurring = true))
|
47 |
+
|| (!empty($paypal["txn_type"]) && preg_match("/^new_case$/i", $paypal["txn_type"]) && !empty($paypal["case_type"]) && preg_match("/^chargeback$/i", $paypal["case_type"]) && !($recurring = false)) // Seeking this for future compatibility.
|
48 |
+
|| (!empty($paypal["payment_status"]) && preg_match("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"]) && !($recurring = false))) // The `txn_type` is irrelevant in all of these payment statuses: `refunded|reversed|reversal`.
|
49 |
+
&& (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal)) || (!empty($paypal["parent_txn_id"]) && ($paypal["subscr_id"] = $paypal["parent_txn_id"]))) // Other MUST haves.
|
50 |
+
&& (!empty($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal, false)) || empty($recurring) || ($paypal["period1"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period1", false, $paypal["subscr_id"])) || ($paypal["period1"] = "0 D"))
|
51 |
+
&& (!empty($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal, false)) || empty($recurring) || ($paypal["period3"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period3", false, $paypal["subscr_id"])) || ($paypal["period3"] = "1 D"))
|
52 |
+
&& ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal)) || ($paypal["item_number"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_number", false, $paypal["subscr_id"])) || ($paypal["item_number"] = "1")) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
53 |
+
&& (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal["item_name"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_name", false, $paypal["subscr_id"])) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))
|
54 |
+
&& (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("payer_email", false, $paypal["subscr_id"])) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))))
|
55 |
{
|
56 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
57 |
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars());
|
58 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
59 |
+
|
60 |
if(!get_transient($transient_ipn = "s2m_ipn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10))
|
61 |
{
|
62 |
$is_refund = (preg_match("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
63 |
$is_reversal = (preg_match("/^(reversed|reversal)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
|
64 |
$is_reversal = (!$is_reversal) ? (preg_match("/^new_case$/i", $paypal["txn_type"]) && preg_match("/^chargeback$/i", $paypal["case_type"])) : $is_reversal;
|
65 |
+
$is_refund_or_reversal = ($is_refund || $is_reversal); // If either of the previous tests above evaluated to true; then it's obviously a Refund and/or a Reversal.
|
66 |
$is_delayed_eot = (!$is_refund_or_reversal && preg_match("/^(subscr_eot|recurring_payment_expired)$/i", $paypal["txn_type"]) && preg_match("/^I-/i", $paypal["subscr_id"]));
|
67 |
+
|
68 |
if($is_refund_or_reversal)
|
69 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ".($identified_as = "( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` )").".";
|
70 |
else
|
71 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ".($identified_as = "( `subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment` ) - or - `recurring_payment_profile_cancel` w/ `initial_payment_status` ( `failed` )").".";
|
72 |
+
|
73 |
$paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
|
74 |
+
sleep(5); // Sleep here for a moment. PayPal® sometimes sends a subscr_eot before the subscr_signup, subscr_modify.
|
75 |
+
// 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.
|
76 |
$paypal["s2member_log"][] = "Awake. It's ".date("D M j, Y g:i:s a T").". s2Member `txn_type` identified as ".$identified_as.".";
|
77 |
+
|
78 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
79 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
80 |
+
|
81 |
if(($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && !empty($user->ID))
|
82 |
{
|
83 |
+
$fields = get_user_option("s2member_custom_fields", $user_id); // These will be needed below.
|
84 |
+
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id); // Needed below.
|
85 |
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
86 |
+
|
87 |
+
if( // Here we take action, BUT based on Auto EOT Behavior options; as configured by the Site Owner.
|
88 |
+
(!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option("s2member_auto_eot_time", $user_id))
|
89 |
+
|| ($is_refund_or_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals")
|
90 |
+
|| ($is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals")
|
91 |
+
|| ($is_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds"))
|
92 |
{
|
93 |
+
if(!$user->has_cap("administrator")) // Do NOT process this routine on Administrators.
|
94 |
{
|
95 |
+
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) // EOT enabled?
|
96 |
{
|
97 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
98 |
{
|
99 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
100 |
+
|
101 |
+
$eot_del_type = ($is_refund_or_reversal) ? // Set EOT/Del type.
|
102 |
"ipn-refund-reversal-demotion" : "ipn-cancellation-expiration-demotion";
|
103 |
+
|
104 |
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");
|
105 |
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
106 |
+
|
107 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
108 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars());
|
109 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), $eot_del_type, "modification", $demotion_role);
|
110 |
do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "modification");
|
111 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
112 |
+
|
113 |
+
if($existing_role !== $demotion_role) // Only if NOT the existing Role.
|
114 |
+
$user->set_role($demotion_role); // Give User the demotion Role.
|
115 |
+
|
116 |
foreach($user->allcaps as $cap => $cap_enabled)
|
117 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
118 |
$user->remove_cap($ccap = $cap);
|
119 |
+
|
120 |
delete_user_option($user_id, "s2member_custom");
|
121 |
delete_user_option($user_id, "s2member_subscr_id");
|
122 |
delete_user_option($user_id, "s2member_subscr_gateway");
|
123 |
+
|
124 |
delete_user_option($user_id, "s2member_ipn_signup_vars");
|
125 |
if(!apply_filters("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars()))
|
126 |
delete_user_option($user_id, "s2member_paid_registration_times");
|
127 |
+
|
128 |
delete_user_option($user_id, "s2member_last_status_scan");
|
129 |
delete_user_option($user_id, "s2member_first_payment_txn_id");
|
130 |
delete_user_option($user_id, "s2member_last_payment_time");
|
131 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
132 |
+
|
133 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
134 |
+
|
135 |
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Demoted by s2Member: ".date("D M j, Y g:i a T"));
|
136 |
+
c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "Paid Subscr. ID @ time of demotion: ".$paypal["subscr_gateway"]." -› ".$paypal["subscr_id"]);
|
137 |
+
|
138 |
$paypal["s2member_log"][] = "Member Level/Capabilities demoted to: ".ucwords(preg_replace("/_/", " ", $demotion_role)).".";
|
139 |
+
|
140 |
if($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
141 |
{
|
142 |
+
foreach(preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) // Handle EOT Notifications.
|
143 |
+
|
144 |
if(($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($eot_del_type)), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["subscr_id"])), $url)))
|
145 |
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)))
|
146 |
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_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)))
|
151 |
{
|
152 |
if(is_array($fields) && !empty($fields))
|
153 |
+
foreach($fields as $var => $val) // Custom Registration/Profile Fields.
|
154 |
if(!($url = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url)))
|
155 |
break;
|
156 |
+
|
157 |
if(($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))))
|
158 |
c_ws_plugin__s2member_utils_urls::remote($url);
|
159 |
}
|
160 |
+
|
161 |
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
162 |
}
|
163 |
+
|
164 |
if($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
165 |
{
|
166 |
+
$msg = $sbj = "(s2Member / API Notification Email) - EOT/Deletion";
|
167 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
168 |
+
|
169 |
$msg .= "eot_del_type: %%eot_del_type%%\n";
|
170 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
171 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
175 |
$msg .= "user_login: %%user_login%%\n";
|
176 |
$msg .= "user_ip: %%user_ip%%\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";
|
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("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($eot_del_type), $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["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)))
|
200 |
if(($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)))
|
201 |
{
|
202 |
if(is_array($fields) && !empty($fields))
|
203 |
+
foreach($fields as $var => $val) // Custom Registration/Profile Fields.
|
204 |
if(!($msg = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg)))
|
205 |
break;
|
206 |
+
|
207 |
+
if($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
208 |
+
|
209 |
foreach(c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient)
|
210 |
+
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()), "Content-Type: text/plain; charset=UTF-8");
|
211 |
}
|
212 |
+
|
213 |
$paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
|
214 |
}
|
215 |
+
|
216 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
217 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_demote", get_defined_vars());
|
218 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
219 |
}
|
220 |
+
|
221 |
else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
222 |
{
|
223 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
224 |
+
|
225 |
+
$eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = // Configure EOT/Del type.
|
226 |
($is_refund_or_reversal) ? "ipn-refund-reversal-deletion" : "ipn-cancellation-expiration-deletion";
|
227 |
+
|
228 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
229 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_delete", get_defined_vars());
|
230 |
do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "removal-deletion");
|
231 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
232 |
+
|
233 |
+
if(is_multisite()) // Multisite does NOT actually delete; ONLY removes.
|
234 |
{
|
235 |
remove_user_from_blog($user_id, $current_blog->blog_id);
|
236 |
+
// This will automatically trigger `eot_del_notification_urls` as well.
|
237 |
c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions($user_id, $current_blog->blog_id, "s2says");
|
238 |
}
|
239 |
+
|
240 |
+
else // Otherwise, we can actually delete them.
|
241 |
+
// This will automatically trigger `eot_del_notification_urls` as well.
|
242 |
+
wp_delete_user($user_id); // `c_ws_plugin__s2member_user_deletions::handle_user_deletions()`
|
243 |
+
|
244 |
$paypal["s2member_log"][] = "This Member's account has been ".((is_multisite()) ? "removed" : "deleted").".";
|
245 |
+
|
246 |
$paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
|
247 |
+
|
248 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
249 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delete", get_defined_vars());
|
250 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
251 |
}
|
252 |
+
|
253 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
254 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot", get_defined_vars());
|
255 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
256 |
}
|
257 |
+
|
258 |
+
else // Otherwise, treat this as if it were a cancellation. EOTs are currently disabled.
|
259 |
{
|
260 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
261 |
+
|
262 |
update_user_option($user_id, "s2member_auto_eot_time", ($auto_eot_time = strtotime("now")));
|
263 |
+
|
264 |
+
$paypal["s2member_log"][] = "Auto-EOT is currently disabled. Skipping immediate EOT (demote|delete), for now.";
|
265 |
$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);
|
266 |
+
|
267 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
268 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_disabled", get_defined_vars());
|
269 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
270 |
}
|
271 |
}
|
272 |
else
|
273 |
+
$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.";
|
274 |
}
|
275 |
+
|
276 |
else if($is_delayed_eot && !get_user_option("s2member_auto_eot_time", $user_id))
|
277 |
{
|
278 |
+
if(!$user->has_cap("administrator")) // Do NOT process this routine on Administrators.
|
279 |
{
|
280 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
281 |
+
|
282 |
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time($user_id, $paypal["period1"], $paypal["period3"], "", time());
|
283 |
/* We assume the last payment was today, because this is how newer PayPal® accounts function with respect to EOT handling.
|
284 |
Newer PayPal® accounts ( i.e. Subscription IDs starting with `I-`, will have their EOT triggered upon the last payment. */
|
285 |
+
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); // s2Member will follow-up on this later.
|
286 |
+
|
287 |
+
$paypal["s2member_log"][] = "Auto-EOT Time for this account (delayed), set to: ".date("D M j, Y g:i a T", $auto_eot_time);
|
288 |
+
|
289 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
290 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delayed", get_defined_vars());
|
291 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
292 |
}
|
293 |
else
|
294 |
$paypal["s2member_log"][] = "Ignoring Delayed EOT. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
295 |
}
|
296 |
+
|
297 |
else if(!$is_refund_or_reversal || $is_delayed_eot)
|
298 |
+
$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.";
|
299 |
+
|
300 |
else if($is_reversal)
|
301 |
+
$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.";
|
302 |
+
|
303 |
else if($is_refund)
|
304 |
+
$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.";
|
305 |
}
|
306 |
+
else if($is_delayed_eot) // Otherwise, we need to re-generate/store this IPN into a Transient Queue. Then re-process it on registration.
|
307 |
{
|
308 |
$paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
|
309 |
+
|
310 |
+
$ipn = array("txn_type" => "subscr_eot"); // Create a simulated IPN response for txn_type=subscr_eot.
|
311 |
+
|
312 |
foreach($paypal as $var => $val)
|
313 |
if(in_array($var, array("subscr_gateway", "subscr_id", "custom", "invoice", "payer_email", "first_name", "last_name", "item_name", "item_number", /* Exclude; might be defaults. "period1", "period3", */ "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
314 |
$ipn[$var] = $val;
|
315 |
+
|
316 |
$paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
|
317 |
+
|
318 |
set_transient("s2m_".md5("s2member_transient_ipn_subscr_eot_".$paypal["subscr_id"]), $ipn, 43200);
|
319 |
}
|
320 |
+
|
321 |
else
|
322 |
+
$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.";
|
323 |
/*
|
324 |
Refunds and chargeback reversals. This is excluded from the processing check, because a Member *could* have already been (demoted|deleted).
|
325 |
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
|
326 |
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
|
327 |
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
|
328 |
*/
|
329 |
+
if($is_refund_or_reversal) // Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection.
|
330 |
{
|
331 |
+
$fields = ($user_id) ? get_user_option("s2member_custom_fields", $user_id) : array(); // These will be needed below.
|
332 |
+
$user_reg_ip = ($user_id) ? get_user_option("s2member_registration_ip", $user_id) : ""; // Needed below.
|
333 |
+
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally.
|
334 |
+
|
335 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
336 |
{
|
337 |
foreach(preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
|
338 |
+
|
339 |
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)))
|
340 |
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)))
|
341 |
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)))
|
346 |
if(($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)))
|
347 |
{
|
348 |
if(is_array($fields) && !empty($fields))
|
349 |
+
foreach($fields as $var => $val) // Custom Registration/Profile Fields.
|
350 |
if(!($url = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url)))
|
351 |
break;
|
352 |
+
|
353 |
if(($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))))
|
354 |
c_ws_plugin__s2member_utils_urls::remote($url);
|
355 |
}
|
356 |
+
|
357 |
$paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
|
358 |
}
|
359 |
+
|
360 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"] && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
361 |
{
|
362 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Refund/Reversal";
|
363 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
364 |
+
|
365 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
366 |
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
|
367 |
$msg .= "item_number: %%item_number%%\n";
|
374 |
$msg .= "payer_email: %%payer_email%%\n";
|
375 |
$msg .= "user_ip: %%user_ip%%\n";
|
376 |
$msg .= "user_id: %%user_id%%\n";
|
377 |
+
|
378 |
if(is_array($fields) && !empty($fields))
|
379 |
foreach($fields as $var => $val)
|
380 |
$msg .= $var.": %%".$var."%%\n";
|
381 |
+
|
382 |
$msg .= "cv0: %%cv0%%\n";
|
383 |
$msg .= "cv1: %%cv1%%\n";
|
384 |
$msg .= "cv2: %%cv2%%\n";
|
389 |
$msg .= "cv7: %%cv7%%\n";
|
390 |
$msg .= "cv8: %%cv8%%\n";
|
391 |
$msg .= "cv9: %%cv9%%";
|
392 |
+
|
393 |
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)))
|
394 |
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)))
|
395 |
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)))
|
400 |
if(($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)))
|
401 |
{
|
402 |
if(is_array($fields) && !empty($fields))
|
403 |
+
foreach($fields as $var => $val) // Custom Registration/Profile Fields.
|
404 |
if(!($msg = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg)))
|
405 |
break;
|
406 |
+
|
407 |
+
if($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
408 |
+
|
409 |
foreach(c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"]) as $recipient)
|
410 |
+
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()), "Content-Type: text/plain; charset=UTF-8");
|
411 |
}
|
412 |
+
|
413 |
$paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
|
414 |
}
|
415 |
+
|
416 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
417 |
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_refund_reversal", get_defined_vars());
|
418 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
419 |
}
|
420 |
}
|
421 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
422 |
{
|
423 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
424 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as a type of EOT.";
|
425 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
426 |
}
|
427 |
+
|
428 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
429 |
do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_eot", get_defined_vars());
|
430 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
431 |
+
|
432 |
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level", $paypal, get_defined_vars());
|
433 |
}
|
434 |
+
else return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level", false, get_defined_vars());
|
|
|
435 |
}
|
436 |
}
|
437 |
}
|
includes/classes/paypal-notify-in-subscr-or-rp-payment-failed-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,53 +28,53 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
45 |
-
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
46 |
-
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
47 |
-
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))
|
48 |
{
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
|
56 |
-
|
57 |
-
$processing = $during = true;
|
58 |
-
|
59 |
$paypal["s2member_log"][] = "This `txn_type` does not require any action on the part of s2Member.";
|
60 |
$paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
|
61 |
$paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
|
62 |
-
|
63 |
-
|
64 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars ());
|
65 |
-
unset
|
66 |
}
|
67 |
-
else
|
68 |
{
|
69 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
70 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
|
71 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
72 |
}
|
73 |
-
|
74 |
-
|
75 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars ());
|
76 |
-
unset
|
77 |
-
|
78 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", $paypal, get_defined_vars ());
|
79 |
}
|
80 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i", $paypal["txn_type"]))
|
44 |
+
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
45 |
+
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
46 |
+
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
47 |
+
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"]))))
|
48 |
{
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars ());
|
51 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
52 |
+
|
53 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
|
56 |
+
|
57 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
58 |
+
|
59 |
$paypal["s2member_log"][] = "This `txn_type` does not require any action on the part of s2Member.";
|
60 |
$paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
|
61 |
$paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
|
62 |
+
|
63 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
64 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars ());
|
65 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
66 |
}
|
67 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
68 |
{
|
69 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
70 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
|
71 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
72 |
}
|
73 |
+
|
74 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
75 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars ());
|
76 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
77 |
+
|
78 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", $paypal, get_defined_vars ());
|
79 |
}
|
80 |
else
|
includes/classes/paypal-notify-in-subscr-or-rp-payment-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,69 +28,69 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract ($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
48 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
49 |
-
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
50 |
-
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))
|
51 |
-
&& (!empty ($paypal["txn_id"])) && (!empty ($paypal["mc_gross"]))
|
52 |
{
|
53 |
-
|
54 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
|
55 |
-
unset
|
56 |
-
|
57 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
58 |
{
|
59 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_payment|recurring_payment` )") . ".";
|
60 |
$paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
|
61 |
-
sleep (5);
|
62 |
-
|
63 |
$paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
|
64 |
-
|
65 |
-
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"],
|
66 |
-
|
67 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
68 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
69 |
-
|
70 |
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)
|
71 |
{
|
72 |
-
$processing = $during = true;
|
73 |
-
|
74 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
75 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"];
|
76 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
77 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
78 |
-
|
79 |
-
if (!get_user_option ("s2member_first_payment_txn_id", $user_id))
|
80 |
update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
|
81 |
-
|
82 |
-
update_user_option ($user_id, "s2member_last_payment_time", time ());
|
83 |
-
|
84 |
-
$paypal["s2member_log"][] = "Updated Payment Times for this Member.";
|
85 |
-
|
86 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
87 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
88 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
89 |
-
|
90 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
91 |
{
|
92 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
93 |
-
|
94 |
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)))
|
95 |
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)))
|
96 |
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)))
|
@@ -106,23 +106,23 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
106 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
107 |
{
|
108 |
if (is_array ($fields) && !empty ($fields))
|
109 |
-
foreach ($fields as $var => $val)
|
110 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
111 |
break;
|
112 |
-
|
113 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
114 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
115 |
}
|
116 |
}
|
117 |
-
|
118 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
119 |
}
|
120 |
-
|
121 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
122 |
{
|
123 |
-
$msg = $sbj = "(
|
124 |
-
$msg .= "\n\n";
|
125 |
-
|
126 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
127 |
$msg .= "amount: %%amount%%\n";
|
128 |
$msg .= "txn_id: %%txn_id%%\n";
|
@@ -132,7 +132,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
132 |
$msg .= "last_name: %%last_name%%\n";
|
133 |
$msg .= "full_name: %%full_name%%\n";
|
134 |
$msg .= "payer_email: %%payer_email%%\n";
|
135 |
-
|
136 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
137 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
138 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
@@ -140,11 +140,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
140 |
$msg .= "user_login: %%user_login%%\n";
|
141 |
$msg .= "user_ip: %%user_ip%%\n";
|
142 |
$msg .= "user_id: %%user_id%%\n";
|
143 |
-
|
144 |
if (is_array ($fields) && !empty ($fields))
|
145 |
foreach ($fields as $var => $val)
|
146 |
$msg .= $var . ": %%" . $var . "%%\n";
|
147 |
-
|
148 |
$msg .= "cv0: %%cv0%%\n";
|
149 |
$msg .= "cv1: %%cv1%%\n";
|
150 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -155,7 +155,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
155 |
$msg .= "cv7: %%cv7%%\n";
|
156 |
$msg .= "cv8: %%cv8%%\n";
|
157 |
$msg .= "cv9: %%cv9%%";
|
158 |
-
|
159 |
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)))
|
160 |
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)))
|
161 |
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)))
|
@@ -171,50 +171,50 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_
|
|
171 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
172 |
{
|
173 |
if (is_array ($fields) && !empty ($fields))
|
174 |
-
foreach ($fields as $var => $val)
|
175 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
176 |
break;
|
177 |
-
|
178 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
179 |
-
|
180 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
181 |
-
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 ()), "Content-Type: text/plain; charset=
|
182 |
}
|
183 |
}
|
184 |
-
|
185 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
186 |
}
|
187 |
-
|
188 |
-
|
189 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars ());
|
190 |
-
unset
|
191 |
}
|
192 |
-
else
|
193 |
{
|
194 |
$paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
|
195 |
-
|
196 |
-
$ipn = array ("txn_type" => "subscr_payment");
|
197 |
-
|
198 |
foreach ($paypal as $var => $val)
|
199 |
if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
200 |
$ipn[$var] = $val;
|
201 |
-
|
202 |
$paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
|
203 |
-
|
204 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
205 |
}
|
206 |
}
|
207 |
-
else
|
208 |
{
|
209 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
210 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_payment|recurring_payment` ).";
|
211 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
212 |
}
|
213 |
-
|
214 |
-
|
215 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars ());
|
216 |
-
unset
|
217 |
-
|
218 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", $paypal, get_defined_vars ());
|
219 |
}
|
220 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^(subscr_payment|recurring_payment)$/i", $paypal["txn_type"]))
|
46 |
+
&& ((!empty ($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (!empty ($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))
|
48 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
49 |
+
&& (!empty ($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))
|
50 |
+
&& (!empty ($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))
|
51 |
+
&& (!empty ($paypal["txn_id"])) && (!empty ($paypal["mc_gross"])))
|
52 |
{
|
53 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
54 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
|
55 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
56 |
+
|
57 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
58 |
{
|
59 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_payment|recurring_payment` )") . ".";
|
60 |
$paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
|
61 |
+
sleep (5); // Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
|
62 |
+
// 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.
|
63 |
$paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
|
64 |
+
|
65 |
+
list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
66 |
+
|
67 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
68 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
69 |
+
|
70 |
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)
|
71 |
{
|
72 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
73 |
+
|
74 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
75 |
+
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; // Preserves existing.
|
76 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
77 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); // Update now.
|
78 |
+
|
79 |
+
if (!get_user_option ("s2member_first_payment_txn_id", $user_id)) // 1st payment?
|
80 |
update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
|
81 |
+
|
82 |
+
update_user_option ($user_id, "s2member_last_payment_time", time ()); // Also update last payment time.
|
83 |
+
|
84 |
+
$paypal["s2member_log"][] = "Updated Payment Times for this Member."; // Flag this action in the log.
|
85 |
+
|
86 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); // These will be needed in the routines below.
|
87 |
+
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); // Original IP during Registration.
|
88 |
+
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally.
|
89 |
+
|
90 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
91 |
{
|
92 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
93 |
+
|
94 |
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)))
|
95 |
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)))
|
96 |
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)))
|
106 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
107 |
{
|
108 |
if (is_array ($fields) && !empty ($fields))
|
109 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
110 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
111 |
break;
|
112 |
+
|
113 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
114 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
115 |
}
|
116 |
}
|
117 |
+
|
118 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
119 |
}
|
120 |
+
|
121 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
122 |
{
|
123 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Payment";
|
124 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
125 |
+
|
126 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
127 |
$msg .= "amount: %%amount%%\n";
|
128 |
$msg .= "txn_id: %%txn_id%%\n";
|
132 |
$msg .= "last_name: %%last_name%%\n";
|
133 |
$msg .= "full_name: %%full_name%%\n";
|
134 |
$msg .= "payer_email: %%payer_email%%\n";
|
135 |
+
|
136 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
137 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
138 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
140 |
$msg .= "user_login: %%user_login%%\n";
|
141 |
$msg .= "user_ip: %%user_ip%%\n";
|
142 |
$msg .= "user_id: %%user_id%%\n";
|
143 |
+
|
144 |
if (is_array ($fields) && !empty ($fields))
|
145 |
foreach ($fields as $var => $val)
|
146 |
$msg .= $var . ": %%" . $var . "%%\n";
|
147 |
+
|
148 |
$msg .= "cv0: %%cv0%%\n";
|
149 |
$msg .= "cv1: %%cv1%%\n";
|
150 |
$msg .= "cv2: %%cv2%%\n";
|
155 |
$msg .= "cv7: %%cv7%%\n";
|
156 |
$msg .= "cv8: %%cv8%%\n";
|
157 |
$msg .= "cv9: %%cv9%%";
|
158 |
+
|
159 |
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)))
|
160 |
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)))
|
161 |
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)))
|
171 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
172 |
{
|
173 |
if (is_array ($fields) && !empty ($fields))
|
174 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
175 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
176 |
break;
|
177 |
+
|
178 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
179 |
+
|
180 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
181 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
182 |
}
|
183 |
}
|
184 |
+
|
185 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
186 |
}
|
187 |
+
|
188 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
189 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars ());
|
190 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
191 |
}
|
192 |
+
else // Otherwise, we need to re-generate/store this IPN into a Transient Queue. Then re-process it on registration.
|
193 |
{
|
194 |
$paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
|
195 |
+
|
196 |
+
$ipn = array ("txn_type" => "subscr_payment"); // Create a simulated IPN response for txn_type=subscr_payment.
|
197 |
+
|
198 |
foreach ($paypal as $var => $val)
|
199 |
if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
200 |
$ipn[$var] = $val;
|
201 |
+
|
202 |
$paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
|
203 |
+
|
204 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
205 |
}
|
206 |
}
|
207 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
208 |
{
|
209 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
210 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_payment|recurring_payment` ).";
|
211 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
212 |
}
|
213 |
+
|
214 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
215 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars ());
|
216 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
217 |
+
|
218 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", $paypal, get_defined_vars ());
|
219 |
}
|
220 |
else
|
includes/classes/paypal-notify-in-subscr-or-wa-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,142 +28,139 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function
|
42 |
{
|
43 |
-
extract
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (!empty ($paypal["subscr_id"]) || (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])))
|
48 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
49 |
-
&& (!empty ($paypal["payer_email"]))
|
50 |
{
|
51 |
-
|
52 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", get_defined_vars ());
|
53 |
-
unset
|
54 |
-
|
55 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
56 |
{
|
57 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ).";
|
58 |
-
|
59 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
60 |
-
|
61 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
62 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
63 |
-
|
64 |
-
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] :
|
65 |
-
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
66 |
-
|
67 |
-
if (preg_match ("/^web_accept$/i", $paypal["txn_type"])
|
68 |
{
|
69 |
-
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] :
|
70 |
-
$paypal["mc_amount3"] =
|
71 |
}
|
72 |
-
|
73 |
-
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
74 |
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
75 |
-
$paypal["regular"] =
|
76 |
-
$paypal["regular_term"] =
|
77 |
-
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
78 |
-
|
79 |
-
|
80 |
/*
|
81 |
-
New Subscription with advanced update vars (
|
82 |
*/
|
83 |
-
if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
84 |
-
|
85 |
-
PayPal® will not allow the `modify=1|2` parameter to be used in those scenarios, because technically there is no billing to update; only the account.
|
86 |
{
|
87 |
-
|
88 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
|
89 |
-
unset
|
90 |
-
|
91 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars.";
|
92 |
-
|
93 |
-
/* Check for both the old & new subscr_id's, just in case the Return routine already changed it. */
|
94 |
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)
|
95 |
{
|
96 |
-
if
|
97 |
{
|
98 |
-
$processing = $modifying = $during =
|
99 |
-
|
100 |
-
|
101 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", get_defined_vars ());
|
102 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
|
103 |
-
unset
|
104 |
-
|
105 |
-
$fields =
|
106 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
107 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
108 |
-
|
109 |
-
if (is_multisite () && !is_user_member_of_blog ($user_id)
|
110 |
{
|
111 |
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
112 |
$user = new WP_User ($user_id);
|
113 |
}
|
114 |
-
/**/
|
115 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
116 |
-
|
117 |
-
if ($current_role !== "s2member_level" . $paypal["level"])
|
118 |
-
$user->set_role ("s2member_level" . $paypal["level"]);
|
119 |
-
|
120 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
121 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
122 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
123 |
$user->remove_cap ($ccap = $cap);
|
124 |
-
|
125 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
126 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
127 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
128 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
129 |
-
|
130 |
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
131 |
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
132 |
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
133 |
-
|
134 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
135 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
136 |
-
|
137 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
138 |
-
|
139 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
140 |
-
|
141 |
if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
142 |
{
|
143 |
-
update_user_option ($user_id, "s2member_auto_eot_time",
|
144 |
($eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"], "", get_user_option ("s2member_auto_eot_time", $user_id))));
|
145 |
-
$paypal["s2member_log"][] = "Automatic EOT (
|
146 |
}
|
147 |
-
else /* Otherwise, we need to clear the Auto-EOT Time. */
|
148 |
-
|
149 |
-
/**/
|
150 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
151 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"];
|
152 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
153 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
154 |
-
|
155 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
156 |
-
|
|
|
157 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
158 |
-
|
159 |
-
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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=
|
160 |
-
|
161 |
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
162 |
-
|
163 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
164 |
{
|
165 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
|
166 |
-
|
167 |
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)))
|
168 |
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)))
|
169 |
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)))
|
@@ -171,7 +168,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
171 |
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)))
|
172 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
173 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
174 |
-
|
175 |
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)))
|
176 |
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)))
|
177 |
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
@@ -180,22 +177,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
180 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
181 |
{
|
182 |
if (is_array ($fields) && !empty ($fields))
|
183 |
-
foreach ($fields as $var => $val)
|
184 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
185 |
break;
|
186 |
-
|
187 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
188 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
189 |
}
|
190 |
-
/**/
|
191 |
$paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
|
192 |
}
|
193 |
-
/**/
|
194 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
195 |
{
|
196 |
-
$msg = $sbj = "(
|
197 |
-
$msg .=
|
198 |
-
|
199 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
200 |
$msg .= "initial: %%initial%%\n";
|
201 |
$msg .= "regular: %%regular%%\n";
|
@@ -208,7 +203,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
208 |
$msg .= "last_name: %%last_name%%\n";
|
209 |
$msg .= "full_name: %%full_name%%\n";
|
210 |
$msg .= "payer_email: %%payer_email%%\n";
|
211 |
-
|
212 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
213 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
214 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
@@ -216,11 +211,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
216 |
$msg .= "user_login: %%user_login%%\n";
|
217 |
$msg .= "user_ip: %%user_ip%%\n";
|
218 |
$msg .= "user_id: %%user_id%%\n";
|
219 |
-
|
220 |
if (is_array ($fields) && !empty ($fields))
|
221 |
foreach ($fields as $var => $val)
|
222 |
$msg .= $var . ": %%" . $var . "%%\n";
|
223 |
-
|
224 |
$msg .= "cv0: %%cv0%%\n";
|
225 |
$msg .= "cv1: %%cv1%%\n";
|
226 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -231,7 +226,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
231 |
$msg .= "cv7: %%cv7%%\n";
|
232 |
$msg .= "cv8: %%cv8%%\n";
|
233 |
$msg .= "cv9: %%cv9%%";
|
234 |
-
|
235 |
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)))
|
236 |
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)))
|
237 |
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)))
|
@@ -239,7 +234,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
239 |
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)))
|
240 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
241 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
242 |
-
|
243 |
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)))
|
244 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
245 |
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
@@ -248,19 +243,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
248 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
249 |
{
|
250 |
if (is_array ($fields) && !empty ($fields))
|
251 |
-
foreach ($fields as $var => $val)
|
252 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
253 |
break;
|
254 |
-
|
255 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
256 |
-
|
257 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"]) as $recipient)
|
258 |
-
wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "Content-Type: text/plain; charset=
|
259 |
}
|
260 |
-
/**/
|
261 |
$paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
|
262 |
}
|
263 |
-
/**/
|
264 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
265 |
{
|
266 |
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)))
|
@@ -279,11 +272,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
279 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
280 |
{
|
281 |
if (is_array ($fields) && !empty ($fields))
|
282 |
-
foreach ($fields as $var => $val)
|
283 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
284 |
break;
|
285 |
-
|
286 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))
|
287 |
{
|
288 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
289 |
set_transient ("s2m_" . md5 ("s2member_transient_modification_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
@@ -291,40 +284,37 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
291 |
}
|
292 |
}
|
293 |
}
|
294 |
-
|
295 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
296 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
|
297 |
-
unset
|
298 |
}
|
299 |
-
else
|
300 |
-
$paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
301 |
}
|
302 |
-
else
|
303 |
-
|
304 |
-
|
305 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
306 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars ());
|
307 |
-
unset
|
308 |
}
|
309 |
/*
|
310 |
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
311 |
*/
|
312 |
-
else
|
313 |
{
|
314 |
-
|
315 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars ());
|
316 |
-
unset
|
317 |
-
|
318 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/o update vars.";
|
319 |
-
|
320 |
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"])))
|
321 |
{
|
322 |
-
$processing = $during =
|
323 |
-
|
324 |
-
$sbj = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
325 |
-
$msg = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
326 |
-
$rec = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
327 |
-
|
328 |
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)))
|
329 |
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)))
|
330 |
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)))
|
@@ -332,10 +322,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
332 |
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)))
|
333 |
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)))
|
334 |
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)))
|
335 |
-
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)))
|
336 |
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
337 |
if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
|
338 |
-
|
339 |
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)))
|
340 |
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)))
|
341 |
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)))
|
@@ -346,7 +336,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
346 |
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
347 |
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
348 |
if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
|
349 |
-
|
350 |
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)))
|
351 |
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)))
|
352 |
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)))
|
@@ -357,19 +347,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
357 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
358 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
359 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
360 |
-
|
361 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
362 |
{
|
363 |
-
foreach
|
364 |
-
c_ws_plugin__s2member_email_configs::email_config () . 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=
|
365 |
-
|
366 |
$paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . $rec . ".";
|
367 |
}
|
368 |
-
/**/
|
369 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
370 |
{
|
371 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
|
372 |
-
|
373 |
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)))
|
374 |
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)))
|
375 |
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)))
|
@@ -378,18 +367,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
378 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
379 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
380 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
381 |
-
|
382 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
383 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
384 |
-
|
385 |
$paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
|
386 |
}
|
387 |
-
/**/
|
388 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
389 |
{
|
390 |
-
$msg = $sbj = "(
|
391 |
-
$msg .=
|
392 |
-
|
393 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
394 |
$msg .= "initial: %%initial%%\n";
|
395 |
$msg .= "regular: %%regular%%\n";
|
@@ -403,7 +391,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
403 |
$msg .= "full_name: %%full_name%%\n";
|
404 |
$msg .= "payer_email: %%payer_email%%\n";
|
405 |
$msg .= "user_ip: %%user_ip%%\n";
|
406 |
-
|
407 |
$msg .= "cv0: %%cv0%%\n";
|
408 |
$msg .= "cv1: %%cv1%%\n";
|
409 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -414,7 +402,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
414 |
$msg .= "cv7: %%cv7%%\n";
|
415 |
$msg .= "cv8: %%cv8%%\n";
|
416 |
$msg .= "cv9: %%cv9%%";
|
417 |
-
|
418 |
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)))
|
419 |
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)))
|
420 |
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)))
|
@@ -423,15 +411,14 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
423 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
424 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
425 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
426 |
-
|
427 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
428 |
-
|
429 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"]) as $recipient)
|
430 |
-
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 ()), "Content-Type: text/plain; charset=
|
431 |
-
|
432 |
$paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
|
433 |
}
|
434 |
-
/**/
|
435 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
436 |
{
|
437 |
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)))
|
@@ -442,33 +429,30 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
442 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
443 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
444 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
445 |
-
|
446 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))
|
447 |
{
|
448 |
$paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
|
449 |
set_transient ("s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
450 |
}
|
451 |
}
|
452 |
-
|
453 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
454 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());
|
455 |
-
unset
|
456 |
}
|
457 |
-
else
|
458 |
-
|
459 |
-
|
460 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
461 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars ());
|
462 |
-
unset
|
463 |
}
|
464 |
-
|
465 |
-
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? */
|
466 |
{
|
467 |
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))
|
468 |
{
|
469 |
-
$fields =
|
470 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
471 |
-
|
472 |
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)))
|
473 |
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)))
|
474 |
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)))
|
@@ -486,43 +470,41 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
486 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
487 |
{
|
488 |
if (is_array ($fields) && !empty ($fields))
|
489 |
-
foreach ($fields as $var => $val)
|
490 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
491 |
break;
|
492 |
-
|
493 |
-
if (($url = trim ($url)))
|
494 |
-
|
495 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
496 |
}
|
497 |
}
|
498 |
}
|
499 |
-
/**/
|
500 |
$paypal["s2member_log"][] = "Subscr. Return ( `modification=" . (int)$modifying . "` ), a Proxy Return URL is ready.";
|
501 |
}
|
502 |
-
|
503 |
-
|
504 |
-
&& (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))/**/
|
505 |
&& (($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)))
|
506 |
{
|
507 |
$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") . "` ).";
|
508 |
-
|
509 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
510 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"];
|
511 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
512 |
-
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
513 |
-
|
514 |
-
if (!get_user_option ("s2member_first_payment_txn_id", $user_id))
|
515 |
update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
|
516 |
-
|
517 |
-
update_user_option ($user_id, "s2member_last_payment_time", time ());
|
518 |
-
|
519 |
-
$fields =
|
520 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
521 |
-
|
522 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
523 |
{
|
524 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
525 |
-
|
526 |
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)))
|
527 |
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)))
|
528 |
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)))
|
@@ -538,23 +520,21 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
538 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
539 |
{
|
540 |
if (is_array ($fields) && !empty ($fields))
|
541 |
-
foreach ($fields as $var => $val)
|
542 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
543 |
break;
|
544 |
-
|
545 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
546 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
547 |
}
|
548 |
}
|
549 |
-
/**/
|
550 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
551 |
}
|
552 |
-
/**/
|
553 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
554 |
{
|
555 |
-
$msg = $sbj = "(
|
556 |
-
$msg .=
|
557 |
-
|
558 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
559 |
$msg .= "amount: %%amount%%\n";
|
560 |
$msg .= "txn_id: %%txn_id%%\n";
|
@@ -564,7 +544,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
564 |
$msg .= "last_name: %%last_name%%\n";
|
565 |
$msg .= "full_name: %%full_name%%\n";
|
566 |
$msg .= "payer_email: %%payer_email%%\n";
|
567 |
-
|
568 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
569 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
570 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
@@ -572,11 +552,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
572 |
$msg .= "user_login: %%user_login%%\n";
|
573 |
$msg .= "user_ip: %%user_ip%%\n";
|
574 |
$msg .= "user_id: %%user_id%%\n";
|
575 |
-
|
576 |
if (is_array ($fields) && !empty ($fields))
|
577 |
foreach ($fields as $var => $val)
|
578 |
$msg .= $var . ": %%" . $var . "%%\n";
|
579 |
-
|
580 |
$msg .= "cv0: %%cv0%%\n";
|
581 |
$msg .= "cv1: %%cv1%%\n";
|
582 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -587,7 +567,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
587 |
$msg .= "cv7: %%cv7%%\n";
|
588 |
$msg .= "cv8: %%cv8%%\n";
|
589 |
$msg .= "cv9: %%cv9%%";
|
590 |
-
|
591 |
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)))
|
592 |
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)))
|
593 |
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)))
|
@@ -603,65 +583,61 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"
|
|
603 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
604 |
{
|
605 |
if (is_array ($fields) && !empty ($fields))
|
606 |
-
foreach ($fields as $var => $val)
|
607 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
608 |
break;
|
609 |
-
|
610 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
611 |
-
|
612 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
613 |
-
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 ()), "Content-Type: text/plain; charset=
|
614 |
}
|
615 |
}
|
616 |
-
/**/
|
617 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
618 |
}
|
619 |
}
|
620 |
-
else if ($processing
|
621 |
-
&& (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($
|
622 |
{
|
623 |
$paypal["s2member_log"][] = "Storing `payment` for Subscription via ( `" . ((preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . "` ).";
|
624 |
-
|
625 |
-
$ipn =
|
626 |
-
|
627 |
foreach ($paypal as $var => $val)
|
628 |
if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
629 |
$ipn[$var] = $val;
|
630 |
-
|
631 |
$paypal["s2member_log"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.";
|
632 |
-
|
633 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
634 |
}
|
635 |
-
|
636 |
-
if ($processing /* Store signup vars now? If the User already exists in the database, we can go ahead and store these right now. */
|
637 |
&& (($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)))
|
638 |
{
|
639 |
$paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference.";
|
640 |
-
|
641 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
642 |
}
|
643 |
-
else if
|
644 |
{
|
645 |
$paypal["s2member_log"][] = "Storing IPN signup vars into a Transient Queue. These will be processed on registration.";
|
646 |
-
|
647 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_signup_vars_" . $paypal["subscr_id"]), $ipn_signup_vars, 43200);
|
648 |
}
|
649 |
}
|
650 |
-
else
|
651 |
{
|
652 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
653 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ).";
|
654 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
655 |
}
|
656 |
-
|
657 |
-
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
658 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup", get_defined_vars ());
|
659 |
-
unset
|
660 |
-
|
661 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", $paypal, get_defined_vars ());
|
662 |
}
|
663 |
-
else
|
664 |
-
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", false, get_defined_vars ());
|
665 |
}
|
666 |
}
|
667 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
42 |
{
|
43 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ ($vars);
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (!empty ($paypal["subscr_id"]) || (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])))
|
48 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
49 |
+
&& (!empty ($paypal["payer_email"])))
|
50 |
{
|
51 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
52 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", get_defined_vars ());
|
53 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
54 |
+
|
55 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
56 |
{
|
57 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ).";
|
58 |
+
|
59 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
60 |
+
|
61 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
62 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
63 |
+
|
64 |
+
$paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
65 |
+
$paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
66 |
+
|
67 |
+
if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) /* Conversions for Lifetime & Fixed-Term sales. */)
|
68 |
{
|
69 |
+
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : /* 1 Lifetime. */ "1 L";
|
70 |
+
$paypal["mc_amount3"] = /* The "Buy Now" amount is the full gross. */$paypal["mc_gross"];
|
71 |
}
|
72 |
+
$paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
|
|
73 |
$paypal["initial"] = (strlen ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
74 |
+
$paypal["regular"] = /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */$paypal["mc_amount3"];
|
75 |
+
$paypal["regular_term"] = /* This is just set to keep a standard; this way both initial_term & regular_term are available. */ $paypal["period3"];
|
76 |
+
$paypal["recurring"] = /* If non-recurring, this should be zero, otherwise Regular. */($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
77 |
+
|
78 |
+
$ipn_signup_vars = $paypal; /* Create array of IPN signup vars w/o s2member_log. */ unset($ipn_signup_vars["s2member_log"]);
|
79 |
/*
|
80 |
+
New Subscription with advanced update vars (option_name1, option_selection1)? These variables are used in Subscr. Modifications.
|
81 |
*/
|
82 |
+
if /* Advanced way to handle Subscription mods. */ (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
83 |
+
// 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.
|
84 |
+
// PayPal® will not allow the `modify=1|2` parameter to be used in those scenarios, because technically there is no billing to update; only the account.
|
85 |
{
|
86 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
87 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
|
88 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
89 |
+
|
90 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars.";
|
91 |
+
|
|
|
92 |
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)
|
93 |
{
|
94 |
+
if /* Do NOT process this routine on Administrators. */(!$user->has_cap ("administrator"))
|
95 |
{
|
96 |
+
$processing = $modifying = $during = /* Yes, we ARE processing this. */ true;
|
97 |
+
|
98 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
99 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", get_defined_vars ());
|
100 |
do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
|
101 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
102 |
+
|
103 |
+
$fields = /* These will be needed in the routines below. */get_user_option ("s2member_custom_fields", $user_id);
|
104 |
+
$user_reg_ip = /* Original IP during Registration. */get_user_option ("s2member_registration_ip", $user_id);
|
105 |
+
$user_reg_ip = $paypal["ip"] = /* Now merge conditionally. */ ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
106 |
+
|
107 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id) /* Must have a Role on this Blog. */)
|
108 |
{
|
109 |
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
|
110 |
$user = new WP_User ($user_id);
|
111 |
}
|
|
|
112 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
|
113 |
+
|
114 |
+
if /* Only if we need to. */($current_role !== "s2member_level" . $paypal["level"])
|
115 |
+
$user->set_role /* (upgrade/downgrade) */("s2member_level" . $paypal["level"]);
|
116 |
+
|
117 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
118 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
119 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
120 |
$user->remove_cap ($ccap = $cap);
|
121 |
+
|
122 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
123 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
124 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
125 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
126 |
+
|
127 |
update_user_option ($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
128 |
update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
129 |
update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
|
130 |
+
|
131 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
132 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
133 |
+
|
134 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
135 |
+
|
136 |
delete_user_option ($user_id, "s2member_file_download_access_log");
|
137 |
+
|
138 |
if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
139 |
{
|
140 |
+
update_user_option ($user_id, "s2member_auto_eot_time", // Set exclusively by the IPN handler; to avoid duplicate extensions.
|
141 |
($eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"], "", get_user_option ("s2member_auto_eot_time", $user_id))));
|
142 |
+
$paypal["s2member_log"][] = "Automatic EOT (End Of Term) Time set to: " . date ("D M j, Y g:i:s a T", $eot_time) . ".";
|
143 |
}
|
144 |
+
else /* Otherwise, we need to clear the Auto-EOT Time. */ delete_user_option ($user_id, "s2member_auto_eot_time");
|
145 |
+
|
|
|
146 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
147 |
+
$pr_times["level"] = /* Preserve existing. */(!$pr_times["level"]) ? time () : $pr_times["level"];
|
148 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
149 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
150 |
+
|
151 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
|
152 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Paid Subscr\. ID @ time of demotion\:/");
|
153 |
+
|
154 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
155 |
+
|
156 |
+
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
157 |
+
|
158 |
$paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
159 |
+
|
160 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
161 |
{
|
162 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
|
163 |
+
|
164 |
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)))
|
165 |
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)))
|
166 |
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)))
|
168 |
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)))
|
169 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
170 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
171 |
+
|
172 |
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)))
|
173 |
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)))
|
174 |
if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
|
177 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
178 |
{
|
179 |
if (is_array ($fields) && !empty ($fields))
|
180 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
181 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
182 |
break;
|
183 |
+
|
184 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
185 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
186 |
}
|
|
|
187 |
$paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
|
188 |
}
|
|
|
189 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
190 |
{
|
191 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Modification";
|
192 |
+
$msg .= /* Spacing in the message body. */"\n\n";
|
193 |
+
|
194 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
195 |
$msg .= "initial: %%initial%%\n";
|
196 |
$msg .= "regular: %%regular%%\n";
|
203 |
$msg .= "last_name: %%last_name%%\n";
|
204 |
$msg .= "full_name: %%full_name%%\n";
|
205 |
$msg .= "payer_email: %%payer_email%%\n";
|
206 |
+
|
207 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
208 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
209 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
211 |
$msg .= "user_login: %%user_login%%\n";
|
212 |
$msg .= "user_ip: %%user_ip%%\n";
|
213 |
$msg .= "user_id: %%user_id%%\n";
|
214 |
+
|
215 |
if (is_array ($fields) && !empty ($fields))
|
216 |
foreach ($fields as $var => $val)
|
217 |
$msg .= $var . ": %%" . $var . "%%\n";
|
218 |
+
|
219 |
$msg .= "cv0: %%cv0%%\n";
|
220 |
$msg .= "cv1: %%cv1%%\n";
|
221 |
$msg .= "cv2: %%cv2%%\n";
|
226 |
$msg .= "cv7: %%cv7%%\n";
|
227 |
$msg .= "cv8: %%cv8%%\n";
|
228 |
$msg .= "cv9: %%cv9%%";
|
229 |
+
|
230 |
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)))
|
231 |
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)))
|
232 |
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)))
|
234 |
if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
|
235 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
236 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
237 |
+
|
238 |
if (($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)))
|
239 |
if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
|
240 |
if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
|
243 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
244 |
{
|
245 |
if (is_array ($fields) && !empty ($fields))
|
246 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
247 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
248 |
break;
|
249 |
+
|
250 |
+
if /* Still have a ``$sbj`` and a ``$msg``? */($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
251 |
+
|
252 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"]) as $recipient)
|
253 |
+
wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "Content-Type: text/plain; charset=UTF-8");
|
254 |
}
|
|
|
255 |
$paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
|
256 |
}
|
|
|
257 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
258 |
{
|
259 |
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)))
|
272 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
273 |
{
|
274 |
if (is_array ($fields) && !empty ($fields))
|
275 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
276 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
277 |
break;
|
278 |
+
|
279 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
280 |
{
|
281 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
282 |
set_transient ("s2m_" . md5 ("s2member_transient_modification_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
284 |
}
|
285 |
}
|
286 |
}
|
287 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
288 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
|
289 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
290 |
}
|
291 |
+
else $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
|
|
292 |
}
|
293 |
+
else $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.";
|
294 |
+
|
295 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
296 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars ());
|
297 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
298 |
}
|
299 |
/*
|
300 |
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
301 |
*/
|
302 |
+
else // Else this is a normal Subscription signup, we are not updating anything.
|
303 |
{
|
304 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
305 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars ());
|
306 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
307 |
+
|
308 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/o update vars.";
|
309 |
+
|
310 |
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"])))
|
311 |
{
|
312 |
+
$processing = $during = /* Yes, we ARE processing this. */true;
|
313 |
+
|
314 |
+
$sbj = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_subject"]);
|
315 |
+
$msg = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_message"]);
|
316 |
+
$rec = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_recipients"]);
|
317 |
+
|
318 |
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)))
|
319 |
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)))
|
320 |
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)))
|
322 |
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)))
|
323 |
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)))
|
324 |
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)))
|
325 |
+
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>).
|
326 |
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
327 |
if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
|
328 |
+
|
329 |
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)))
|
330 |
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)))
|
331 |
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)))
|
336 |
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
337 |
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
338 |
if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
|
339 |
+
|
340 |
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)))
|
341 |
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)))
|
342 |
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)))
|
347 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
348 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
349 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
350 |
+
|
351 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
352 |
{
|
353 |
+
foreach /* Go through a possible list of recipients. */(c_ws_plugin__s2member_utils_strings::parse_emails ($rec) as $recipient)
|
354 |
+
c_ws_plugin__s2member_email_configs::email_config () . 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") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
355 |
+
|
356 |
$paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . $rec . ".";
|
357 |
}
|
|
|
358 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
359 |
{
|
360 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
|
361 |
+
|
362 |
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)))
|
363 |
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)))
|
364 |
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)))
|
367 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
368 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
369 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
370 |
+
|
371 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
372 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
373 |
+
|
374 |
$paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
|
375 |
}
|
|
|
376 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
377 |
{
|
378 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Signup";
|
379 |
+
$msg .= /* Spacing in the message body. */ "\n\n";
|
380 |
+
|
381 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
382 |
$msg .= "initial: %%initial%%\n";
|
383 |
$msg .= "regular: %%regular%%\n";
|
391 |
$msg .= "full_name: %%full_name%%\n";
|
392 |
$msg .= "payer_email: %%payer_email%%\n";
|
393 |
$msg .= "user_ip: %%user_ip%%\n";
|
394 |
+
|
395 |
$msg .= "cv0: %%cv0%%\n";
|
396 |
$msg .= "cv1: %%cv1%%\n";
|
397 |
$msg .= "cv2: %%cv2%%\n";
|
402 |
$msg .= "cv7: %%cv7%%\n";
|
403 |
$msg .= "cv8: %%cv8%%\n";
|
404 |
$msg .= "cv9: %%cv9%%";
|
405 |
+
|
406 |
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)))
|
407 |
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)))
|
408 |
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)))
|
411 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
412 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
413 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
414 |
+
|
415 |
+
if /* Still have a ``$sbj`` and a ``$msg``? */($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
416 |
+
|
417 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"]) as $recipient)
|
418 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
419 |
+
|
420 |
$paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
|
421 |
}
|
|
|
422 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
423 |
{
|
424 |
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)))
|
429 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
430 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
431 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
432 |
+
|
433 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
434 |
{
|
435 |
$paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
|
436 |
set_transient ("s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
|
437 |
}
|
438 |
}
|
439 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
440 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());
|
441 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
442 |
}
|
443 |
+
else $paypal["s2member_log"][] = "Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response.";
|
444 |
+
|
445 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
446 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars ());
|
447 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
448 |
}
|
449 |
+
if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) // A Proxy is requesting a Return URL?
|
|
|
450 |
{
|
451 |
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))
|
452 |
{
|
453 |
+
$fields = /* These will be needed in the routines below. */get_user_option ("s2member_custom_fields", $user_id);
|
454 |
+
$user_reg_ip = /* Original IP during Registration. */get_user_option ("s2member_registration_ip", $user_id);
|
455 |
+
|
456 |
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)))
|
457 |
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)))
|
458 |
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)))
|
470 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
471 |
{
|
472 |
if (is_array ($fields) && !empty ($fields))
|
473 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
474 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
475 |
break;
|
476 |
+
|
477 |
+
if /* Preserve remaining replacements. */(($url = trim ($url)))
|
478 |
+
// Because the parent routine may perform replacements too.
|
479 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
480 |
}
|
481 |
}
|
482 |
}
|
|
|
483 |
$paypal["s2member_log"][] = "Subscr. Return ( `modification=" . (int)$modifying . "` ), a Proxy Return URL is ready.";
|
484 |
}
|
485 |
+
if ($processing // Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`.
|
486 |
+
&& (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_REQUEST["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/", $_REQUEST["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0))
|
|
|
487 |
&& (($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)))
|
488 |
{
|
489 |
$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") . "` ).";
|
490 |
+
|
491 |
$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
|
492 |
+
$pr_times["level"] = /* Preserve existing. */ (!$pr_times["level"]) ? time () : $pr_times["level"];
|
493 |
$pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
|
494 |
+
update_user_option ($user_id, "s2member_paid_registration_times", $pr_times);
|
495 |
+
|
496 |
+
if /* 1st payment? */(!get_user_option ("s2member_first_payment_txn_id", $user_id))
|
497 |
update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
|
498 |
+
|
499 |
+
update_user_option /* Update the last payment time. */ ($user_id, "s2member_last_payment_time", time ());
|
500 |
+
|
501 |
+
$fields = /* These will be needed in the routines below. */ get_user_option ("s2member_custom_fields", $user_id);
|
502 |
+
$user_reg_ip = /* Original IP during Registration. */get_user_option ("s2member_registration_ip", $user_id);
|
503 |
+
|
504 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
505 |
{
|
506 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
507 |
+
|
508 |
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)))
|
509 |
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)))
|
510 |
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)))
|
520 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
521 |
{
|
522 |
if (is_array ($fields) && !empty ($fields))
|
523 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
524 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
525 |
break;
|
526 |
+
|
527 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
528 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
529 |
}
|
530 |
}
|
|
|
531 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
532 |
}
|
|
|
533 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
534 |
{
|
535 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Payment";
|
536 |
+
$msg .= /* Spacing in the message body. */"\n\n";
|
537 |
+
|
538 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
539 |
$msg .= "amount: %%amount%%\n";
|
540 |
$msg .= "txn_id: %%txn_id%%\n";
|
544 |
$msg .= "last_name: %%last_name%%\n";
|
545 |
$msg .= "full_name: %%full_name%%\n";
|
546 |
$msg .= "payer_email: %%payer_email%%\n";
|
547 |
+
|
548 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
549 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
550 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
552 |
$msg .= "user_login: %%user_login%%\n";
|
553 |
$msg .= "user_ip: %%user_ip%%\n";
|
554 |
$msg .= "user_id: %%user_id%%\n";
|
555 |
+
|
556 |
if (is_array ($fields) && !empty ($fields))
|
557 |
foreach ($fields as $var => $val)
|
558 |
$msg .= $var . ": %%" . $var . "%%\n";
|
559 |
+
|
560 |
$msg .= "cv0: %%cv0%%\n";
|
561 |
$msg .= "cv1: %%cv1%%\n";
|
562 |
$msg .= "cv2: %%cv2%%\n";
|
567 |
$msg .= "cv7: %%cv7%%\n";
|
568 |
$msg .= "cv8: %%cv8%%\n";
|
569 |
$msg .= "cv9: %%cv9%%";
|
570 |
+
|
571 |
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)))
|
572 |
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)))
|
573 |
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)))
|
583 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
584 |
{
|
585 |
if (is_array ($fields) && !empty ($fields))
|
586 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
587 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
588 |
break;
|
589 |
+
|
590 |
+
if /* Still have a ``$sbj`` and a ``$msg``? */($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
591 |
+
|
592 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
593 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
594 |
}
|
595 |
}
|
|
|
596 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
597 |
}
|
598 |
}
|
599 |
+
else if ($processing // Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`.
|
600 |
+
&& (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_REQUEST["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/", $_REQUEST["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0)))
|
601 |
{
|
602 |
$paypal["s2member_log"][] = "Storing `payment` for Subscription via ( `" . ((preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . "` ).";
|
603 |
+
|
604 |
+
$ipn = /* Create a simulated IPN response for txn_type=subscr_payment. */array ("txn_type" => "subscr_payment");
|
605 |
+
|
606 |
foreach ($paypal as $var => $val)
|
607 |
if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
|
608 |
$ipn[$var] = $val;
|
609 |
+
|
610 |
$paypal["s2member_log"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.";
|
611 |
+
|
612 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
|
613 |
}
|
614 |
+
if ($processing // Store signup vars now? If the User already exists in the database, we can go ahead and store these right now.
|
|
|
615 |
&& (($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)))
|
616 |
{
|
617 |
$paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference.";
|
618 |
+
|
619 |
update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
620 |
}
|
621 |
+
else if /* Otherwise, we can store these into a Transient Queue for registration processing. */ ($processing)
|
622 |
{
|
623 |
$paypal["s2member_log"][] = "Storing IPN signup vars into a Transient Queue. These will be processed on registration.";
|
624 |
+
|
625 |
set_transient ("s2m_" . md5 ("s2member_transient_ipn_signup_vars_" . $paypal["subscr_id"]), $ipn_signup_vars, 43200);
|
626 |
}
|
627 |
}
|
628 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
629 |
{
|
630 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
631 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ).";
|
632 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
633 |
}
|
634 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
635 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup", get_defined_vars ());
|
636 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
637 |
+
|
638 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", $paypal, get_defined_vars ());
|
639 |
}
|
640 |
+
else return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", false, get_defined_vars ());
|
|
|
641 |
}
|
642 |
}
|
643 |
}
|
includes/classes/paypal-notify-in-virtual-terminal.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,49 +28,49 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_virtual_terminal
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function cp ($vars = array ())
|
40 |
{
|
41 |
-
extract($vars);
|
42 |
-
|
43 |
-
if (
|
44 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
-
&& (!empty ($paypal["txn_id"]))
|
46 |
{
|
47 |
-
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars ());
|
49 |
-
unset
|
50 |
-
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
|
54 |
-
|
55 |
-
$processing = $during = true;
|
56 |
-
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
-
|
59 |
-
|
60 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars ());
|
61 |
-
unset
|
62 |
}
|
63 |
-
else
|
64 |
{
|
65 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
66 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
|
67 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
68 |
}
|
69 |
-
|
70 |
-
|
71 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars ());
|
72 |
-
unset
|
73 |
-
|
74 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal", $paypal, get_defined_vars ());
|
75 |
}
|
76 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_virtual_terminal
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
40 |
{
|
41 |
+
extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
+
|
43 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^virtual_terminal$/i", $paypal["txn_type"]))
|
44 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
45 |
+
&& (!empty ($paypal["txn_id"])))
|
46 |
{
|
47 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
48 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars ());
|
49 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
50 |
+
|
51 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
|
54 |
+
|
55 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
56 |
+
|
57 |
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
|
58 |
+
|
59 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
60 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars ());
|
61 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
62 |
}
|
63 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
64 |
{
|
65 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
66 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
|
67 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
68 |
}
|
69 |
+
|
70 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
71 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars ());
|
72 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
73 |
+
|
74 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal", $paypal, get_defined_vars ());
|
75 |
}
|
76 |
else
|
includes/classes/paypal-notify-in-wa-ccaps-wo-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110815
|
@@ -28,80 +28,80 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110815
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract ($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
-
&& (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (!empty ($paypal["payer_email"]))
|
49 |
{
|
50 |
-
|
51 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_new_ccaps", get_defined_vars ());
|
52 |
-
unset
|
53 |
-
|
54 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
57 |
-
|
58 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
-
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
-
|
63 |
-
if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
64 |
{
|
65 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["txn_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
66 |
{
|
67 |
-
if (!$user->has_cap ("administrator"))
|
68 |
{
|
69 |
-
$processing = $during = true;
|
70 |
-
|
71 |
-
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps", get_defined_vars ());
|
73 |
-
unset
|
74 |
-
|
75 |
-
$fields = get_user_option ("s2member_custom_fields", $user_id);
|
76 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
77 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
78 |
-
|
79 |
-
if (is_multisite () && !is_user_member_of_blog ($user_id))
|
80 |
{
|
81 |
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => get_option ("default_role")));
|
82 |
$user = new WP_User ($user_id);
|
83 |
}
|
84 |
-
|
85 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
86 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
87 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
88 |
$user->remove_cap ($ccap = $cap);
|
89 |
-
|
90 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
91 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
92 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
93 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
94 |
-
|
95 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
96 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
97 |
-
|
98 |
$paypal["s2member_log"][] = "s2Member Custom Capabilities updated w/ advanced update routines.";
|
99 |
-
|
100 |
-
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_capabilities_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_capabilities_email_msg", _x ("Thank you! You now have access to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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=
|
101 |
-
|
102 |
$paypal["s2member_log"][] = "Capability Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
103 |
-
|
104 |
-
if ($processing && $
|
105 |
{
|
106 |
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)))
|
107 |
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)))
|
@@ -118,23 +118,23 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
118 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
119 |
{
|
120 |
if (is_array ($fields) && !empty ($fields))
|
121 |
-
foreach ($fields as $var => $val)
|
122 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
123 |
break;
|
124 |
-
|
125 |
-
if (($url = trim ($url)))
|
126 |
-
|
127 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
128 |
}
|
129 |
}
|
130 |
-
|
131 |
$paypal["s2member_log"][] = "Capability Return, a Proxy Return URL is ready.";
|
132 |
}
|
133 |
-
|
134 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
135 |
{
|
136 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
137 |
-
|
138 |
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)))
|
139 |
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)))
|
140 |
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)))
|
@@ -150,23 +150,23 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
150 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
151 |
{
|
152 |
if (is_array ($fields) && !empty ($fields))
|
153 |
-
foreach ($fields as $var => $val)
|
154 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
155 |
break;
|
156 |
-
|
157 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
158 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
159 |
}
|
160 |
}
|
161 |
-
|
162 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
163 |
}
|
164 |
-
|
165 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
166 |
{
|
167 |
-
$msg = $sbj = "(
|
168 |
-
$msg .= "\n\n";
|
169 |
-
|
170 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
171 |
$msg .= "amount: %%amount%%\n";
|
172 |
$msg .= "txn_id: %%txn_id%%\n";
|
@@ -176,7 +176,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
176 |
$msg .= "last_name: %%last_name%%\n";
|
177 |
$msg .= "full_name: %%full_name%%\n";
|
178 |
$msg .= "payer_email: %%payer_email%%\n";
|
179 |
-
|
180 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
181 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
182 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
@@ -184,11 +184,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
184 |
$msg .= "user_login: %%user_login%%\n";
|
185 |
$msg .= "user_ip: %%user_ip%%\n";
|
186 |
$msg .= "user_id: %%user_id%%\n";
|
187 |
-
|
188 |
if (is_array ($fields) && !empty ($fields))
|
189 |
foreach ($fields as $var => $val)
|
190 |
$msg .= $var . ": %%" . $var . "%%\n";
|
191 |
-
|
192 |
$msg .= "cv0: %%cv0%%\n";
|
193 |
$msg .= "cv1: %%cv1%%\n";
|
194 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -199,7 +199,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
199 |
$msg .= "cv7: %%cv7%%\n";
|
200 |
$msg .= "cv8: %%cv8%%\n";
|
201 |
$msg .= "cv9: %%cv9%%";
|
202 |
-
|
203 |
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)))
|
204 |
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)))
|
205 |
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)))
|
@@ -215,20 +215,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
215 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
216 |
{
|
217 |
if (is_array ($fields) && !empty ($fields))
|
218 |
-
foreach ($fields as $var => $val)
|
219 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
220 |
break;
|
221 |
-
|
222 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
223 |
-
|
224 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
225 |
-
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 ()), "Content-Type: text/plain; charset=
|
226 |
}
|
227 |
}
|
228 |
-
|
229 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
230 |
}
|
231 |
-
|
232 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
233 |
{
|
234 |
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)))
|
@@ -246,11 +246,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
246 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
247 |
{
|
248 |
if (is_array ($fields) && !empty ($fields))
|
249 |
-
foreach ($fields as $var => $val)
|
250 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
251 |
break;
|
252 |
-
|
253 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))))
|
254 |
{
|
255 |
$paypal["s2member_log"][] = "Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.";
|
256 |
set_transient ("s2m_" . md5 ("s2member_transient_ccap_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
@@ -258,10 +258,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
258 |
}
|
259 |
}
|
260 |
}
|
261 |
-
|
262 |
-
|
263 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_new_ccaps", get_defined_vars ());
|
264 |
-
unset
|
265 |
}
|
266 |
else
|
267 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
@@ -272,17 +272,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
|
272 |
else
|
273 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code.";
|
274 |
}
|
275 |
-
else
|
276 |
{
|
277 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
278 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
279 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
280 |
}
|
281 |
-
|
282 |
-
|
283 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_new_ccaps", get_defined_vars ());
|
284 |
-
unset
|
285 |
-
|
286 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level", $paypal, get_defined_vars ());
|
287 |
}
|
288 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110815
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110815
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^web_accept$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
+
&& (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (!empty ($paypal["payer_email"])))
|
49 |
{
|
50 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
51 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_new_ccaps", get_defined_vars ());
|
52 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
53 |
+
|
54 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
57 |
+
|
58 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
+
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
+
|
63 |
+
if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) // Must have this information for Capability additions.
|
64 |
{
|
65 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["txn_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
66 |
{
|
67 |
+
if (!$user->has_cap ("administrator")) // Do NOT process this routine on Administrators.
|
68 |
{
|
69 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
70 |
+
|
71 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
72 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps", get_defined_vars ());
|
73 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
74 |
+
|
75 |
+
$fields = get_user_option ("s2member_custom_fields", $user_id); // These will be needed in the routines below.
|
76 |
+
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); // Original IP during Registration.
|
77 |
+
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally.
|
78 |
+
|
79 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id)) // Must have a Role on this Blog.
|
80 |
{
|
81 |
add_existing_user_to_blog (array ("user_id" => $user_id, "role" => get_option ("default_role")));
|
82 |
$user = new WP_User ($user_id);
|
83 |
}
|
84 |
+
|
85 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
86 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
87 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
88 |
$user->remove_cap ($ccap = $cap);
|
89 |
+
|
90 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
91 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
92 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
93 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
94 |
+
|
95 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
96 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
97 |
+
|
98 |
$paypal["s2member_log"][] = "s2Member Custom Capabilities updated w/ advanced update routines.";
|
99 |
+
|
100 |
+
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_capabilities_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_capabilities_email_msg", _x ("Thank you! You now have access to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\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") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
101 |
+
|
102 |
$paypal["s2member_log"][] = "Capability Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
|
103 |
+
|
104 |
+
if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) // A Proxy is requesting a Return URL?
|
105 |
{
|
106 |
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)))
|
107 |
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)))
|
118 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
119 |
{
|
120 |
if (is_array ($fields) && !empty ($fields))
|
121 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
122 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
123 |
break;
|
124 |
+
|
125 |
+
if (($url = trim ($url))) // Preserve remaining replacements.
|
126 |
+
// Because the parent routine may perform replacements too.
|
127 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
128 |
}
|
129 |
}
|
130 |
+
|
131 |
$paypal["s2member_log"][] = "Capability Return, a Proxy Return URL is ready.";
|
132 |
}
|
133 |
+
|
134 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
135 |
{
|
136 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
|
137 |
+
|
138 |
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)))
|
139 |
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)))
|
140 |
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)))
|
150 |
if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
|
151 |
{
|
152 |
if (is_array ($fields) && !empty ($fields))
|
153 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
154 |
if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
|
155 |
break;
|
156 |
+
|
157 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
158 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
|
163 |
}
|
164 |
+
|
165 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
166 |
{
|
167 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Payment";
|
168 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
169 |
+
|
170 |
$msg .= "subscr_id: %%subscr_id%%\n";
|
171 |
$msg .= "amount: %%amount%%\n";
|
172 |
$msg .= "txn_id: %%txn_id%%\n";
|
176 |
$msg .= "last_name: %%last_name%%\n";
|
177 |
$msg .= "full_name: %%full_name%%\n";
|
178 |
$msg .= "payer_email: %%payer_email%%\n";
|
179 |
+
|
180 |
$msg .= "user_first_name: %%user_first_name%%\n";
|
181 |
$msg .= "user_last_name: %%user_last_name%%\n";
|
182 |
$msg .= "user_full_name: %%user_full_name%%\n";
|
184 |
$msg .= "user_login: %%user_login%%\n";
|
185 |
$msg .= "user_ip: %%user_ip%%\n";
|
186 |
$msg .= "user_id: %%user_id%%\n";
|
187 |
+
|
188 |
if (is_array ($fields) && !empty ($fields))
|
189 |
foreach ($fields as $var => $val)
|
190 |
$msg .= $var . ": %%" . $var . "%%\n";
|
191 |
+
|
192 |
$msg .= "cv0: %%cv0%%\n";
|
193 |
$msg .= "cv1: %%cv1%%\n";
|
194 |
$msg .= "cv2: %%cv2%%\n";
|
199 |
$msg .= "cv7: %%cv7%%\n";
|
200 |
$msg .= "cv8: %%cv8%%\n";
|
201 |
$msg .= "cv9: %%cv9%%";
|
202 |
+
|
203 |
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)))
|
204 |
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)))
|
205 |
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)))
|
215 |
if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
|
216 |
{
|
217 |
if (is_array ($fields) && !empty ($fields))
|
218 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
219 |
if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
|
220 |
break;
|
221 |
+
|
222 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
223 |
+
|
224 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient)
|
225 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
226 |
}
|
227 |
}
|
228 |
+
|
229 |
$paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
|
230 |
}
|
231 |
+
|
232 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
233 |
{
|
234 |
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)))
|
246 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
247 |
{
|
248 |
if (is_array ($fields) && !empty ($fields))
|
249 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
250 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
251 |
break;
|
252 |
+
|
253 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) // This gets stored into a Transient Queue.
|
254 |
{
|
255 |
$paypal["s2member_log"][] = "Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.";
|
256 |
set_transient ("s2m_" . md5 ("s2member_transient_ccap_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
258 |
}
|
259 |
}
|
260 |
}
|
261 |
+
|
262 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
263 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_new_ccaps", get_defined_vars ());
|
264 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
265 |
}
|
266 |
else
|
267 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
|
272 |
else
|
273 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code.";
|
274 |
}
|
275 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
276 |
{
|
277 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
278 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
279 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
280 |
}
|
281 |
+
|
282 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
283 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_new_ccaps", get_defined_vars ());
|
284 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
285 |
+
|
286 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level", $paypal, get_defined_vars ());
|
287 |
}
|
288 |
else
|
includes/classes/paypal-notify-in-web-accept-sp.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,98 +28,98 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_web_accept_sp
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® IPN handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function cp ($vars = array ())
|
42 |
{
|
43 |
-
extract ($vars);
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
47 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
-
&& (!empty ($paypal["payer_email"])) && (!empty ($paypal["txn_id"]))
|
49 |
{
|
50 |
-
|
51 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars ());
|
52 |
-
unset
|
53 |
-
|
54 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
57 |
-
|
58 |
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
-
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
-
|
63 |
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"])))
|
64 |
{
|
65 |
-
$processing = $during = true;
|
66 |
-
|
67 |
-
if (preg_match ("/(referenc|associat)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
68 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["option_selection1"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
69 |
{
|
70 |
$sp_references = (array)get_user_option ("s2member_sp_references", $user_id);
|
71 |
$_sp_reference = array ("time" => time (), "ids" => $paypal["sp_ids"], "hours" => $paypal["hours"], "url" => $sp_access_url);
|
72 |
$sp_references = c_ws_plugin__s2member_utils_arrays::array_unique (array_merge ($sp_references, $_sp_reference));
|
73 |
update_user_option ($user_id, "s2member_sp_references", $sp_references);
|
74 |
-
|
75 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale associated with User ID: " . $user_id . ".";
|
76 |
}
|
77 |
-
|
78 |
-
$sbj = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
79 |
$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);
|
80 |
-
|
81 |
-
$msg = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
82 |
$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);
|
83 |
-
|
84 |
-
$rec = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($
|
85 |
$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);
|
86 |
-
|
87 |
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)))
|
88 |
-
if (($rec = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $rec)))
|
89 |
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)))
|
90 |
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)))
|
91 |
-
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)))
|
92 |
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
93 |
if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
|
94 |
-
|
95 |
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)))
|
96 |
-
if (($sbj = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $sbj)))
|
97 |
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)))
|
98 |
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)))
|
99 |
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
100 |
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
101 |
if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
|
102 |
-
|
103 |
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)))
|
104 |
-
if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg)))
|
105 |
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)))
|
106 |
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)))
|
107 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
108 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
109 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
110 |
-
|
111 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
112 |
{
|
113 |
-
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($rec) as $recipient)
|
114 |
-
c_ws_plugin__s2member_email_configs::email_config () . 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=
|
115 |
-
|
116 |
$paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . $rec . ".";
|
117 |
}
|
118 |
-
|
119 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
120 |
{
|
121 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url)
|
122 |
-
|
123 |
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)))
|
124 |
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)))
|
125 |
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)))
|
@@ -128,18 +128,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
128 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
129 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
130 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
131 |
-
|
132 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
133 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
134 |
-
|
135 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
|
136 |
}
|
137 |
-
|
138 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
139 |
{
|
140 |
-
$msg = $sbj = "(
|
141 |
-
$msg .= "\n\n";
|
142 |
-
|
143 |
$msg .= "sp_access_url: %%sp_access_url%%\n";
|
144 |
$msg .= "sp_access_exp: %%sp_access_exp%%\n";
|
145 |
$msg .= "amount: %%amount%%\n";
|
@@ -151,7 +151,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
151 |
$msg .= "full_name: %%full_name%%\n";
|
152 |
$msg .= "payer_email: %%payer_email%%\n";
|
153 |
$msg .= "user_ip: %%user_ip%%\n";
|
154 |
-
|
155 |
$msg .= "cv0: %%cv0%%\n";
|
156 |
$msg .= "cv1: %%cv1%%\n";
|
157 |
$msg .= "cv2: %%cv2%%\n";
|
@@ -162,7 +162,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
162 |
$msg .= "cv7: %%cv7%%\n";
|
163 |
$msg .= "cv8: %%cv8%%\n";
|
164 |
$msg .= "cv9: %%cv9%%";
|
165 |
-
|
166 |
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)))
|
167 |
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)))
|
168 |
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)))
|
@@ -171,16 +171,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
171 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
172 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
173 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
174 |
-
|
175 |
-
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
176 |
-
|
177 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"]) as $recipient)
|
178 |
-
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 ()), "Content-Type: text/plain; charset=
|
179 |
-
|
180 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
|
181 |
}
|
182 |
-
|
183 |
-
if ($processing && $
|
184 |
{
|
185 |
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)))
|
186 |
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)))
|
@@ -190,14 +190,14 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
190 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
191 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
192 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
193 |
-
|
194 |
-
if (($url = trim ($url)))
|
195 |
-
|
196 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
197 |
-
|
198 |
$paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
|
199 |
}
|
200 |
-
|
201 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
202 |
{
|
203 |
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)))
|
@@ -206,32 +206,32 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
|
206 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
207 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
208 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
209 |
-
|
210 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))))
|
211 |
{
|
212 |
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
213 |
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
214 |
}
|
215 |
}
|
216 |
-
|
217 |
-
|
218 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars ());
|
219 |
-
unset
|
220 |
}
|
221 |
else
|
222 |
$paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?";
|
223 |
}
|
224 |
-
else
|
225 |
{
|
226 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
227 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
228 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
229 |
}
|
230 |
-
|
231 |
-
|
232 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars ());
|
233 |
-
unset
|
234 |
-
|
235 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", $paypal, get_defined_vars ());
|
236 |
}
|
237 |
else
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_notify_in_web_accept_sp
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® IPN handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function cp ($vars = array ()) // Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
42 |
{
|
43 |
+
extract ($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^web_accept$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
47 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
+
&& (!empty ($paypal["payer_email"])) && (!empty ($paypal["txn_id"])))
|
49 |
{
|
50 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
51 |
do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars ());
|
52 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
53 |
+
|
54 |
if (!get_transient ($transient_ipn = "s2m_ipn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_ipn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
57 |
+
|
58 |
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
+
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
+
|
63 |
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"])))
|
64 |
{
|
65 |
+
$processing = $during = true; // Yes, we ARE processing this.
|
66 |
+
|
67 |
+
if (preg_match ("/(referenc|associat)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) // Associating this purchase with a Member?
|
68 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["option_selection1"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
69 |
{
|
70 |
$sp_references = (array)get_user_option ("s2member_sp_references", $user_id);
|
71 |
$_sp_reference = array ("time" => time (), "ids" => $paypal["sp_ids"], "hours" => $paypal["hours"], "url" => $sp_access_url);
|
72 |
$sp_references = c_ws_plugin__s2member_utils_arrays::array_unique (array_merge ($sp_references, $_sp_reference));
|
73 |
update_user_option ($user_id, "s2member_sp_references", $sp_references);
|
74 |
+
|
75 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale associated with User ID: " . $user_id . ".";
|
76 |
}
|
77 |
+
|
78 |
+
$sbj = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_subject"]);
|
79 |
$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);
|
80 |
+
|
81 |
+
$msg = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_message"]);
|
82 |
$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);
|
83 |
+
|
84 |
+
$rec = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_REQUEST["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_recipients"]);
|
85 |
$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);
|
86 |
+
|
87 |
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)))
|
88 |
+
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.
|
89 |
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)))
|
90 |
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)))
|
91 |
+
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>).
|
92 |
if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
|
93 |
if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
|
94 |
+
|
95 |
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)))
|
96 |
+
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.
|
97 |
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)))
|
98 |
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)))
|
99 |
if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
|
100 |
if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
|
101 |
if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
|
102 |
+
|
103 |
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)))
|
104 |
+
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.
|
105 |
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)))
|
106 |
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)))
|
107 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
108 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
109 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
110 |
+
|
111 |
if (($rec = trim (preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
|
112 |
{
|
113 |
+
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($rec) as $recipient) // Go through a possible list of recipients.
|
114 |
+
c_ws_plugin__s2member_email_configs::email_config () . 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") . c_ws_plugin__s2member_email_configs::email_config_release ();
|
115 |
+
|
116 |
$paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . $rec . ".";
|
117 |
}
|
118 |
+
|
119 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
120 |
{
|
121 |
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url)
|
122 |
+
|
123 |
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)))
|
124 |
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)))
|
125 |
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)))
|
128 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
129 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
130 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
131 |
+
|
132 |
if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
|
133 |
c_ws_plugin__s2member_utils_urls::remote ($url);
|
134 |
+
|
135 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
|
136 |
}
|
137 |
+
|
138 |
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
139 |
{
|
140 |
+
$msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Sale";
|
141 |
+
$msg .= "\n\n"; // Spacing in the message body.
|
142 |
+
|
143 |
$msg .= "sp_access_url: %%sp_access_url%%\n";
|
144 |
$msg .= "sp_access_exp: %%sp_access_exp%%\n";
|
145 |
$msg .= "amount: %%amount%%\n";
|
151 |
$msg .= "full_name: %%full_name%%\n";
|
152 |
$msg .= "payer_email: %%payer_email%%\n";
|
153 |
$msg .= "user_ip: %%user_ip%%\n";
|
154 |
+
|
155 |
$msg .= "cv0: %%cv0%%\n";
|
156 |
$msg .= "cv1: %%cv1%%\n";
|
157 |
$msg .= "cv2: %%cv2%%\n";
|
162 |
$msg .= "cv7: %%cv7%%\n";
|
163 |
$msg .= "cv8: %%cv8%%\n";
|
164 |
$msg .= "cv9: %%cv9%%";
|
165 |
+
|
166 |
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)))
|
167 |
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)))
|
168 |
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)))
|
171 |
if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
|
172 |
if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
|
173 |
if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
|
174 |
+
|
175 |
+
if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
|
176 |
+
|
177 |
foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"]) as $recipient)
|
178 |
+
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 ()), "Content-Type: text/plain; charset=UTF-8");
|
179 |
+
|
180 |
$paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
|
181 |
}
|
182 |
+
|
183 |
+
if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) // A Proxy is requesting a Return URL?
|
184 |
{
|
185 |
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)))
|
186 |
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)))
|
190 |
if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
|
191 |
if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
|
192 |
if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
|
193 |
+
|
194 |
+
if (($url = trim ($url))) // Preserve Remaining replacements.
|
195 |
+
// Because the parent routine may perform replacements too.
|
196 |
$paypal["s2member_paypal_proxy_return_url"] = $url;
|
197 |
+
|
198 |
$paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
|
199 |
}
|
200 |
+
|
201 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
202 |
{
|
203 |
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)))
|
206 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
207 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
208 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
209 |
+
|
210 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) // This gets stored into a Transient Queue.
|
211 |
{
|
212 |
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
213 |
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
214 |
}
|
215 |
}
|
216 |
+
|
217 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
218 |
do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars ());
|
219 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
220 |
}
|
221 |
else
|
222 |
$paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?";
|
223 |
}
|
224 |
+
else // Else, this is a duplicate IPN. Must stop here.
|
225 |
{
|
226 |
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
|
227 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
228 |
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
|
229 |
}
|
230 |
+
|
231 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
232 |
do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars ());
|
233 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
234 |
+
|
235 |
return apply_filters ("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", $paypal, get_defined_vars ());
|
236 |
}
|
237 |
else
|
includes/classes/paypal-notify-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® IPN handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® IPN handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 3.5
|
@@ -31,7 +31,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
|
|
31 |
* Handles PayPal® IPN processing.
|
32 |
*
|
33 |
* These same routines also handle s2Member Pro/PayPal® Pro operations;
|
34 |
-
* giving you the ability *(
|
35 |
* WordPress® Hooks/Filters; as seen in the source code below.
|
36 |
*
|
37 |
* Please do NOT modify the source code directly.
|
@@ -49,157 +49,158 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
|
|
49 |
*/
|
50 |
public static function paypal_notify ()
|
51 |
{
|
52 |
-
global
|
53 |
-
|
54 |
do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
|
55 |
-
|
56 |
-
if (!empty ($_GET["s2member_paypal_notify"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty ($
|
57 |
{
|
58 |
-
@ignore_user_abort (true);
|
59 |
-
|
60 |
-
include_once ABSPATH . "wp-admin/includes/admin.php";
|
61 |
-
|
62 |
-
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
|
63 |
-
c_ws_plugin__s2member_email_configs::email_config_release ();
|
64 |
-
|
65 |
if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal) && ($_paypal_s = serialize ($_paypal)))
|
66 |
{
|
67 |
$paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
|
68 |
$paypal["s2member_log"][] = "s2Member POST vars verified " . ((!empty ($paypal["proxy_verified"])) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
69 |
-
|
70 |
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
71 |
-
|
72 |
-
$paypal["subscr_gateway"] = (!empty ($
|
73 |
-
|
74 |
-
if (empty ($paypal["custom"]) && !empty ($paypal["recurring_payment_id"]))
|
75 |
$paypal["custom"] = c_ws_plugin__s2member_utils_users::get_user_custom_with ($paypal["recurring_payment_id"]);
|
76 |
-
|
77 |
if (!empty ($paypal["custom"]) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
78 |
{
|
79 |
$paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
|
80 |
-
|
81 |
-
|
82 |
if (!apply_filters ("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars ()))
|
83 |
{
|
84 |
-
unset
|
85 |
-
|
86 |
if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_virtual_terminal::cp (get_defined_vars ())))
|
87 |
$paypal = $_paypal_cp;
|
88 |
-
|
89 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_express_checkout::cp (get_defined_vars ())))
|
90 |
$paypal = $_paypal_cp;
|
91 |
-
|
92 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_cart::cp (get_defined_vars ())))
|
93 |
$paypal = $_paypal_cp;
|
94 |
-
|
95 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_send_money::cp (get_defined_vars ())))
|
96 |
$paypal = $_paypal_cp;
|
97 |
-
|
98 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_web_accept_sp::cp (get_defined_vars ())))
|
99 |
$paypal = $_paypal_cp;
|
100 |
-
|
101 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level::cp (get_defined_vars ())))
|
102 |
$paypal = $_paypal_cp;
|
103 |
-
|
104 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level::cp (get_defined_vars ())))
|
105 |
$paypal = $_paypal_cp;
|
106 |
-
|
107 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level::cp (get_defined_vars ())))
|
108 |
$paypal = $_paypal_cp;
|
109 |
-
|
110 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level::cp (get_defined_vars ())))
|
111 |
$paypal = $_paypal_cp;
|
112 |
-
|
113 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level::cp (get_defined_vars ())))
|
114 |
$paypal = $_paypal_cp;
|
115 |
-
|
116 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level::cp (get_defined_vars ())))
|
117 |
$paypal = $_paypal_cp;
|
118 |
-
|
119 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level::cp (get_defined_vars ())))
|
120 |
$paypal = $_paypal_cp;
|
121 |
-
|
122 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level::cp (get_defined_vars ())))
|
123 |
$paypal = $_paypal_cp;
|
124 |
-
|
125 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal::cp (get_defined_vars ())))
|
126 |
$paypal = $_paypal_cp;
|
127 |
-
|
128 |
-
else
|
129 |
$paypal["s2member_log"][] = "Ignoring this IPN request. The `txn_type/status` does NOT require any action on the part of s2Member.";
|
130 |
}
|
131 |
-
else
|
132 |
-
unset
|
133 |
}
|
134 |
-
|
135 |
else if (!empty ($paypal["txn_type"]) && preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
|
136 |
{
|
137 |
$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.";
|
138 |
$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.";
|
139 |
}
|
140 |
-
|
141 |
-
else if (!empty ($paypal["txn_type"]) && preg_match ("/^recurring_/i", $paypal["txn_type"]))
|
142 |
$paypal["s2member_log"][] = "Transaction type ( `^recurring_?` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible.";
|
143 |
-
|
144 |
-
else
|
145 |
$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.";
|
146 |
}
|
147 |
-
|
148 |
-
else
|
149 |
{
|
150 |
$paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.";
|
151 |
$paypal["s2member_log"][] = "If you're absolutely SURE that your 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/communicate with your Payment Gateway over an HTTPS connection.";
|
152 |
$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; and instead, set `allow_url_fopen = yes` in your php.ini file. The `cURL` extension (usually) does NOT support SSL connections on a Windows® server.";
|
153 |
$paypal["s2member_log"][] = "Please see this thread: `http://www.s2member.com/forums/topic/ideal-server-configuration-for-s2member/` for details regarding the ideal server configuration for s2Member.";
|
154 |
-
$paypal["s2member_log"][] = var_export ($_REQUEST, true);
|
155 |
}
|
156 |
-
|
157 |
-
if ($email_configs_were_on)
|
158 |
c_ws_plugin__s2member_email_configs::email_config ();
|
159 |
/*
|
160 |
-
Add IPN proxy (
|
161 |
*/
|
162 |
-
if (!empty ($
|
163 |
-
$paypal["s2member_paypal_proxy"] = $
|
164 |
/*
|
165 |
-
Add IPN proxy use vars (
|
166 |
*/
|
167 |
-
if (!empty ($
|
168 |
-
$paypal["s2member_paypal_proxy_use"] = $
|
169 |
/*
|
170 |
-
Also add IPN proxy self-verification (
|
171 |
*/
|
172 |
-
if (!empty ($
|
173 |
-
$paypal["s2member_paypal_proxy_verification"] = $
|
174 |
/*
|
175 |
If debugging/logging is enabled; we need to append ``$paypal`` to the log file.
|
176 |
Logging now supports Multisite Networking as well.
|
177 |
*/
|
|
|
178 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
179 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
180 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
181 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
182 |
$log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
|
183 |
-
|
184 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
185 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
186 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
187 |
-
file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
|
188 |
-
|
189 |
-
|
190 |
do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
|
191 |
-
unset
|
192 |
-
|
193 |
-
status_header (200);
|
194 |
-
header ("Content-Type: text/plain; charset=
|
195 |
-
|
196 |
-
|
197 |
exit (((!empty ($paypal["s2member_paypal_proxy_return_url"])) ? $paypal["s2member_paypal_proxy_return_url"] : ""));
|
198 |
}
|
199 |
-
|
200 |
-
|
201 |
do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
|
202 |
-
unset
|
203 |
}
|
204 |
}
|
205 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® IPN handler (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® IPN handler (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 3.5
|
31 |
* Handles PayPal® IPN processing.
|
32 |
*
|
33 |
* These same routines also handle s2Member Pro/PayPal® Pro operations;
|
34 |
+
* giving you the ability *(as needed)* to Hook into these routines using
|
35 |
* WordPress® Hooks/Filters; as seen in the source code below.
|
36 |
*
|
37 |
* Please do NOT modify the source code directly.
|
49 |
*/
|
50 |
public static function paypal_notify ()
|
51 |
{
|
52 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
53 |
+
|
54 |
do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
|
55 |
+
|
56 |
+
if (!empty ($_GET["s2member_paypal_notify"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty ($_REQUEST["s2member_paypal_proxy"])))
|
57 |
{
|
58 |
+
@ignore_user_abort (true); // Important. Continue processing even if/when the connection is broken by the sending party.
|
59 |
+
|
60 |
+
include_once ABSPATH . "wp-admin/includes/admin.php"; // Get administrative functions. Needed for `wp_delete_user()`.
|
61 |
+
|
62 |
+
$email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (); // Filters on?
|
63 |
+
c_ws_plugin__s2member_email_configs::email_config_release (); // Release s2Member Filters.
|
64 |
+
|
65 |
if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal) && ($_paypal_s = serialize ($_paypal)))
|
66 |
{
|
67 |
$paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
|
68 |
$paypal["s2member_log"][] = "s2Member POST vars verified " . ((!empty ($paypal["proxy_verified"])) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
69 |
+
|
70 |
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
71 |
+
|
72 |
+
$paypal["subscr_gateway"] = (!empty ($_REQUEST["s2member_paypal_proxy"])) ? esc_html (trim (stripslashes ($_REQUEST["s2member_paypal_proxy"]))) : "paypal";
|
73 |
+
|
74 |
+
if (empty ($paypal["custom"]) && !empty ($paypal["recurring_payment_id"])) // Lookup on Recurring Profiles?
|
75 |
$paypal["custom"] = c_ws_plugin__s2member_utils_users::get_user_custom_with ($paypal["recurring_payment_id"]);
|
76 |
+
|
77 |
if (!empty ($paypal["custom"]) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
78 |
{
|
79 |
$paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
|
80 |
+
|
81 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
82 |
if (!apply_filters ("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars ()))
|
83 |
{
|
84 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
85 |
+
|
86 |
if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_virtual_terminal::cp (get_defined_vars ())))
|
87 |
$paypal = $_paypal_cp;
|
88 |
+
|
89 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_express_checkout::cp (get_defined_vars ())))
|
90 |
$paypal = $_paypal_cp;
|
91 |
+
|
92 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_cart::cp (get_defined_vars ())))
|
93 |
$paypal = $_paypal_cp;
|
94 |
+
|
95 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_send_money::cp (get_defined_vars ())))
|
96 |
$paypal = $_paypal_cp;
|
97 |
+
|
98 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_web_accept_sp::cp (get_defined_vars ())))
|
99 |
$paypal = $_paypal_cp;
|
100 |
+
|
101 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level::cp (get_defined_vars ())))
|
102 |
$paypal = $_paypal_cp;
|
103 |
+
|
104 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level::cp (get_defined_vars ())))
|
105 |
$paypal = $_paypal_cp;
|
106 |
+
|
107 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level::cp (get_defined_vars ())))
|
108 |
$paypal = $_paypal_cp;
|
109 |
+
|
110 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level::cp (get_defined_vars ())))
|
111 |
$paypal = $_paypal_cp;
|
112 |
+
|
113 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level::cp (get_defined_vars ())))
|
114 |
$paypal = $_paypal_cp;
|
115 |
+
|
116 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level::cp (get_defined_vars ())))
|
117 |
$paypal = $_paypal_cp;
|
118 |
+
|
119 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level::cp (get_defined_vars ())))
|
120 |
$paypal = $_paypal_cp;
|
121 |
+
|
122 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level::cp (get_defined_vars ())))
|
123 |
$paypal = $_paypal_cp;
|
124 |
+
|
125 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal::cp (get_defined_vars ())))
|
126 |
$paypal = $_paypal_cp;
|
127 |
+
|
128 |
+
else // Ignoring this IPN request. The txn_type/status does NOT require any action.
|
129 |
$paypal["s2member_log"][] = "Ignoring this IPN request. The `txn_type/status` does NOT require any action on the part of s2Member.";
|
130 |
}
|
131 |
+
else // Else a custom conditional has been applied by Filters.
|
132 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
133 |
}
|
134 |
+
|
135 |
else if (!empty ($paypal["txn_type"]) && preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
|
136 |
{
|
137 |
$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.";
|
138 |
$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.";
|
139 |
}
|
140 |
+
|
141 |
+
else if (!empty ($paypal["txn_type"]) && preg_match ("/^recurring_/i", $paypal["txn_type"])) // Otherwise, is this a ^recurring_ txn_type?
|
142 |
$paypal["s2member_log"][] = "Transaction type ( `^recurring_?` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible.";
|
143 |
+
|
144 |
+
else // Else, use the default ``$_SERVER["HTTP_HOST"]`` error.
|
145 |
$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.";
|
146 |
}
|
147 |
+
|
148 |
+
else // Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail.
|
149 |
{
|
150 |
$paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.";
|
151 |
$paypal["s2member_log"][] = "If you're absolutely SURE that your 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/communicate with your Payment Gateway over an HTTPS connection.";
|
152 |
$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; and instead, set `allow_url_fopen = yes` in your php.ini file. The `cURL` extension (usually) does NOT support SSL connections on a Windows® server.";
|
153 |
$paypal["s2member_log"][] = "Please see this thread: `http://www.s2member.com/forums/topic/ideal-server-configuration-for-s2member/` for details regarding the ideal server configuration for s2Member.";
|
154 |
+
$paypal["s2member_log"][] = var_export ($_REQUEST, true); // Recording _POST + _GET vars for analysis and debugging.
|
155 |
}
|
156 |
+
|
157 |
+
if ($email_configs_were_on) // Back on?
|
158 |
c_ws_plugin__s2member_email_configs::email_config ();
|
159 |
/*
|
160 |
+
Add IPN proxy (when available) to the ``$paypal`` array.
|
161 |
*/
|
162 |
+
if (!empty ($_REQUEST["s2member_paypal_proxy"]))
|
163 |
+
$paypal["s2member_paypal_proxy"] = $_REQUEST["s2member_paypal_proxy"];
|
164 |
/*
|
165 |
+
Add IPN proxy use vars (when available) to the ``$paypal`` array.
|
166 |
*/
|
167 |
+
if (!empty ($_REQUEST["s2member_paypal_proxy_use"]))
|
168 |
+
$paypal["s2member_paypal_proxy_use"] = $_REQUEST["s2member_paypal_proxy_use"];
|
169 |
/*
|
170 |
+
Also add IPN proxy self-verification (when available) to the ``$paypal`` array.
|
171 |
*/
|
172 |
+
if (!empty ($_REQUEST["s2member_paypal_proxy_verification"]))
|
173 |
+
$paypal["s2member_paypal_proxy_verification"] = $_REQUEST["s2member_paypal_proxy_verification"];
|
174 |
/*
|
175 |
If debugging/logging is enabled; we need to append ``$paypal`` to the log file.
|
176 |
Logging now supports Multisite Networking as well.
|
177 |
*/
|
178 |
+
$logt = c_ws_plugin__s2member_utilities::time_details ();
|
179 |
$logv = c_ws_plugin__s2member_utilities::ver_details ();
|
180 |
$logm = c_ws_plugin__s2member_utilities::mem_details ();
|
181 |
$log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
|
182 |
$log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
|
183 |
$log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
|
184 |
+
|
185 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
|
186 |
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
187 |
if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
|
188 |
+
file_put_contents ($logs_dir . "/" . $log2, "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
|
189 |
+
|
190 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
191 |
do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
|
192 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
193 |
+
|
194 |
+
status_header (200); // Send a 200 OK status header.
|
195 |
+
header ("Content-Type: text/plain; charset=UTF-8"); // Content-Type text/plain with UTF-8.
|
196 |
+
while (@ob_end_clean ()); // Clean any existing output buffers.
|
197 |
+
|
198 |
exit (((!empty ($paypal["s2member_paypal_proxy_return_url"])) ? $paypal["s2member_paypal_proxy_return_url"] : ""));
|
199 |
}
|
200 |
+
|
201 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
202 |
do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
|
203 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
204 |
}
|
205 |
}
|
206 |
}
|
includes/classes/paypal-notify.inc.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,7 +16,7 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify"))
|
21 |
{
|
22 |
/**
|
@@ -39,7 +39,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify"))
|
|
39 |
*/
|
40 |
public static function paypal_notify ()
|
41 |
{
|
42 |
-
if (!empty ($_GET["s2member_paypal_notify"]))
|
43 |
{
|
44 |
return c_ws_plugin__s2member_paypal_notify_in::paypal_notify ();
|
45 |
}
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_notify"))
|
21 |
{
|
22 |
/**
|
39 |
*/
|
40 |
public static function paypal_notify ()
|
41 |
{
|
42 |
+
if (!empty ($_GET["s2member_paypal_notify"]))
|
43 |
{
|
44 |
return c_ws_plugin__s2member_paypal_notify_in::paypal_notify ();
|
45 |
}
|
includes/classes/paypal-return-in-no-tx-data.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_no_tx_data"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,44 +28,48 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_no_tx_data"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_no_tx_data
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function
|
40 |
{
|
41 |
-
extract
|
42 |
-
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
-
$paypal["s2member_log"][] = "No Return-Data. Customer
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
-
if
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
66 |
do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
|
67 |
-
unset
|
68 |
-
|
69 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_no_tx_data", $paypal, get_defined_vars ());
|
70 |
}
|
71 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_no_tx_data"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_no_tx_data
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
40 |
{
|
41 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
42 |
+
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
+
$paypal["s2member_log"][] = "No Return-Data. Customer MUST wait for Email Confirmation.";
|
48 |
+
$paypal["s2member_log"][] = "Note. This can sometimes happen when/if you are offering an Initial/Trial Period. There are times when a Payment Gateway will NOT supply s2Member with any data immediately after checkout. When/if this happens, s2Member must process the transaction via IPN only (i.e. behind-the-scene), and the Customer must wait for Email Confirmation in these cases.";
|
49 |
+
$paypal["s2member_log"][] = /* Recording _POST + _GET vars for analysis and debugging. */ var_export ($_REQUEST, true);
|
50 |
+
|
51 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
52 |
do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
|
53 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
54 |
+
|
55 |
+
if /* Using a custom success redirection URL? */ ($custom_success_redirection)
|
56 |
+
{
|
57 |
+
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL: " . $custom_success_redirection . ".";
|
58 |
+
|
59 |
+
wp_redirect($custom_success_redirection);
|
60 |
+
}
|
61 |
+
else // Else we use the default redirection URL for this scenario, which is the Home Page.
|
62 |
+
{
|
63 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after asking Customer to check their email).";
|
64 |
+
|
65 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
66 |
+
_x ('<strong>Thank you! (you MUST check your email before proceeding).</strong><br /><br />* Note: It can take <em>(up to 15 minutes)</em> for Email Confirmation with important details. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.', "s2member-front", "s2member") . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] || (c_ws_plugin__s2member_utils_conds::pro_is_installed () && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_" . $paypal["subscr_gateway"] . "_sandbox"]))) ? '<br /><br />' . _x ('<strong>** Sandbox Mode **</strong> You may NOT receive this Email in Sandbox Mode. Sandbox addresses are usually bogus (for testing).', "s2member-front", "s2member") : ''),
|
67 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
68 |
+
}
|
69 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
70 |
do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
|
71 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
72 |
+
|
73 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_no_tx_data", $paypal, get_defined_vars ());
|
74 |
}
|
75 |
}
|
includes/classes/paypal-return-in-proxy-ty-email.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_ty_email"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,41 +28,46 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_ty_email"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_proxy_ty_email
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function
|
40 |
{
|
41 |
-
extract
|
42 |
-
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_ty_email", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
-
$paypal["s2member_log"][] = "Customer
|
48 |
-
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_ty_email", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
-
if
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_ty_email", get_defined_vars ());
|
64 |
-
unset
|
65 |
-
|
66 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_proxy_ty_email", $paypal, get_defined_vars ());
|
67 |
}
|
68 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_ty_email"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_proxy_ty_email
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
40 |
{
|
41 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
42 |
+
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_ty_email", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
+
$paypal["s2member_log"][] = "Customer MUST wait for Email Confirmation — `proxy_use`: ( `ty-email` ).";
|
48 |
+
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_ty_email", get_defined_vars ());
|
51 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
52 |
+
|
53 |
+
if /* Using a custom success redirection URL? */ ($custom_success_redirection)
|
54 |
+
{
|
55 |
+
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection . ".";
|
56 |
+
|
57 |
+
wp_redirect($custom_success_redirection);
|
58 |
+
}
|
59 |
+
else // Else we use the default redirection URL for this scenario, which is the Home Page.
|
60 |
+
{
|
61 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after asking Customer to check their email).";
|
62 |
+
|
63 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
64 |
+
_x ('<strong>Thank you! (you MUST check your email before proceeding).</strong><br /><br />* Note: It can take <em>(up to 15 minutes)</em> for Email Confirmation with important details. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.', "s2member-front", "s2member") . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] || (c_ws_plugin__s2member_utils_conds::pro_is_installed () && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_" . $paypal["subscr_gateway"] . "_sandbox"]))) ? '<br /><br />' . _x ('<strong>** Sandbox Mode **</strong> You may NOT receive this Email in Sandbox Mode. Sandbox addresses are usually bogus (for testing).', "s2member-front", "s2member") : ''),
|
65 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
66 |
+
}
|
67 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
68 |
do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_ty_email", get_defined_vars ());
|
69 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
70 |
+
|
71 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_proxy_ty_email", $paypal, get_defined_vars ());
|
72 |
}
|
73 |
}
|
includes/classes/paypal-return-in-proxy-x-preview.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_x_preview"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,41 +28,46 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_x_preview"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_proxy_x_preview
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*/
|
39 |
-
public static function
|
40 |
{
|
41 |
-
extract
|
42 |
-
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_x_preview", get_defined_vars ());
|
45 |
-
unset
|
46 |
-
|
47 |
$paypal["s2member_log"][] = "Test preview of Return Page `proxy_use`: ( `x_preview` ).";
|
48 |
-
|
49 |
-
|
50 |
do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_x_preview", get_defined_vars ());
|
51 |
-
unset
|
52 |
-
|
53 |
-
if
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_x_preview", get_defined_vars ());
|
64 |
-
unset
|
65 |
-
|
66 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_proxy_x_preview", $paypal, get_defined_vars ());
|
67 |
}
|
68 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_proxy_x_preview"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_proxy_x_preview
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*/
|
39 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
40 |
{
|
41 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
42 |
+
|
43 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
44 |
do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_x_preview", get_defined_vars ());
|
45 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
46 |
+
|
47 |
$paypal["s2member_log"][] = "Test preview of Return Page `proxy_use`: ( `x_preview` ).";
|
48 |
+
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_x_preview", get_defined_vars ());
|
51 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
52 |
+
|
53 |
+
if /* Using a custom success redirection URL? */ ($custom_success_redirection)
|
54 |
+
{
|
55 |
+
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection . ".";
|
56 |
+
|
57 |
+
wp_redirect($custom_success_redirection);
|
58 |
+
}
|
59 |
+
else // Else we use the default redirection URL for this scenario, which is the Home Page.
|
60 |
+
{
|
61 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying preview information).";
|
62 |
+
|
63 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
64 |
+
sprintf (_x ('<strong>Thank you! (this is a preview, no action necessary).</strong><br /><br />* Note: each of your Customers are returned back to your site immediately after they complete checkout. This Return Page displays a message and instructions for the Customer. s2Member may change the message and instructions dynamically, based on what the Customer is actually doing <em>(i.e. based on the type of transaction that is taking place)</em>.<br /><br /><em>* With <a href="%s" target="_blank">s2Member Pro</a> installed, it is possible to customize this Return Page in various ways.</em>', "s2member-front", "s2member"), esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Pro Module / Prices"))),
|
65 |
+
_x ("Continue (Click Here)", "s2member-front", "s2member"), home_url ("/"));
|
66 |
+
}
|
67 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
68 |
do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_x_preview", get_defined_vars ());
|
69 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
70 |
+
|
71 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_proxy_x_preview", $paypal, get_defined_vars ());
|
72 |
}
|
73 |
}
|
includes/classes/paypal-return-in-subscr-modify-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,117 +28,117 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level")
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function
|
42 |
{
|
43 |
-
extract
|
44 |
-
|
45 |
-
if(
|
46 |
-
&& (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (!empty($paypal["subscr_id"]))
|
48 |
{
|
49 |
-
|
50 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars());
|
51 |
-
unset
|
52 |
-
|
53 |
if(!get_transient($transient_rtn = "s2m_rtn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ), a Subscription Modification.";
|
56 |
-
|
57 |
list($paypal["level"], $paypal["ccaps"]/*, $paypal["eotper"] */) = preg_split("/\:/", $paypal["item_number"], 2);
|
58 |
-
|
59 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
62 |
-
|
63 |
-
$paypal["period1"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] :
|
64 |
-
$paypal["mc_amount1"] = (strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
65 |
-
|
66 |
-
if(preg_match("/^web_accept$/i", $paypal["txn_type"]))
|
67 |
{
|
68 |
-
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] :
|
69 |
-
$paypal["mc_amount3"] =
|
70 |
}
|
71 |
-
|
72 |
-
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] :
|
73 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
74 |
-
$paypal["regular"] =
|
75 |
-
$paypal["regular_term"] =
|
76 |
-
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
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)
|
81 |
{
|
82 |
-
if
|
83 |
{
|
84 |
-
$processing = $modifying = $during =
|
85 |
-
|
86 |
-
|
87 |
do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_modify", get_defined_vars());
|
88 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level".$paypal["level"]);
|
89 |
-
unset
|
90 |
-
|
91 |
-
$fields =
|
92 |
-
$user_reg_ip =
|
93 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
94 |
-
|
95 |
-
if(is_multisite() && !is_user_member_of_blog($user_id)
|
96 |
{
|
97 |
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level".$paypal["level"]));
|
98 |
-
$user =
|
99 |
}
|
100 |
-
/**/
|
101 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
102 |
-
|
103 |
-
if($current_role !== "s2member_level".$paypal["level"])
|
104 |
-
$user->set_role("s2member_level".$paypal["level"]);
|
105 |
-
|
106 |
if($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"])))
|
107 |
foreach($user->allcaps as $cap => $cap_enabled)
|
108 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
109 |
$user->remove_cap($ccap = $cap);
|
110 |
-
|
111 |
if($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"])))
|
112 |
foreach(preg_split("/[\r\n\t\s;,]+/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap)
|
113 |
if(strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap)))))
|
114 |
$user->add_cap("access_s2member_ccap_".$ccap);
|
115 |
-
|
116 |
update_user_option($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
117 |
update_user_option($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
118 |
update_user_option($user_id, "s2member_custom", $paypal["custom"]);
|
119 |
-
|
120 |
if(!get_user_option("s2member_registration_ip", $user_id))
|
121 |
update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]);
|
122 |
-
|
123 |
update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
124 |
-
|
125 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
126 |
-
|
127 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
128 |
-
|
129 |
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
|
130 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time() : $pr_times["level"];
|
131 |
$pr_times["level".$paypal["level"]] = (!$pr_times["level".$paypal["level"]]) ? time() : $pr_times["level".$paypal["level"]];
|
132 |
-
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
|
133 |
-
|
134 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Demoted by s2Member\:/");
|
135 |
-
|
|
|
136 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on ( `subscr_modify` ), a Subscription Modification.";
|
137 |
-
|
138 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
139 |
-
|
140 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `subscr_modify` ), a Subscription Modification.";
|
141 |
-
|
142 |
if($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
143 |
{
|
144 |
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)))
|
@@ -157,11 +157,11 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level")
|
|
157 |
if(($code = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $code)))
|
158 |
{
|
159 |
if(is_array($fields) && !empty($fields))
|
160 |
-
foreach($fields as $var => $val)
|
161 |
if(!($code = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $code)))
|
162 |
break;
|
163 |
-
|
164 |
-
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code)))
|
165 |
{
|
166 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
167 |
set_transient("s2m_".md5("s2member_transient_modification_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
@@ -169,67 +169,64 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level")
|
|
169 |
}
|
170 |
}
|
171 |
}
|
172 |
-
|
173 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
174 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars());
|
175 |
-
unset
|
176 |
-
|
177 |
if(($redirection_url_after_modification = apply_filters("ws_plugin__s2member_redirection_url_after_modification", false, get_defined_vars())))
|
178 |
{
|
179 |
$paypal["s2member_log"][] = "Redirecting this Member to a custom URL after modification: ".$redirection_url_after_modification;
|
180 |
-
|
181 |
wp_redirect($redirection_url_after_modification);
|
182 |
}
|
183 |
-
else
|
184 |
{
|
185 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in.";
|
186 |
-
|
187 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
188 |
-
|
189 |
-
|
190 |
}
|
191 |
}
|
192 |
-
else
|
193 |
{
|
194 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The 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.";
|
195 |
-
|
196 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
197 |
-
|
198 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
199 |
-
|
200 |
-
|
201 |
}
|
202 |
}
|
203 |
-
else
|
204 |
{
|
205 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
206 |
-
|
207 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
208 |
-
|
209 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
210 |
-
|
211 |
-
|
212 |
}
|
213 |
}
|
214 |
-
else
|
215 |
{
|
216 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
217 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as `subscr_modify`.";
|
218 |
-
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page.";
|
219 |
-
|
220 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
221 |
-
|
222 |
-
|
223 |
}
|
224 |
-
|
225 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
226 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars());
|
227 |
-
unset
|
228 |
-
|
229 |
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level", $paypal, get_defined_vars());
|
230 |
}
|
231 |
-
else
|
232 |
-
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level", false, get_defined_vars());
|
233 |
}
|
234 |
}
|
235 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp($vars = array())
|
42 |
{
|
43 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
44 |
+
|
45 |
+
if((!empty($paypal["txn_type"]) && preg_match("/^subscr_modify$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (!empty($paypal["subscr_id"])))
|
48 |
{
|
49 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
50 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars());
|
51 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
52 |
+
|
53 |
if(!get_transient($transient_rtn = "s2m_rtn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10))
|
54 |
{
|
55 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ), a Subscription Modification.";
|
56 |
+
|
57 |
list($paypal["level"], $paypal["ccaps"]/*, $paypal["eotper"] */) = preg_split("/\:/", $paypal["item_number"], 2);
|
58 |
+
|
59 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
60 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
61 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
62 |
+
|
63 |
+
$paypal["period1"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
64 |
+
$paypal["mc_amount1"] = (strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
65 |
+
|
66 |
+
if /* Conversions for Lifetime & Fixed-Term sales. */(preg_match("/^web_accept$/i", $paypal["txn_type"]))
|
67 |
{
|
68 |
+
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : /* 1 Lifetime. */ "1 L";
|
69 |
+
$paypal["mc_amount3"] = /* The "Buy Now" amount is the full gross. */ $paypal["mc_gross"];
|
70 |
}
|
71 |
+
|
72 |
+
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
73 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
74 |
+
$paypal["regular"] = /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */ $paypal["mc_amount3"];
|
75 |
+
$paypal["regular_term"] = /* This is just set to keep a standard; this way both initial_term & regular_term are available. */ $paypal["period3"];
|
76 |
+
$paypal["recurring"] = /* If non-recurring, this should be zero, otherwise Regular. */ ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
77 |
+
|
78 |
+
$ipn_signup_vars = $paypal; /* Create array of wouldbe IPN signup vars w/o s2member_log. */ unset($ipn_signup_vars["s2member_log"]);
|
79 |
+
|
80 |
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)
|
81 |
{
|
82 |
+
if /* Do NOT process this routine on Administrators. */(!$user->has_cap("administrator"))
|
83 |
{
|
84 |
+
$processing = $modifying = $during = /* Yes, we ARE processing this. */ true;
|
85 |
+
|
86 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
87 |
do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_modify", get_defined_vars());
|
88 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level".$paypal["level"]);
|
89 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
90 |
+
|
91 |
+
$fields = /* These will be needed in the routines below. */ get_user_option("s2member_custom_fields", $user_id);
|
92 |
+
$user_reg_ip = /* Original IP during Registration. */ get_user_option("s2member_registration_ip", $user_id);
|
93 |
+
$user_reg_ip = $paypal["ip"] = /* Now merge conditionally. */ ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
94 |
+
|
95 |
+
if(is_multisite() && !is_user_member_of_blog($user_id) /* Must have a Role on this Blog. */)
|
96 |
{
|
97 |
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level".$paypal["level"]));
|
98 |
+
$user = /* Now update the $user object we're using. */ new WP_User($user_id);
|
99 |
}
|
|
|
100 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
101 |
+
|
102 |
+
if /* Only if we need to. */($current_role !== "s2member_level".$paypal["level"])
|
103 |
+
$user->set_role /* (upgrade/downgrade) */("s2member_level".$paypal["level"]);
|
104 |
+
|
105 |
if($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"])))
|
106 |
foreach($user->allcaps as $cap => $cap_enabled)
|
107 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
108 |
$user->remove_cap($ccap = $cap);
|
109 |
+
|
110 |
if($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"])))
|
111 |
foreach(preg_split("/[\r\n\t\s;,]+/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap)
|
112 |
if(strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap)))))
|
113 |
$user->add_cap("access_s2member_ccap_".$ccap);
|
114 |
+
|
115 |
update_user_option($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
116 |
update_user_option($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
117 |
update_user_option($user_id, "s2member_custom", $paypal["custom"]);
|
118 |
+
|
119 |
if(!get_user_option("s2member_registration_ip", $user_id))
|
120 |
update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]);
|
121 |
+
|
122 |
update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
123 |
+
|
124 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
125 |
+
|
126 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
127 |
+
|
128 |
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
|
129 |
+
$pr_times["level"] = /* Preserve existing. */ (!$pr_times["level"]) ? time() : $pr_times["level"];
|
130 |
$pr_times["level".$paypal["level"]] = (!$pr_times["level".$paypal["level"]]) ? time() : $pr_times["level".$paypal["level"]];
|
131 |
+
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
|
132 |
+
|
133 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Demoted by s2Member\:/");
|
134 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Paid Subscr\. ID @ time of demotion\:/");
|
135 |
+
|
136 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on ( `subscr_modify` ), a Subscription Modification.";
|
137 |
+
|
138 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
139 |
+
|
140 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `subscr_modify` ), a Subscription Modification.";
|
141 |
+
|
142 |
if($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
143 |
{
|
144 |
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)))
|
157 |
if(($code = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $code)))
|
158 |
{
|
159 |
if(is_array($fields) && !empty($fields))
|
160 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
161 |
if(!($code = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $code)))
|
162 |
break;
|
163 |
+
|
164 |
+
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
165 |
{
|
166 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
167 |
set_transient("s2m_".md5("s2member_transient_modification_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
169 |
}
|
170 |
}
|
171 |
}
|
172 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
173 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars());
|
174 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
175 |
+
|
176 |
if(($redirection_url_after_modification = apply_filters("ws_plugin__s2member_redirection_url_after_modification", false, get_defined_vars())))
|
177 |
{
|
178 |
$paypal["s2member_log"][] = "Redirecting this Member to a custom URL after modification: ".$redirection_url_after_modification;
|
179 |
+
|
180 |
wp_redirect($redirection_url_after_modification);
|
181 |
}
|
182 |
+
else // Else, use standard/default handling in this scenario. Have the Customer log in again.
|
183 |
{
|
184 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page (after displaying a quick thank-you message). They need to log back in.";
|
185 |
+
|
186 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
187 |
+
'<strong>'._x("Thank you! You've been updated to:", "s2member-front", "s2member").'<br /><em>'.esc_html($paypal["item_name"]).'</em></strong>',
|
188 |
+
_x("Please Log Back In (Click Here)", "s2member-front", "s2member"), wp_login_url());
|
189 |
}
|
190 |
}
|
191 |
+
else // Else, unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here.
|
192 |
{
|
193 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The 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.";
|
194 |
+
|
195 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
196 |
+
|
197 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
198 |
+
_x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />The 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.', "s2member-front", "s2member"),
|
199 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
200 |
}
|
201 |
}
|
202 |
+
else // Unable to modify Subscription. Could not get the existing User ID from the DB.
|
203 |
{
|
204 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
205 |
+
|
206 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
207 |
+
|
208 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
209 |
+
_x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', "s2member-front", "s2member"),
|
210 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
211 |
}
|
212 |
}
|
213 |
+
else // Page Expired. Duplicate Return-Data.
|
214 |
{
|
215 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
216 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as `subscr_modify`.";
|
217 |
+
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page (after displaying an error message).";
|
218 |
+
|
219 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
220 |
+
_x('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"),
|
221 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
222 |
}
|
223 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
224 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars());
|
225 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
226 |
+
|
227 |
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level", $paypal, get_defined_vars());
|
228 |
}
|
229 |
+
else return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level", false, get_defined_vars());
|
|
|
230 |
}
|
231 |
}
|
232 |
}
|
includes/classes/paypal-return-in-subscr-or-wa-w-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,166 +28,164 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function
|
42 |
{
|
43 |
-
extract
|
44 |
-
|
45 |
-
if(
|
46 |
-
&& (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (!empty($paypal["subscr_id"]) || (!empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])))
|
48 |
-
&& (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"]))
|
49 |
{
|
50 |
-
|
51 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars());
|
52 |
-
unset
|
53 |
-
|
54 |
if(!get_transient($transient_rtn = "s2m_rtn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
|
57 |
-
|
58 |
list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\:/", $paypal["item_number"], 3);
|
59 |
-
|
60 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
-
|
64 |
-
if(
|
65 |
-
&& (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET["s2member_paypal_return_tra"])))) && is_array($tra = maybe_unserialize($tra)))
|
66 |
-
&& (count($tra) === 11 && isset($tra["ta"], $tra["tp"], $tra["tt"], $tra["ra"], $tra["rp"], $tra["rt"], $tra["rr"], $tra["rrt"], $tra["rra"], $tra["invoice"], $tra["checksum"]))
|
67 |
-
&& ($tra["invoice"] === $paypal["invoice"]) && ($tra["checksum"] === md5($paypal["invoice"].$paypal["ip"].$paypal["item_number"]))
|
68 |
{
|
69 |
-
$tracking_properties =
|
70 |
-
|
71 |
$paypal["period1"] = ($tra["rr"] !== "BN" && $tra["tp"]) ? $tra["tp"]." ".$tra["tt"] : "0 D";
|
72 |
$paypal["mc_amount1"] = ($tra["rr"] !== "BN" && $tra["tp"]) ? number_format($tra["ta"], 2, ".", "") : "0.00";
|
73 |
-
|
74 |
$paypal["period3"] = $tra["rp"]." ".$tra["rt"];
|
75 |
$paypal["mc_amount3"] = $tra["ra"];
|
76 |
-
|
77 |
$paypal["recurring"] = ($tra["rr"] === "1") ? "1" : "0";
|
78 |
-
|
79 |
-
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] :
|
80 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
81 |
-
$paypal["regular"] =
|
82 |
-
$paypal["regular_term"] =
|
83 |
-
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
84 |
-
|
85 |
-
|
86 |
}
|
87 |
else if(preg_match("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))
|
88 |
{
|
89 |
-
$tracking_properties =
|
90 |
-
|
91 |
-
$paypal["period1"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] :
|
92 |
-
$paypal["mc_amount1"] = (strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
93 |
-
|
94 |
-
if(preg_match("/^web_accept$/i", $paypal["txn_type"])
|
95 |
{
|
96 |
-
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] :
|
97 |
-
$paypal["mc_amount3"] =
|
98 |
}
|
99 |
-
|
100 |
-
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
|
101 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
102 |
-
$paypal["regular"] =
|
103 |
-
$paypal["regular_term"] =
|
104 |
-
$paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
105 |
-
|
106 |
-
|
107 |
}
|
108 |
/*
|
109 |
-
New Subscription with advanced update vars (
|
110 |
*/
|
111 |
if(preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
112 |
{
|
113 |
-
|
114 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars());
|
115 |
-
unset
|
116 |
-
|
117 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
|
118 |
-
|
119 |
-
/* Check for both the old & new subscr_id's, just in case the IPN routine already changed it. */
|
120 |
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)
|
121 |
{
|
122 |
-
if(!$user->has_cap("administrator")
|
123 |
{
|
124 |
-
$processing = $modifying = $during =
|
125 |
-
|
126 |
-
|
127 |
do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_signup_w_update_vars", get_defined_vars());
|
128 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level".$paypal["level"]);
|
129 |
-
unset
|
130 |
-
|
131 |
-
$fields =
|
132 |
-
$user_reg_ip =
|
133 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
134 |
-
|
135 |
-
if(is_multisite() && !is_user_member_of_blog($user_id)
|
136 |
{
|
137 |
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level".$paypal["level"]));
|
138 |
$user = new WP_User($user_id);
|
139 |
}
|
140 |
-
/**/
|
141 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
142 |
-
|
143 |
-
if($current_role !== "s2member_level".$paypal["level"])
|
144 |
-
$user->set_role("s2member_level".$paypal["level"]);
|
145 |
-
|
146 |
if($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"])))
|
147 |
foreach($user->allcaps as $cap => $cap_enabled)
|
148 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
149 |
$user->remove_cap($ccap = $cap);
|
150 |
-
|
151 |
if($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"])))
|
152 |
foreach(preg_split("/[\r\n\t\s;,]+/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap)
|
153 |
if(strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap)))))
|
154 |
$user->add_cap("access_s2member_ccap_".$ccap);
|
155 |
-
|
156 |
update_user_option($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
157 |
update_user_option($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
158 |
update_user_option($user_id, "s2member_custom", $paypal["custom"]);
|
159 |
-
|
160 |
if(!get_user_option("s2member_registration_ip", $user_id))
|
161 |
update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]);
|
162 |
-
|
163 |
if( /* We should have these from the routines above. */!empty($ipn_signup_vars))
|
164 |
update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
165 |
-
|
166 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
167 |
-
|
168 |
if(preg_match("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
169 |
{
|
170 |
-
|
171 |
-
|
172 |
$eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $paypal["eotper"], "", get_user_option("s2member_auto_eot_time", $user_id));
|
173 |
-
$paypal["s2member_log"][] = "Automatic EOT (
|
174 |
}
|
175 |
-
else
|
176 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
177 |
-
|
178 |
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
|
179 |
-
$pr_times["level"] = (!$pr_times["level"]) ? time() : $pr_times["level"];
|
180 |
$pr_times["level".$paypal["level"]] = (!$pr_times["level".$paypal["level"]]) ? time() : $pr_times["level".$paypal["level"]];
|
181 |
-
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
|
182 |
-
|
183 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Demoted by s2Member\:/");
|
184 |
-
|
|
|
185 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
186 |
-
|
187 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
188 |
-
|
189 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
|
190 |
-
|
191 |
if($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
192 |
{
|
193 |
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)))
|
@@ -206,11 +204,11 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
|
206 |
if(($code = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $code)))
|
207 |
{
|
208 |
if(is_array($fields) && !empty($fields))
|
209 |
-
foreach($fields as $var => $val)
|
210 |
if(!($code = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $code)))
|
211 |
break;
|
212 |
-
|
213 |
-
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code)))
|
214 |
{
|
215 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
216 |
set_transient("s2m_".md5("s2member_transient_modification_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
@@ -218,76 +216,74 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
|
218 |
}
|
219 |
}
|
220 |
}
|
221 |
-
|
222 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
223 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars());
|
224 |
-
unset
|
225 |
-
|
226 |
if(($redirection_url_after_modification = apply_filters("ws_plugin__s2member_redirection_url_after_modification", false, get_defined_vars())))
|
227 |
{
|
228 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after modification: ".$redirection_url_after_modification;
|
229 |
-
|
230 |
wp_redirect($redirection_url_after_modification);
|
231 |
}
|
232 |
-
else
|
233 |
{
|
234 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in.";
|
235 |
-
|
236 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
237 |
-
|
238 |
-
|
239 |
}
|
240 |
}
|
241 |
-
else
|
242 |
{
|
243 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The 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.";
|
244 |
-
|
245 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
246 |
-
|
247 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
248 |
-
|
249 |
-
|
250 |
}
|
251 |
}
|
252 |
-
else
|
253 |
{
|
254 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
255 |
-
|
256 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
257 |
-
|
258 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
259 |
-
|
260 |
-
|
261 |
}
|
262 |
-
|
263 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
264 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars());
|
265 |
-
unset
|
266 |
}
|
267 |
/*
|
268 |
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
269 |
*/
|
270 |
-
else
|
271 |
{
|
272 |
-
|
273 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars());
|
274 |
-
unset
|
275 |
-
|
276 |
-
$processing = $during =
|
277 |
-
|
278 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
279 |
-
|
280 |
setcookie("s2member_subscr_gateway", ($s2member_subscr_gateway = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_gateway"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_subscr_gateway", $s2member_subscr_gateway, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_subscr_gateway"] = $s2member_subscr_gateway);
|
281 |
setcookie("s2member_subscr_id", ($s2member_subscr_id = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_subscr_id", $s2member_subscr_id, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_subscr_id"] = $s2member_subscr_id);
|
282 |
setcookie("s2member_custom", ($s2member_custom = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["custom"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_custom", $s2member_custom, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_custom"] = $s2member_custom);
|
283 |
setcookie("s2member_item_number", ($s2member_item_number = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["item_number"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_item_number", $s2member_item_number, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_item_number"] = $s2member_item_number);
|
284 |
-
|
285 |
$paypal["s2member_log"][] = "Registration Cookies set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
286 |
-
|
287 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
288 |
-
|
289 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
290 |
-
|
291 |
if($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
292 |
{
|
293 |
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)))
|
@@ -298,89 +294,85 @@ if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
|
298 |
if(($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"]." ".$paypal["last_name"])), $code)))
|
299 |
if(($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)))
|
300 |
if(($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $code)))
|
301 |
-
|
302 |
-
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code)))
|
303 |
{
|
304 |
$paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
|
305 |
set_transient("s2m_".md5("s2member_transient_signup_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
306 |
}
|
307 |
}
|
308 |
-
|
309 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
310 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars());
|
311 |
-
unset
|
312 |
-
|
313 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site())
|
314 |
{
|
315 |
if(($redirection_url_after_mms_farm_signup = apply_filters("ws_plugin__s2member_redirection_url_after_mms_farm_signup", false, get_defined_vars())))
|
316 |
{
|
317 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after signup: ".$redirection_url_after_mms_farm_signup;
|
318 |
-
|
319 |
wp_redirect($redirection_url_after_mms_farm_signup);
|
320 |
}
|
321 |
-
else if
|
322 |
{
|
323 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: ".$custom_success_redirection;
|
324 |
-
|
325 |
wp_redirect($custom_success_redirection);
|
326 |
}
|
327 |
-
else
|
328 |
{
|
329 |
-
$paypal["s2member_log"][] = "Redirecting Customer to Signup Page. They need to Signup/Register now.";
|
330 |
-
|
331 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
332 |
-
|
333 |
-
|
334 |
}
|
335 |
}
|
336 |
-
else
|
337 |
{
|
338 |
if(($redirection_url_after_signup = apply_filters("ws_plugin__s2member_redirection_url_after_signup", false, get_defined_vars())))
|
339 |
{
|
340 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after signup: ".$redirection_url_after_signup;
|
341 |
-
|
342 |
wp_redirect($redirection_url_after_signup);
|
343 |
}
|
344 |
-
else if
|
345 |
{
|
346 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: ".$custom_success_redirection;
|
347 |
-
|
348 |
wp_redirect($custom_success_redirection);
|
349 |
}
|
350 |
-
else
|
351 |
{
|
352 |
-
$paypal["s2member_log"][] = "Redirecting Customer to Registration Page. They need to Register now.";
|
353 |
-
|
354 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
355 |
-
|
356 |
-
|
357 |
}
|
358 |
}
|
359 |
-
|
360 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
361 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars());
|
362 |
-
unset
|
363 |
}
|
364 |
}
|
365 |
-
else
|
366 |
{
|
367 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
368 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
|
369 |
-
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page.";
|
370 |
-
|
371 |
-
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"]
|
372 |
-
|
373 |
-
|
374 |
}
|
375 |
-
|
376 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
377 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars());
|
378 |
-
unset
|
379 |
-
|
380 |
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level", $paypal, get_defined_vars());
|
381 |
}
|
382 |
-
else
|
383 |
-
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level", false, get_defined_vars());
|
384 |
}
|
385 |
}
|
386 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if(!class_exists("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp($vars = array())
|
42 |
{
|
43 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
44 |
+
|
45 |
+
if((!empty($paypal["txn_type"]) && preg_match("/^(web_accept|subscr_signup|subscr_payment)$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (!empty($paypal["subscr_id"]) || (!empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])))
|
48 |
+
&& (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])))
|
49 |
{
|
50 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
51 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars());
|
52 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
53 |
+
|
54 |
if(!get_transient($transient_rtn = "s2m_rtn_".md5("s2member_transient_".$_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
|
57 |
+
|
58 |
list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\:/", $paypal["item_number"], 3);
|
59 |
+
|
60 |
$paypal["ip"] = (preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
+
|
64 |
+
if((preg_match("/^subscr_payment$/i", $paypal["txn_type"]) && !empty($_GET["s2member_paypal_return_tra"]))
|
65 |
+
&& (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET["s2member_paypal_return_tra"])))) && is_array($tra = maybe_unserialize($tra)))
|
66 |
+
&& (count($tra) === 11 && isset($tra["ta"], $tra["tp"], $tra["tt"], $tra["ra"], $tra["rp"], $tra["rt"], $tra["rr"], $tra["rrt"], $tra["rra"], $tra["invoice"], $tra["checksum"]))
|
67 |
+
&& ($tra["invoice"] === $paypal["invoice"]) && ($tra["checksum"] === md5($paypal["invoice"].$paypal["ip"].$paypal["item_number"])))
|
68 |
{
|
69 |
+
$tracking_properties = /* Yes, these tracking properties ARE being set here. */ true;
|
70 |
+
|
71 |
$paypal["period1"] = ($tra["rr"] !== "BN" && $tra["tp"]) ? $tra["tp"]." ".$tra["tt"] : "0 D";
|
72 |
$paypal["mc_amount1"] = ($tra["rr"] !== "BN" && $tra["tp"]) ? number_format($tra["ta"], 2, ".", "") : "0.00";
|
73 |
+
|
74 |
$paypal["period3"] = $tra["rp"]." ".$tra["rt"];
|
75 |
$paypal["mc_amount3"] = $tra["ra"];
|
76 |
+
|
77 |
$paypal["recurring"] = ($tra["rr"] === "1") ? "1" : "0";
|
78 |
+
|
79 |
+
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
80 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
81 |
+
$paypal["regular"] = /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */ $paypal["mc_amount3"];
|
82 |
+
$paypal["regular_term"] = /* This is just set to keep a standard; this way both initial_term & regular_term are available. */ $paypal["period3"];
|
83 |
+
$paypal["recurring"] = /* If non-recurring, this should be zero, otherwise Regular. */ ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
84 |
+
|
85 |
+
$ipn_signup_vars = $paypal; /* Create array of wouldbe IPN signup vars w/o s2member_log. */ unset($ipn_signup_vars["s2member_log"]);
|
86 |
}
|
87 |
else if(preg_match("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))
|
88 |
{
|
89 |
+
$tracking_properties = /* Yes, these tracking properties ARE being set here. */ true;
|
90 |
+
|
91 |
+
$paypal["period1"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
92 |
+
$paypal["mc_amount1"] = (strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00";
|
93 |
+
|
94 |
+
if(preg_match("/^web_accept$/i", $paypal["txn_type"]) /* Conversions for Lifetime & Fixed-Term sales. */)
|
95 |
{
|
96 |
+
$paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : /* 1 Lifetime. */ "1 L";
|
97 |
+
$paypal["mc_amount3"] = /* The "Buy Now" amount is the full gross. */ $paypal["mc_gross"];
|
98 |
}
|
99 |
+
$paypal["initial_term"] = (preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : /* Defaults to "0 D" (zero days). */ "0 D";
|
|
|
100 |
$paypal["initial"] = (strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
|
101 |
+
$paypal["regular"] = /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal®. */ $paypal["mc_amount3"];
|
102 |
+
$paypal["regular_term"] = /* This is just set to keep a standard; this way both initial_term & regular_term are available. */ $paypal["period3"];
|
103 |
+
$paypal["recurring"] = /* If non-recurring, this should be zero, otherwise Regular. */ ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0";
|
104 |
+
|
105 |
+
$ipn_signup_vars = $paypal; /* Create array of wouldbe IPN signup vars w/o s2member_log. */ unset($ipn_signup_vars["s2member_log"]);
|
106 |
}
|
107 |
/*
|
108 |
+
New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications.
|
109 |
*/
|
110 |
if(preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
111 |
{
|
112 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
113 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars());
|
114 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
115 |
+
|
116 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
|
117 |
+
|
|
|
118 |
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)
|
119 |
{
|
120 |
+
if(!$user->has_cap("administrator") /* Do NOT process this routine on Administrators. */)
|
121 |
{
|
122 |
+
$processing = $modifying = $during = /* Yes, we ARE processing this. */ true;
|
123 |
+
|
124 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
125 |
do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_signup_w_update_vars", get_defined_vars());
|
126 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level".$paypal["level"]);
|
127 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
128 |
+
|
129 |
+
$fields = /* These will be needed in the routines below. */ get_user_option("s2member_custom_fields", $user_id);
|
130 |
+
$user_reg_ip = /* Original IP during Registration. */ get_user_option("s2member_registration_ip", $user_id);
|
131 |
+
$user_reg_ip = $paypal["ip"] = /* Now merge conditionally. */ ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
132 |
+
|
133 |
+
if(is_multisite() && !is_user_member_of_blog($user_id) /* Must have a Role on this Blog. */)
|
134 |
{
|
135 |
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level".$paypal["level"]));
|
136 |
$user = new WP_User($user_id);
|
137 |
}
|
|
|
138 |
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
|
139 |
+
|
140 |
+
if /* Only if we need to. */($current_role !== "s2member_level".$paypal["level"])
|
141 |
+
$user->set_role /* (upgrade/downgrade) */("s2member_level".$paypal["level"]);
|
142 |
+
|
143 |
if($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"])))
|
144 |
foreach($user->allcaps as $cap => $cap_enabled)
|
145 |
if(preg_match("/^access_s2member_ccap_/", $cap))
|
146 |
$user->remove_cap($ccap = $cap);
|
147 |
+
|
148 |
if($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"])))
|
149 |
foreach(preg_split("/[\r\n\t\s;,]+/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap)
|
150 |
if(strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap)))))
|
151 |
$user->add_cap("access_s2member_ccap_".$ccap);
|
152 |
+
|
153 |
update_user_option($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
|
154 |
update_user_option($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
|
155 |
update_user_option($user_id, "s2member_custom", $paypal["custom"]);
|
156 |
+
|
157 |
if(!get_user_option("s2member_registration_ip", $user_id))
|
158 |
update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]);
|
159 |
+
|
160 |
if( /* We should have these from the routines above. */!empty($ipn_signup_vars))
|
161 |
update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
|
162 |
+
|
163 |
delete_user_option($user_id, "s2member_file_download_access_log");
|
164 |
+
|
165 |
if(preg_match("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
|
166 |
{
|
167 |
+
// Don't update this in the return routine. Leave this for the IPN routine.
|
168 |
+
// EOT Times might be extended, and we don't want the IPN routine to extend an already-extended EOT Time.
|
169 |
$eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $paypal["eotper"], "", get_user_option("s2member_auto_eot_time", $user_id));
|
170 |
+
$paypal["s2member_log"][] = "Automatic EOT (End Of Term) Time will be set to: ".date("D M j, Y g:i:s a T", $eot_time).".";
|
171 |
}
|
172 |
+
else // Otherwise, we need to clear the Auto-EOT Time.
|
173 |
delete_user_option($user_id, "s2member_auto_eot_time");
|
174 |
+
|
175 |
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
|
176 |
+
$pr_times["level"] = /* Preserve existing. */ (!$pr_times["level"]) ? time() : $pr_times["level"];
|
177 |
$pr_times["level".$paypal["level"]] = (!$pr_times["level".$paypal["level"]]) ? time() : $pr_times["level".$paypal["level"]];
|
178 |
+
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
|
179 |
+
|
180 |
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Demoted by s2Member\:/");
|
181 |
+
c_ws_plugin__s2member_user_notes::clear_user_note_lines ($user_id, "/^Paid Subscr\. ID @ time of demotion\:/");
|
182 |
+
|
183 |
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
|
184 |
+
|
185 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
186 |
+
|
187 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
|
188 |
+
|
189 |
if($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
190 |
{
|
191 |
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)))
|
204 |
if(($code = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $code)))
|
205 |
{
|
206 |
if(is_array($fields) && !empty($fields))
|
207 |
+
foreach /* Custom Registration/Profile Fields. */($fields as $var => $val)
|
208 |
if(!($code = preg_replace("/%%".preg_quote($var, "/")."%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $code)))
|
209 |
break;
|
210 |
+
|
211 |
+
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
212 |
{
|
213 |
$paypal["s2member_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
|
214 |
set_transient("s2m_".md5("s2member_transient_modification_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
216 |
}
|
217 |
}
|
218 |
}
|
219 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
220 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars());
|
221 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
222 |
+
|
223 |
if(($redirection_url_after_modification = apply_filters("ws_plugin__s2member_redirection_url_after_modification", false, get_defined_vars())))
|
224 |
{
|
225 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after modification: ".$redirection_url_after_modification;
|
226 |
+
|
227 |
wp_redirect($redirection_url_after_modification);
|
228 |
}
|
229 |
+
else // Else, use standard/default handling in this scenario. Have the Customer log in again.
|
230 |
{
|
231 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page (after displaying a quick thank-you message). They need to log back in.";
|
232 |
+
|
233 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
234 |
+
'<strong>'._x("Thank you! You've been updated to:", "s2member-front", "s2member").'<br /><em>'.esc_html($paypal["item_name"]).'</em></strong>',
|
235 |
+
_x("Please Log Back In (Click Here)", "s2member-front", "s2member"), wp_login_url());
|
236 |
}
|
237 |
}
|
238 |
+
else // Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here.
|
239 |
{
|
240 |
$paypal["s2member_log"][] = "Unable to modify Subscription. The 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.";
|
241 |
+
|
242 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
243 |
+
|
244 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
245 |
+
_x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />The 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.', "s2member-front", "s2member"),
|
246 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
247 |
}
|
248 |
}
|
249 |
+
else // Unable to modify Subscription. Could not get the existing User ID from the DB.
|
250 |
{
|
251 |
$paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
|
252 |
+
|
253 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
254 |
+
|
255 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
256 |
+
_x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', "s2member-front", "s2member"),
|
257 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
258 |
}
|
259 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
260 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars());
|
261 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
262 |
}
|
263 |
/*
|
264 |
New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
|
265 |
*/
|
266 |
+
else // Else this is a normal Subscription signup, we are not updating an existing Subscription.
|
267 |
{
|
268 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
269 |
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars());
|
270 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
271 |
+
|
272 |
+
$processing = $during = /* Yes, we ARE processing this new Subscription request. */ true;
|
273 |
+
|
274 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
275 |
+
|
276 |
setcookie("s2member_subscr_gateway", ($s2member_subscr_gateway = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_gateway"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_subscr_gateway", $s2member_subscr_gateway, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_subscr_gateway"] = $s2member_subscr_gateway);
|
277 |
setcookie("s2member_subscr_id", ($s2member_subscr_id = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_subscr_id", $s2member_subscr_id, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_subscr_id"] = $s2member_subscr_id);
|
278 |
setcookie("s2member_custom", ($s2member_custom = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["custom"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_custom", $s2member_custom, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_custom"] = $s2member_custom);
|
279 |
setcookie("s2member_item_number", ($s2member_item_number = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["item_number"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_item_number", $s2member_item_number, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_item_number"] = $s2member_item_number);
|
280 |
+
|
281 |
$paypal["s2member_log"][] = "Registration Cookies set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
282 |
+
|
283 |
setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"])), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
284 |
+
|
285 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
|
286 |
+
|
287 |
if($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array($cv = preg_split("/\|/", $paypal["custom"])))
|
288 |
{
|
289 |
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)))
|
294 |
if(($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"]." ".$paypal["last_name"])), $code)))
|
295 |
if(($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)))
|
296 |
if(($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $code)))
|
297 |
+
|
298 |
+
if(($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
299 |
{
|
300 |
$paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
|
301 |
set_transient("s2m_".md5("s2member_transient_signup_tracking_codes_".$paypal["subscr_id"]), $code, 43200);
|
302 |
}
|
303 |
}
|
304 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
305 |
do_action("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars());
|
306 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
307 |
+
|
308 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site())
|
309 |
{
|
310 |
if(($redirection_url_after_mms_farm_signup = apply_filters("ws_plugin__s2member_redirection_url_after_mms_farm_signup", false, get_defined_vars())))
|
311 |
{
|
312 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after signup: ".$redirection_url_after_mms_farm_signup;
|
313 |
+
|
314 |
wp_redirect($redirection_url_after_mms_farm_signup);
|
315 |
}
|
316 |
+
else if /* Using a custom success redirection URL? */($custom_success_redirection)
|
317 |
{
|
318 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: ".$custom_success_redirection;
|
319 |
+
|
320 |
wp_redirect($custom_success_redirection);
|
321 |
}
|
322 |
+
else // Else use the default return URL in this scenario, which is the Signup Page.
|
323 |
{
|
324 |
+
$paypal["s2member_log"][] = "Redirecting Customer to Signup Page (after displaying a quick thank-you message). They need to Signup/Register now.";
|
325 |
+
|
326 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
327 |
+
_x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', "s2member-front", "s2member"),
|
328 |
+
_x("Please Register Now (Click Here)", "s2member-front", "s2member"), c_ws_plugin__s2member_utils_urls::wp_signup_url());
|
329 |
}
|
330 |
}
|
331 |
+
else // Otherwise, this is NOT a Multisite install. Or it is, but the Super Administrator is NOT selling Blog creation.
|
332 |
{
|
333 |
if(($redirection_url_after_signup = apply_filters("ws_plugin__s2member_redirection_url_after_signup", false, get_defined_vars())))
|
334 |
{
|
335 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after signup: ".$redirection_url_after_signup;
|
336 |
+
|
337 |
wp_redirect($redirection_url_after_signup);
|
338 |
}
|
339 |
+
else if /* Using a custom success redirection URL? */($custom_success_redirection)
|
340 |
{
|
341 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: ".$custom_success_redirection;
|
342 |
+
|
343 |
wp_redirect($custom_success_redirection);
|
344 |
}
|
345 |
+
else // Else use the default return URL in this scenario, which is the Registration Page.
|
346 |
{
|
347 |
+
$paypal["s2member_log"][] = "Redirecting Customer to Registration Page (after displaying a quick thank-you message). They need to Register now.";
|
348 |
+
|
349 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
350 |
+
_x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', "s2member-front", "s2member"),
|
351 |
+
_x("Please Register Now (Click Here)", "s2member-front", "s2member"), c_ws_plugin__s2member_utils_urls::wp_register_url());
|
352 |
}
|
353 |
}
|
354 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
355 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars());
|
356 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
357 |
}
|
358 |
}
|
359 |
+
else // Page Expired. Duplicate Return-Data.
|
360 |
{
|
361 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
362 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
|
363 |
+
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page (after displaying an error message).";
|
364 |
+
|
365 |
+
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"],
|
366 |
+
_x('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"),
|
367 |
+
_x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
|
368 |
}
|
369 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
370 |
do_action("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars());
|
371 |
+
unset /* Unset defined __refs, __v. */($__refs, $__v);
|
372 |
+
|
373 |
return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level", $paypal, get_defined_vars());
|
374 |
}
|
375 |
+
else return apply_filters("c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level", false, get_defined_vars());
|
|
|
376 |
}
|
377 |
}
|
378 |
}
|
includes/classes/paypal-return-in-wa-ccaps-wo-level.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,76 +28,75 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function
|
42 |
{
|
43 |
-
extract
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $paypal["item_number"]))
|
47 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
-
&& (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (!empty ($paypal["payer_email"]))
|
49 |
{
|
50 |
-
|
51 |
do_action ("ws_plugin__s2member_during_paypal_return_before_new_ccaps", get_defined_vars ());
|
52 |
-
unset
|
53 |
-
|
54 |
if (!get_transient ($transient_rtn = "s2m_rtn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_rtn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
57 |
-
|
58 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
-
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
-
|
64 |
-
if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
65 |
{
|
66 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["txn_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
67 |
{
|
68 |
-
if
|
69 |
{
|
70 |
-
$processing = $during =
|
71 |
-
|
72 |
-
$fields =
|
73 |
-
$user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
|
74 |
-
$user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
75 |
-
|
76 |
-
if (is_multisite () && !is_user_member_of_blog ($user_id)
|
77 |
{
|
78 |
add_existing_user_to_blog(array ("user_id" => $user_id, "role" => get_option ("default_role")));
|
79 |
$user = new WP_User ($user_id);
|
80 |
}
|
81 |
-
/**/
|
82 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
83 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
84 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
85 |
$user->remove_cap ($ccap = $cap);
|
86 |
-
|
87 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
88 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
89 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
90 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
91 |
-
|
92 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
93 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
94 |
-
|
95 |
$paypal["s2member_log"][] = "s2Member Custom Capabilities updated w/ advanced update routines.";
|
96 |
-
|
97 |
setcookie ("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["subscr_id"])), time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_tracking", $s2member_tracking, time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
98 |
-
|
99 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
100 |
-
|
101 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
102 |
{
|
103 |
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)))
|
@@ -115,11 +114,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level"))
|
|
115 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
116 |
{
|
117 |
if (is_array ($fields) && !empty ($fields))
|
118 |
-
foreach ($fields as $var => $val)
|
119 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
120 |
break;
|
121 |
-
|
122 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))
|
123 |
{
|
124 |
$paypal["s2member_log"][] = "Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.";
|
125 |
set_transient ("s2m_" . md5 ("s2member_transient_ccap_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
@@ -127,78 +126,75 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level"))
|
|
127 |
}
|
128 |
}
|
129 |
}
|
130 |
-
|
131 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
132 |
do_action ("ws_plugin__s2member_during_paypal_return_during_new_ccaps", get_defined_vars ());
|
133 |
-
unset
|
134 |
-
|
135 |
if (($redirection_url_after_capabilities = apply_filters ("ws_plugin__s2member_redirection_url_after_capabilities", false, get_defined_vars ())))
|
136 |
{
|
137 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after Capabilities: " . $redirection_url_after_capabilities;
|
138 |
-
|
139 |
wp_redirect($redirection_url_after_capabilities);
|
140 |
}
|
141 |
-
else
|
142 |
{
|
143 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in.";
|
144 |
-
|
145 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
146 |
-
|
147 |
-
|
148 |
}
|
149 |
}
|
150 |
-
else
|
151 |
{
|
152 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. The 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.";
|
153 |
-
|
154 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
155 |
-
|
156 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
157 |
-
|
158 |
-
|
159 |
}
|
160 |
}
|
161 |
-
else
|
162 |
{
|
163 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Could not get the existing User ID from the DB.";
|
164 |
-
|
165 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
166 |
-
|
167 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
168 |
-
|
169 |
-
|
170 |
}
|
171 |
}
|
172 |
-
else
|
173 |
{
|
174 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code.";
|
175 |
-
|
176 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
177 |
-
|
178 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
179 |
-
|
180 |
-
|
181 |
}
|
182 |
}
|
183 |
-
else
|
184 |
{
|
185 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
186 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
187 |
-
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page.";
|
188 |
-
|
189 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
190 |
-
|
191 |
-
|
192 |
}
|
193 |
-
|
194 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
195 |
do_action ("ws_plugin__s2member_during_paypal_return_after_new_ccaps", get_defined_vars ());
|
196 |
-
unset
|
197 |
-
|
198 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level", $paypal, get_defined_vars ());
|
199 |
}
|
200 |
-
else
|
201 |
-
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level", false, get_defined_vars ());
|
202 |
}
|
203 |
}
|
204 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
42 |
{
|
43 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^web_accept$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $paypal["item_number"]))
|
47 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
+
&& (!empty ($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (!empty ($paypal["payer_email"])))
|
49 |
{
|
50 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
51 |
do_action ("ws_plugin__s2member_during_paypal_return_before_new_ccaps", get_defined_vars ());
|
52 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
53 |
+
|
54 |
if (!get_transient ($transient_rtn = "s2m_rtn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_rtn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
57 |
+
|
58 |
list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
+
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
+
|
64 |
+
if /* Must have this information for Capability additions. */ (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"])
|
65 |
{
|
66 |
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["txn_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
|
67 |
{
|
68 |
+
if /* Do NOT process this routine on Administrators. */ (!$user->has_cap ("administrator"))
|
69 |
{
|
70 |
+
$processing = $during = /* Yes, we ARE processing this. */ true;
|
71 |
+
|
72 |
+
$fields = /* These will be needed in the routines below. */ get_user_option ("s2member_custom_fields", $user_id);
|
73 |
+
$user_reg_ip = /* Original IP during Registration. */ get_user_option ("s2member_registration_ip", $user_id);
|
74 |
+
$user_reg_ip = $paypal["ip"] = /* Now merge conditionally. */ ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
|
75 |
+
|
76 |
+
if (is_multisite () && !is_user_member_of_blog ($user_id) /* Must have a Role on this Blog. */)
|
77 |
{
|
78 |
add_existing_user_to_blog(array ("user_id" => $user_id, "role" => get_option ("default_role")));
|
79 |
$user = new WP_User ($user_id);
|
80 |
}
|
|
|
81 |
if ($paypal["ccaps"] && preg_match ("/^-all/", str_replace ("+", "", $paypal["ccaps"])))
|
82 |
foreach ($user->allcaps as $cap => $cap_enabled)
|
83 |
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
84 |
$user->remove_cap ($ccap = $cap);
|
85 |
+
|
86 |
if ($paypal["ccaps"] && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"])))
|
87 |
foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $paypal["ccaps"]))) as $ccap)
|
88 |
if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
|
89 |
$user->add_cap ("access_s2member_ccap_" . $ccap);
|
90 |
+
|
91 |
if (!get_user_option ("s2member_registration_ip", $user_id))
|
92 |
update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
|
93 |
+
|
94 |
$paypal["s2member_log"][] = "s2Member Custom Capabilities updated w/ advanced update routines.";
|
95 |
+
|
96 |
setcookie ("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["subscr_id"])), time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_tracking", $s2member_tracking, time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
|
97 |
+
|
98 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
99 |
+
|
100 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
101 |
{
|
102 |
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)))
|
114 |
if (($code = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $code)))
|
115 |
{
|
116 |
if (is_array ($fields) && !empty ($fields))
|
117 |
+
foreach /* Custom Registration/Profile Fields. */ ($fields as $var => $val)
|
118 |
if (!($code = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $code)))
|
119 |
break;
|
120 |
+
|
121 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))) /* This gets stored into a Transient Queue. */)
|
122 |
{
|
123 |
$paypal["s2member_log"][] = "Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.";
|
124 |
set_transient ("s2m_" . md5 ("s2member_transient_ccap_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
126 |
}
|
127 |
}
|
128 |
}
|
129 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
130 |
do_action ("ws_plugin__s2member_during_paypal_return_during_new_ccaps", get_defined_vars ());
|
131 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
132 |
+
|
133 |
if (($redirection_url_after_capabilities = apply_filters ("ws_plugin__s2member_redirection_url_after_capabilities", false, get_defined_vars ())))
|
134 |
{
|
135 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL after Capabilities: " . $redirection_url_after_capabilities;
|
136 |
+
|
137 |
wp_redirect($redirection_url_after_capabilities);
|
138 |
}
|
139 |
+
else // Else, use standard/default handling in this scenario. Have the Customer log in again.
|
140 |
{
|
141 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Login Page (after displaying a quick thank-you message). They need to log back in.";
|
142 |
+
|
143 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
144 |
+
'<strong>' . _x ("Thank you! You now have access to:", "s2member-front", "s2member") . '<br /><em>' . esc_html ($paypal["item_name"]) . '</em></strong>',
|
145 |
+
_x ("Please Log Back In (Click Here)", "s2member-front", "s2member"), wp_login_url ());
|
146 |
}
|
147 |
}
|
148 |
+
else // Unable to add new Capabilities. The existing User ID is associated with an Administrator. Stopping here.
|
149 |
{
|
150 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. The 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.";
|
151 |
+
|
152 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
153 |
+
|
154 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
155 |
+
_x ('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />The 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.', "s2member-front", "s2member"),
|
156 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
157 |
}
|
158 |
}
|
159 |
+
else // Unable to add new Capabilities. Could not get the existing User ID from the DB.
|
160 |
{
|
161 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Could not get the existing User ID from the DB.";
|
162 |
+
|
163 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
164 |
+
|
165 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
166 |
+
_x ('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', "s2member-front", "s2member"),
|
167 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
168 |
}
|
169 |
}
|
170 |
+
else // Unable to add new Capabilities. Missing User/Member details.
|
171 |
{
|
172 |
$paypal["s2member_log"][] = "Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code.";
|
173 |
+
|
174 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
175 |
+
|
176 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
177 |
+
_x ('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />Missing User/Member details.', "s2member-front", "s2member"),
|
178 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
179 |
}
|
180 |
}
|
181 |
+
else // Page Expired. Duplicate Return-Data.
|
182 |
{
|
183 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
184 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.";
|
185 |
+
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page (after displaying an error message).";
|
186 |
+
|
187 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
188 |
+
_x ('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"),
|
189 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
190 |
}
|
191 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
192 |
do_action ("ws_plugin__s2member_during_paypal_return_after_new_ccaps", get_defined_vars ());
|
193 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
194 |
+
|
195 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level", $paypal, get_defined_vars ());
|
196 |
}
|
197 |
+
else return apply_filters ("c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level", false, get_defined_vars ());
|
|
|
198 |
}
|
199 |
}
|
200 |
}
|
includes/classes/paypal-return-in-web-accept-sp.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
@@ -28,47 +28,47 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp"))
|
|
28 |
class c_ws_plugin__s2member_paypal_return_in_web_accept_sp
|
29 |
{
|
30 |
/**
|
31 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
-
* @return array|bool The original ``$paypal`` array passed in (
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
-
public static function
|
42 |
{
|
43 |
-
extract
|
44 |
-
|
45 |
-
if (
|
46 |
-
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
47 |
-
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
-
&& (!empty ($paypal["txn_id"]))
|
49 |
{
|
50 |
-
|
51 |
do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
|
52 |
-
unset
|
53 |
-
|
54 |
if (!get_transient ($transient_rtn = "s2m_rtn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_rtn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
57 |
-
|
58 |
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
-
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
-
|
64 |
if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
|
65 |
{
|
66 |
-
$processing = $during =
|
67 |
-
|
68 |
setcookie ("s2member_sp_tracking", ($s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["txn_id"])), time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_sp_tracking", $s2member_sp_tracking, time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_sp_tracking);
|
69 |
-
|
70 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept` ) for Specific Post/Page Access.";
|
71 |
-
|
72 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
73 |
{
|
74 |
if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", 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)))
|
@@ -77,69 +77,66 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp"))
|
|
77 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
78 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
79 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
80 |
-
|
81 |
-
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code))))
|
82 |
{
|
83 |
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
84 |
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
85 |
}
|
86 |
}
|
87 |
-
|
88 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
89 |
do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
|
90 |
-
unset
|
91 |
-
|
92 |
if (apply_filters ("ws_plugin__s2member_immediate_sp_access_redirection", false, get_defined_vars ()))
|
93 |
{
|
94 |
$paypal["s2member_log"][] = "Redirecting Customer immediately to the Specific Post/Page.";
|
95 |
-
|
96 |
-
wp_redirect
|
97 |
}
|
98 |
-
else if
|
99 |
{
|
100 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection;
|
101 |
-
|
102 |
wp_redirect($custom_success_redirection);
|
103 |
}
|
104 |
-
else
|
105 |
{
|
106 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
|
107 |
-
|
108 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
109 |
-
|
110 |
-
|
111 |
}
|
112 |
}
|
113 |
-
else
|
114 |
{
|
115 |
$paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?";
|
116 |
-
|
117 |
-
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page
|
118 |
-
|
119 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
120 |
-
|
121 |
-
|
122 |
}
|
123 |
}
|
124 |
-
else
|
125 |
{
|
126 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
127 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
128 |
-
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page.";
|
129 |
-
|
130 |
-
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"]
|
131 |
-
|
132 |
-
|
133 |
}
|
134 |
-
|
135 |
-
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
136 |
do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
|
137 |
-
unset
|
138 |
-
|
139 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", $paypal, get_defined_vars ());
|
140 |
}
|
141 |
-
else
|
142 |
-
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", false, get_defined_vars ());
|
143 |
}
|
144 |
}
|
145 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 110720
|
28 |
class c_ws_plugin__s2member_paypal_return_in_web_accept_sp
|
29 |
{
|
30 |
/**
|
31 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routine).
|
32 |
*
|
33 |
* @package s2Member\PayPal
|
34 |
* @since 110720
|
35 |
*
|
36 |
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
|
37 |
+
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
|
38 |
*
|
39 |
* @todo Optimize with ``empty()`` and ``isset()``.
|
40 |
*/
|
41 |
+
public static function /* Conditional phase for ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ cp ($vars = array ())
|
42 |
{
|
43 |
+
extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */($vars);
|
44 |
+
|
45 |
+
if ((!empty ($paypal["txn_type"]) && preg_match ("/^web_accept$/i", $paypal["txn_type"]))
|
46 |
+
&& (!empty ($paypal["item_number"]) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"]))
|
47 |
+
&& (empty ($paypal["payment_status"]) || empty ($payment_status_issues) || !preg_match ($payment_status_issues, $paypal["payment_status"]))
|
48 |
+
&& (!empty ($paypal["txn_id"])))
|
49 |
{
|
50 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
51 |
do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
|
52 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
53 |
+
|
54 |
if (!get_transient ($transient_rtn = "s2m_rtn_" . md5 ("s2member_transient_" . $_paypal_s)) && set_transient ($transient_rtn, time (), 31556926 * 10))
|
55 |
{
|
56 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
57 |
+
|
58 |
list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
|
59 |
+
|
60 |
$paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
|
61 |
$paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[a-z0-9]+~[0-9\.]+$/i", $paypal["invoice"])) ? preg_replace ("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
|
62 |
$paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
|
63 |
+
|
64 |
if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
|
65 |
{
|
66 |
+
$processing = $during = /* Yes, we ARE processing this. */ true;
|
67 |
+
|
68 |
setcookie ("s2member_sp_tracking", ($s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt ($paypal["txn_id"])), time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_sp_tracking", $s2member_sp_tracking, time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_sp_tracking);
|
69 |
+
|
70 |
$paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept` ) for Specific Post/Page Access.";
|
71 |
+
|
72 |
if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
|
73 |
{
|
74 |
if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", 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)))
|
77 |
if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
|
78 |
if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
|
79 |
if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
|
80 |
+
|
81 |
+
if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) // This gets stored into a Transient Queue.
|
82 |
{
|
83 |
$paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
|
84 |
set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
|
85 |
}
|
86 |
}
|
87 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
88 |
do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
|
89 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
90 |
+
|
91 |
if (apply_filters ("ws_plugin__s2member_immediate_sp_access_redirection", false, get_defined_vars ()))
|
92 |
{
|
93 |
$paypal["s2member_log"][] = "Redirecting Customer immediately to the Specific Post/Page.";
|
94 |
+
|
95 |
+
wp_redirect /* Immediate redirection to Specific Post/Page. */($sp_access_url);
|
96 |
}
|
97 |
+
else if /* Using a custom success redirection URL? */ ($custom_success_redirection)
|
98 |
{
|
99 |
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection;
|
100 |
+
|
101 |
wp_redirect($custom_success_redirection);
|
102 |
}
|
103 |
+
else // Else use the default return URL in this scenario, which is the Specific Post/Page.
|
104 |
{
|
105 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page (after displaying a thank-you message).";
|
106 |
+
|
107 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
108 |
+
_x ('<strong>Thank You! Your transaction has been approved.</strong>', "s2member-front", "s2member"),
|
109 |
+
_x ("Continue (Click Here)", "s2member-front", "s2member"), $sp_access_url);
|
110 |
}
|
111 |
}
|
112 |
+
else // Otherwise, the ID must have been invalid. Or the Post/Page was deleted.
|
113 |
{
|
114 |
$paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?";
|
115 |
+
|
116 |
+
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
|
117 |
+
|
118 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
119 |
+
_x ('<strong>ERROR:</strong> Unable to generate Access Link.<br />Please contact Support for assistance.', "s2member-front", "s2member"),
|
120 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
121 |
}
|
122 |
}
|
123 |
+
else // Page Expired. Duplicate Return-Data.
|
124 |
{
|
125 |
$paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data.";
|
126 |
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.";
|
127 |
+
$paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page (after displaying an error message).";
|
128 |
+
|
129 |
+
echo c_ws_plugin__s2member_return_templates::return_template ($paypal["subscr_gateway"],
|
130 |
+
_x ('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"),
|
131 |
+
_x ("Back To Home Page", "s2member-front", "s2member"), home_url ("/"));
|
132 |
}
|
133 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
|
|
134 |
do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
|
135 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
136 |
+
|
137 |
return apply_filters ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", $paypal, get_defined_vars ());
|
138 |
}
|
139 |
+
else return apply_filters ("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", false, get_defined_vars ());
|
|
|
140 |
}
|
141 |
}
|
142 |
}
|
includes/classes/paypal-return-in.inc.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
-
* (
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
-
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
|
21 |
{
|
22 |
/**
|
23 |
-
* s2Member's PayPal® Auto-Return/PDT handler (
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 3.5
|
@@ -39,121 +39,124 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
|
|
39 |
*/
|
40 |
public static function paypal_return ()
|
41 |
{
|
42 |
-
global
|
43 |
-
|
44 |
do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
|
45 |
-
|
46 |
if (!empty ($_GET["s2member_paypal_return"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty ($_GET["s2member_paypal_proxy"])))
|
47 |
{
|
48 |
$custom_success_redirection = (!empty ($_GET["s2member_paypal_return_success"])) ? esc_html (trim (stripslashes ($_GET["s2member_paypal_return_success"]))) : false;
|
49 |
$custom_success_redirection = ($custom_success_redirection) ? str_ireplace (array ("&", "&"), "&", $custom_success_redirection) : $custom_success_redirection;
|
50 |
-
|
51 |
if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal) && ($_paypal_s = serialize ($_paypal)))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
|
54 |
$paypal["s2member_log"][] = "s2Member POST vars verified " . ((!empty ($paypal["proxy_verified"])) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
55 |
-
|
56 |
$paypal["subscr_gateway"] = (!empty ($_GET["s2member_paypal_proxy"])) ? esc_html (trim (stripslashes ($_GET["s2member_paypal_proxy"]))) : "paypal";
|
57 |
-
|
58 |
if (empty ($_GET["s2member_paypal_proxy"]) || empty ($_GET["s2member_paypal_proxy_use"]) || !preg_match ("/ty-email/", $_GET["s2member_paypal_proxy_use"]))
|
59 |
{
|
60 |
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
61 |
-
|
62 |
if (!empty ($paypal["custom"]) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
63 |
{
|
64 |
$paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
|
65 |
-
|
66 |
-
|
67 |
if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
|
68 |
{
|
69 |
-
unset
|
70 |
-
|
71 |
if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_web_accept_sp::cp (get_defined_vars ())))
|
72 |
$paypal = $_paypal_cp;
|
73 |
-
|
74 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level::cp (get_defined_vars ())))
|
75 |
$paypal = $_paypal_cp;
|
76 |
-
|
77 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level::cp (get_defined_vars ())))
|
78 |
$paypal = $_paypal_cp;
|
79 |
-
|
80 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level::cp (get_defined_vars ())))
|
81 |
$paypal = $_paypal_cp;
|
82 |
-
|
83 |
-
else
|
84 |
{
|
85 |
$paypal["s2member_log"][] = "
|
1 |
<?php
|
2 |
/**
|
3 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routines).
|
4 |
*
|
5 |
* Copyright: © 2009-2011
|
6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
|
7 |
+
* (coded in the USA)
|
8 |
*
|
9 |
* Released under the terms of the GNU General Public License.
|
10 |
* You should have received a copy of the GNU General Public License,
|
16 |
*/
|
17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
18 |
exit ("Do not access this file directly.");
|
19 |
+
|
20 |
if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
|
21 |
{
|
22 |
/**
|
23 |
+
* s2Member's PayPal® Auto-Return/PDT handler (inner processing routines).
|
24 |
*
|
25 |
* @package s2Member\PayPal
|
26 |
* @since 3.5
|
39 |
*/
|
40 |
public static function paypal_return ()
|
41 |
{
|
42 |
+
global /* For Multisite support. */ $current_site, $current_blog;
|
43 |
+
|
44 |
do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
|
45 |
+
|
46 |
if (!empty ($_GET["s2member_paypal_return"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty ($_GET["s2member_paypal_proxy"])))
|
47 |
{
|
48 |
$custom_success_redirection = (!empty ($_GET["s2member_paypal_return_success"])) ? esc_html (trim (stripslashes ($_GET["s2member_paypal_return_success"]))) : false;
|
49 |
$custom_success_redirection = ($custom_success_redirection) ? str_ireplace (array ("&", "&"), "&", $custom_success_redirection) : $custom_success_redirection;
|
50 |
+
|
51 |
if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal) && ($_paypal_s = serialize ($_paypal)))
|
52 |
{
|
53 |
$paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
|
54 |
$paypal["s2member_log"][] = "s2Member POST vars verified " . ((!empty ($paypal["proxy_verified"])) ? "with a Proxy Key" : "through a POST back to PayPal®.");
|
55 |
+
|
56 |
$paypal["subscr_gateway"] = (!empty ($_GET["s2member_paypal_proxy"])) ? esc_html (trim (stripslashes ($_GET["s2member_paypal_proxy"]))) : "paypal";
|
57 |
+
|
58 |
if (empty ($_GET["s2member_paypal_proxy"]) || empty ($_GET["s2member_paypal_proxy_use"]) || !preg_match ("/ty-email/", $_GET["s2member_paypal_proxy_use"]))
|
59 |
{
|
60 |
$payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
|
61 |
+
|
62 |
if (!empty ($paypal["custom"]) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
|
63 |
{
|
64 |
$paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
|
65 |
+
|
66 |
+
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
|
67 |
if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
|
68 |
{
|
69 |
+
unset /* Unset defined __refs, __v. */ ($__refs, $__v);
|
70 |
+
|
71 |
if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_web_accept_sp::cp (get_defined_vars ())))
|
72 |
$paypal = $_paypal_cp;
|
73 |
+
|
74 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level::cp (get_defined_vars ())))
|
75 |
$paypal = $_paypal_cp;
|
76 |
+
|
77 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level::cp (get_defined_vars ())))
|
78 |
$paypal = $_paypal_cp;
|
79 |
+
|
80 |
else if (($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level::cp (get_defined_vars ())))
|
81 |
$paypal = $_paypal_cp;
|
82 |
+
|
83 |
+
else // Else we have an unexpected scenario ( i.e. an unexpected `txn_type/status` ).
|
84 |
{
|
85 |
$paypal["s2member_log"][] = "
|