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

Version Description

= v141007 =

(Maintenance Release) Upgrade immediately.

Download this release

Release Info

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

Code changes from version 140921 to 141007

Files changed (81) hide show
  1. checksum.txt +1 -1
  2. includes/classes/admin-lockouts.inc.php +1 -1
  3. includes/classes/admin-notices.inc.php +137 -137
  4. includes/classes/aweber-e.inc.php +151 -0
  5. includes/classes/aweber.inc.php +314 -0
  6. includes/classes/catgs-sp.inc.php +73 -73
  7. includes/classes/catgs.inc.php +70 -73
  8. includes/classes/getresponse.inc.php +196 -0
  9. includes/classes/list-server-base.inc.php +118 -0
  10. includes/classes/list-servers.inc.php +160 -414
  11. includes/classes/login-redirects.inc.php +9 -9
  12. includes/classes/mailchimp-o.inc.php +204 -0
  13. includes/classes/mailchimp.inc.php +218 -0
  14. includes/classes/pages-sp.inc.php +3 -2
  15. includes/classes/pages.inc.php +3 -2
  16. includes/classes/posts-sp.inc.php +3 -2
  17. includes/classes/posts.inc.php +3 -2
  18. includes/classes/ptags-sp.inc.php +87 -90
  19. includes/classes/ptags.inc.php +70 -71
  20. includes/classes/querys.inc.php +1 -1
  21. includes/classes/register-access.inc.php +93 -91
  22. includes/classes/registrations.inc.php +1150 -1105
  23. includes/classes/ruris-sp.inc.php +62 -64
  24. includes/classes/ruris.inc.php +5 -4
  25. includes/classes/sc-gets-in.inc.php +76 -61
  26. includes/classes/sc-gets.inc.php +43 -43
  27. includes/classes/sc-if-conds-in.inc.php +284 -284
  28. includes/classes/sc-if-conds.inc.php +53 -53
  29. includes/classes/sc-keys-in.inc.php +53 -54
  30. includes/classes/sc-keys.inc.php +43 -43
  31. includes/classes/ssl-in.inc.php +158 -162
  32. includes/classes/ssl.inc.php +56 -60
  33. includes/classes/systematics-sp.inc.php +123 -130
  34. includes/classes/systematics.inc.php +136 -149
  35. includes/classes/utils-conds.inc.php +237 -216
  36. includes/classes/utils-logs.inc.php +151 -131
  37. includes/codes.inc.php +20 -21
  38. includes/externals/aweber/aweber.php +294 -0
  39. includes/externals/aweber/aweber_api.php +8 -0
  40. includes/externals/aweber/aweber_collection.php +268 -0
  41. includes/externals/aweber/aweber_entry.php +343 -0
  42. includes/externals/aweber/aweber_entry_data_array.php +68 -0
  43. includes/externals/aweber/aweber_response.php +73 -0
  44. includes/externals/aweber/curl_object.php +103 -0
  45. includes/externals/aweber/curl_response.php +51 -0
  46. includes/externals/aweber/exceptions.php +130 -0
  47. includes/externals/aweber/oauth_adapter.php +11 -0
  48. includes/externals/aweber/oauth_application.php +681 -0
  49. includes/externals/mailchimp/{nc-mcapi.inc.php → Mailchimp-o.php} +2 -2
  50. includes/externals/mailchimp/Mailchimp.php +261 -0
  51. includes/externals/mailchimp/Mailchimp/Campaigns.php +378 -0
  52. includes/externals/mailchimp/Mailchimp/Conversations.php +80 -0
  53. includes/externals/mailchimp/Mailchimp/Ecomm.php +86 -0
  54. includes/externals/mailchimp/Mailchimp/Exceptions.php +471 -0
  55. includes/externals/mailchimp/Mailchimp/Folders.php +62 -0
  56. includes/externals/mailchimp/Mailchimp/Gallery.php +106 -0
  57. includes/externals/mailchimp/Mailchimp/Goal.php +49 -0
  58. includes/externals/mailchimp/Mailchimp/Helper.php +237 -0
  59. includes/externals/mailchimp/Mailchimp/Lists.php +904 -0
  60. includes/externals/mailchimp/Mailchimp/Mobile.php +10 -0
  61. includes/externals/mailchimp/Mailchimp/Neapolitan.php +10 -0
  62. includes/externals/mailchimp/Mailchimp/Reports.php +459 -0
  63. includes/externals/mailchimp/Mailchimp/Templates.php +114 -0
  64. includes/externals/mailchimp/Mailchimp/Users.php +105 -0
  65. includes/externals/mailchimp/Mailchimp/Vip.php +111 -0
  66. includes/funcs.inc.php +21 -22
  67. includes/menu-pages/api-ops.inc.php +7 -7
  68. includes/menu-pages/down-ops.inc.php +1 -1
  69. includes/menu-pages/els-ops.inc.php +403 -356
  70. includes/menu-pages/gen-ops.inc.php +7 -7
  71. includes/menu-pages/logs.inc.php +1 -1
  72. includes/menu-pages/mms-ops.inc.php +1 -1
  73. includes/menu-pages/paypal-buttons.inc.php +2 -2
  74. includes/menu-pages/res-ops.inc.php +611 -602
  75. includes/menu-pages/trk-ops.inc.php +7 -7
  76. includes/s2member-min.js +1 -1
  77. includes/s2member.js +4 -4
  78. includes/syscon.inc.php +23 -5
  79. includes/translations/s2member.pot +10 -10
  80. readme.txt +12 -3
  81. s2member.php +4 -4
checksum.txt CHANGED
@@ -1 +1 @@
1
- 53efa7007fd214f3a812d3cae6cbef4d
1
+ 880cf4b36bfab2c644bde04a14c3be1d
includes/classes/admin-lockouts.inc.php CHANGED
@@ -44,7 +44,7 @@ if(!class_exists('c_ws_plugin__s2member_admin_lockouts'))
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 ( /* Special Redirection. */);
49
50
else // Else we use the Login Welcome Page configured for s2Member.
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 ( /* Special Redirection. */);
49
50
else // Else we use the Login Welcome Page configured for s2Member.
includes/classes/admin-notices.inc.php CHANGED
@@ -1,157 +1,157 @@
1
<?php
2
/**
3
- * Enqueues/displays administrative notices.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Admin_Notices
15
- * @since 3.5
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit("Do not access this file directly.");
19
-
20
- if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
21
{
22
/**
23
- * Enqueues/displays administrative notices.
24
- *
25
- * @package s2Member\Admin_Notices
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_admin_notices
29
{
30
- /**
31
- * Enqueues administrative notices.
32
- *
33
- * @package s2Member\Admin_Notices
34
- * @since 3.5
35
- *
36
- * @param string $notice String value of actual notice *(i.e. the message)*.
37
- * @param string|array $on_pages Optional. Defaults to any page. String or array of pages to display this notice on.
38
- * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
39
- * @param int $time Optional. Unix timestamp indicating when this notice will be displayed.
40
- * @param bool $dismiss Optional. If true, the notice will remain persistent, until dismissed. Defaults to false.
41
- */
42
- public static function enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
43
- {
44
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;
45
- do_action("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
46
- unset($__refs, $__v);
47
48
- if /* If we have a valid string. */(is_string ($notice) && $notice)
49
- {
50
- $notices = (array)get_option ("ws_plugin__s2member_notices");
51
52
- array_push ($notices, array("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time, "dismiss" => $dismiss));
53
54
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;
55
- do_action("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
56
- unset($__refs, $__v);
57
58
- update_option ("ws_plugin__s2member_notices", c_ws_plugin__s2member_utils_arrays::array_unique ($notices));
59
- }
60
- do_action("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
61
- }
62
- /**
63
- * Displays an administrative notice.
64
- *
65
- * @package s2Member\Admin_Notices
66
- * @since 3.5
67
- *
68
- * @param string $notice String value of actual notice *(i.e. the message)*.
69
- * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
70
- * @param bool $dismiss Optional. If true, the notice will be displayed with a dismissal link. Defaults to false.
71
- */
72
- public static function display_admin_notice ($notice = FALSE, $error = FALSE, $dismiss = FALSE)
73
{
74
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;
75
- do_action("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
76
- unset($__refs, $__v);
77
78
- if /* Slightly different/special format for errors. */ (is_string ($notice) && $notice && $error)
79
- {
80
- $notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
81
82
- echo /* Error. */ '<div class="error fade"><p>' . $notice . '</p></div>';
83
- }
84
- else if (is_string ($notice) && $notice)
85
{
86
- $notice .= ($dismiss) ? ' [ <a href="' . esc_attr(add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"])) . '">dismiss message</a> ]' : '';
87
88
- echo '<div class="updated fade"><p>' . $notice . '</p></div>';
89
- }
90
- do_action("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
91
- }
92
- /**
93
- * Processes all administrative notices.
94
- *
95
- * @package s2Member\Admin_Notices
96
- * @since 3.5
97
- *
98
- * @attaches-to ``add_action("admin_notices");``
99
- * @attaches-to ``add_action("user_admin_notices");``
100
- * @attaches-to ``add_action("network_admin_notices");``
101
- * @todo Update to ``add_action("all_admin_notices");``.
102
- */
103
- public static function admin_notices ()
104
- {
105
- global /* This holds the current page filename. */ $pagenow;
106
107
- do_action("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
108
109
- if (is_admin () && is_array($notices = get_option ("ws_plugin__s2member_notices")) && !empty($notices))
110
- {
111
- $a = (is_blog_admin ()) ? "blog" : "";
112
- $a = (is_user_admin ()) ? "user" : $a;
113
- $a = (is_network_admin ()) ? "network" : $a;
114
- $a = /* Default Blog Admin. */(!$a) ? "blog" : $a;
115
-
116
- foreach /* Check several things about each Notice. */ ($notices as $i => $notice)
117
- foreach (((!$notice["on_pages"]) ? array("*"): (array)$notice["on_pages"]) as $page)
118
- {
119
- if /* NO prefix? */ (!preg_match ("/^(.+?)\:/", $page))
120
- $page = /* `blog:` */ "blog:" . ltrim ($page, ":");
121
-
122
- $adms = preg_split ("/\|/", preg_replace ("/\:(.*)#x2F;i", "", $page));
123
- $page = preg_replace ("/^([^\:]*)\:/i", "", $page);
124
-
125
- if (empty($adms) || in_array("*", $adms) || in_array($a, $adms))
126
- if (!$page || "*" === $page || $pagenow === $page || @$_GET["page"] === $page)
127
- {
128
- if /* Time to show it? */ (strtotime ("now") >= (int)$notice["time"])
129
- {
130
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;
131
- do_action("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
132
- unset($__refs, $__v);
133
-
134
- if (!$notice["dismiss"] || (!empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5 ($notice["notice"])))
135
- unset /* Clear this administrative notice now? */($notices[$i]);
136
-
137
- if (!$notice["dismiss"] || empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5 ($notice["notice"]))
138
- c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice["notice"], $notice["error"], $notice["dismiss"]);
139
-
140
- do_action("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
141
- }
142
- continue /* This Notice processed; continue. */ 2;
143
- }
144
- }
145
- $notices = /* Re-index array. */array_merge ($notices);
146
-
147
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;
148
- do_action("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
149
- unset($__refs, $__v);
150
-
151
- update_option ("ws_plugin__s2member_notices", $notices);
152
}
153
- do_action("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
154
}
155
}
156
}
157
- ?>
1
<?php
2
/**
3
+ * Enqueues/displays administrative notices.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Admin_Notices
15
+ * @since 3.5
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit('Do not access this file directly.');
19
+
20
+ if(!class_exists('c_ws_plugin__s2member_admin_notices'))
21
+ {
22
+ /**
23
+ * Enqueues/displays administrative notices.
24
+ *
25
+ * @package s2Member\Admin_Notices
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_admin_notices
29
{
30
/**
31
+ * Enqueues administrative notices.
32
+ *
33
+ * @package s2Member\Admin_Notices
34
+ * @since 3.5
35
+ *
36
+ * @param string $notice String value of actual notice *(i.e. the message)*.
37
+ * @param string|array $on_pages Optional. Defaults to any page. String or array of pages to display this notice on.
38
+ * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
39
+ * @param int $time Optional. Unix timestamp indicating when this notice will be displayed.
40
+ * @param bool $dismiss Optional. If true, the notice will remain persistent, until dismissed. Defaults to false.
41
+ */
42
+ public static function enqueue_admin_notice($notice = '', $on_pages = array(), $error = FALSE, $time = 0, $dismiss = FALSE)
43
+ {
44
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
45
+ do_action('ws_plugin__s2member_before_enqueue_admin_notice', get_defined_vars());
46
+ unset($__refs, $__v); // Allow variables to be modified by reference.
47
+
48
+ if($notice && is_string($notice))// Have a valid string.
49
{
50
+ $notices = (array)get_option('ws_plugin__s2member_notices');
51
+ array_push($notices, array('notice' => $notice, 'on_pages' => $on_pages, 'error' => $error, 'time' => $time, 'dismiss' => $dismiss));
52
53
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
54
+ do_action('ws_plugin__s2member_during_enqueue_admin_notice', get_defined_vars());
55
+ unset($__refs, $__v); // Allow variables to be modified by reference.
56
57
+ update_option('ws_plugin__s2member_notices', c_ws_plugin__s2member_utils_arrays::array_unique($notices));
58
+ }
59
+ do_action('ws_plugin__s2member_after_enqueue_admin_notice', get_defined_vars());
60
+ }
61
62
+ /**
63
+ * Displays an administrative notice.
64
+ *
65
+ * @package s2Member\Admin_Notices
66
+ * @since 3.5
67
+ *
68
+ * @param string $notice String value of actual notice *(i.e. the message)*.
69
+ * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
70
+ * @param bool $dismiss Optional. If true, the notice will be displayed with a dismissal link. Defaults to false.
71
+ */
72
+ public static function display_admin_notice($notice = '', $error = FALSE, $dismiss = FALSE)
73
+ {
74
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
75
+ do_action('ws_plugin__s2member_before_display_admin_notice', get_defined_vars());
76
+ unset($__refs, $__v); // Allow variables to be modified by reference.
77
+
78
+ if($notice && is_string($notice) && $error) // Slightly different/special format for errors.
79
+ {
80
+ $notice .= $dismiss ? ' [ <a href="'.esc_attr(add_query_arg('ws-plugin--s2member-dismiss-admin-notice', urlencode(md5($notice)),
81
+ $_SERVER['REQUEST_URI'])).'">dismiss message</a> ]' : '';
82
+ echo '<div class="error fade"><p>'.$notice.'</p></div>'; // Special error notice; w/ fade class.
83
+ }
84
+ else if($notice && is_string($notice))
85
+ {
86
+ $notice .= $dismiss ? ' [ <a href="'.esc_attr(add_query_arg('ws-plugin--s2member-dismiss-admin-notice', urlencode(md5($notice)),
87
+ $_SERVER['REQUEST_URI'])).'">dismiss message</a> ]' : '';
88
+ echo '<div class="updated fade"><p>'.$notice.'</p></div>'; // Regular notice; w/ fade class.
89
+ }
90
+ do_action('ws_plugin__s2member_after_display_admin_notice', get_defined_vars());
91
+ }
92
93
+ /**
94
+ * Processes all administrative notices.
95
+ *
96
+ * @package s2Member\Admin_Notices
97
+ * @since 3.5
98
+ *
99
+ * @attaches-to ``add_action('admin_notices');``
100
+ * @attaches-to ``add_action('user_admin_notices');``
101
+ * @attaches-to ``add_action('network_admin_notices');``
102
+ * @todo Update to ``add_action('all_admin_notices');``.
103
+ */
104
+ public static function admin_notices()
105
+ {
106
+ global $pagenow; // This holds the current page filename.
107
+
108
+ do_action('ws_plugin__s2member_before_admin_notices', get_defined_vars());
109
+
110
+ if(is_admin() && is_array($notices = get_option('ws_plugin__s2member_notices')) && !empty($notices))
111
+ {
112
+ $a = (is_blog_admin()) ? 'blog' : '';
113
+ $a = (is_user_admin()) ? 'user' : $a;
114
+ $a = (is_network_admin()) ? 'network' : $a;
115
+ $a = (!$a) ? 'blog' : $a; // Default blog admin.
116
+
117
+ foreach($notices as $i => $notice) // Check several things about each notice.
118
+ foreach(!$notice['on_pages'] ? array('*') : (array)$notice['on_pages'] as $page)
119
{
120
+ if(!preg_match('/^(.+?)\:/', $page)) // NO prefix?
121
+ $page = 'blog:'.ltrim($page, ':'); // `blog:`
122
123
+ $adms = preg_split('/\|/', preg_replace('/\:(.*)#x2F;i', '', $page));
124
+ $page = preg_replace('/^([^\:]*)\:/i', '', $page);
125
126
+ if(empty($adms) || in_array('*', $adms) || in_array($a, $adms))
127
+ if(!$page || '*' === $page || $pagenow === $page || @$_GET['page'] === $page)
128
{
129
+ if(strtotime('now') >= (int)$notice['time']) // Time to show it?
130
+ {
131
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
132
+ do_action('ws_plugin__s2member_during_admin_notices_before_display', get_defined_vars());
133
+ unset($__refs, $__v); // Allow variables to be modified by reference.
134
135
+ if(!$notice['dismiss'] || (!empty($_GET['ws-plugin--s2member-dismiss-admin-notice']) && $_GET['ws-plugin--s2member-dismiss-admin-notice'] === md5($notice['notice'])))
136
+ unset($notices[$i]); // Clear this administrative notice now?
137
138
+ if(!$notice['dismiss'] || empty($_GET['ws-plugin--s2member-dismiss-admin-notice']) || $_GET['ws-plugin--s2member-dismiss-admin-notice'] !== md5($notice['notice']))
139
+ c_ws_plugin__s2member_admin_notices::display_admin_notice($notice['notice'], $notice['error'], $notice['dismiss']);
140
141
+ do_action('ws_plugin__s2member_during_admin_notices_after_display', get_defined_vars());
142
+ }
143
+ continue 2; // This notice processed; continue.
144
}
145
}
146
+ $notices = array_merge($notices); // Re-index array.
147
+
148
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
149
+ do_action('ws_plugin__s2member_during_admin_notices', get_defined_vars());
150
+ unset($__refs, $__v); // Allow variables to be modified by reference.
151
+
152
+ update_option('ws_plugin__s2member_notices', $notices);
153
}
154
+ do_action('ws_plugin__s2member_after_admin_notices', get_defined_vars());
155
+ }
156
}
157
+ }
includes/classes/aweber-e.inc.php ADDED
@@ -0,0 +1,151 @@
1
+ <?php
2
+ /**
3
+ * AWeber (Old via Email)
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @since 141004
15
+ * @package s2Member\List_Servers
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_aweber_e'))
21
+ {
22
+ /**
23
+ * AWeber (Old via Email)
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_aweber_e extends c_ws_plugin__s2member_list_server_base
29
+ {
30
+ /**
31
+ * Subscribe.
32
+ *
33
+ * @since 141004
34
+ * @package s2Member\List_Servers
35
+ *
36
+ * @param array $args Input arguments.
37
+ *
38
+ * @return bool True if successful.
39
+ */
40
+ public static function subscribe($args)
41
+ {
42
+ if(!($args = self::validate_args($args)))
43
+ return FALSE; // Invalid args.
44
+
45
+ if(!$args->opt_in) // Double check.
46
+ return FALSE; // Must say explicitly.
47
+
48
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
49
+ return FALSE; // No list configured at this level.
50
+
51
+ $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
52
+
53
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_aw_list)
54
+ {
55
+ $_aw = array(
56
+ 'args' => $args,
57
+ 'function' => __FUNCTION__,
58
+ 'list' => trim($_aw_list),
59
+ 'list_id' => trim($_aw_list),
60
+ 'api_method' => 'listSubscribe'
61
+ );
62
+ if(!$_aw['list']) continue; // List missing.
63
+
64
+ $_aw['bcc'] = apply_filters('ws_plugin__s2member_aweber_bcc', FALSE, get_defined_vars());
65
+ $_aw['pass_inclusion'] = apply_filters('ws_plugin__s2member_aweber_pass_inclusion', FALSE, get_defined_vars()) && $args->pass ? "\n".'Pass: '.$args->pass : '';
66
+
67
+ if($_aw['wp_mail_response'] = wp_mail($_aw['list_id'].'@aweber.com', // Converts to email address @aweber.com.
68
+ ($_aw['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.
69
+ ($_aw['wp_mail_msg'] = apply_filters('ws_plugin__s2member_aweber_msg', 's2Member Subscription Request'."\n".'s2Member w/ PayPal Email ID'."\n".'Ad Tracking: s2Member-'.(is_multisite() && !is_main_site() ? $GLOBALS['current_blog']->domain.$GLOBALS['current_blog']->path : $_SERVER['HTTP_HOST'])."\n".'EMail Address: '.$args->email."\n".'Buyer: '.$args->name."\n".'Full Name: '.$args->name."\n".'First Name: '.$args->fname."\n".'Last Name: '.$args->lname."\n".'IP Address: '.$args->ip."\n".'User ID: '.$args->user_id."\n".'Login: '.$args->login.$_aw['pass_inclusion']."\n".'Role: '.$args->role."\n".'Level: '.$args->level."\n".'CCaps: '.$args->ccaps."\n".' - end.', get_defined_vars())),
70
+ ($_aw['wp_mail_headers'] = 'From: "'.preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']).'" <'.$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'].'>'.($_aw['bcc'] ? "\r\n".'Bcc: '.$_aw['bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
71
+ ) $_aw['wp_mail_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
72
+
73
+ c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
74
+ }
75
+ unset($_aw_list, $_aw); // Just a little housekeeping.
76
+
77
+ return !empty($success); // If one suceeds.
78
+ }
79
+
80
+ /**
81
+ * Unsubscribe.
82
+ *
83
+ * @since 141004
84
+ * @package s2Member\List_Servers
85
+ *
86
+ * @param array $args Input arguments.
87
+ *
88
+ * @return bool True if successful.
89
+ */
90
+ public static function unsubscribe($args)
91
+ {
92
+ if(!($args = self::validate_args($args)))
93
+ return FALSE; // Invalid args.
94
+
95
+ if(!$args->opt_out) // Double check.
96
+ return FALSE; // Must say explicitly.
97
+
98
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
99
+ return FALSE; // No list configured at this level.
100
+
101
+ $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
102
+
103
+ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
104
+ if(!$email_configs_were_on) c_ws_plugin__s2member_email_configs::email_config(); // MUST be ON for removal requests.
105
+ // `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
106
+
107
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_aw_list)
108
+ {
109
+ $_aw = array(
110
+ 'args' => $args,
111
+ 'function' => __FUNCTION__,
112
+ 'list' => trim($_aw_list),
113
+ 'list_id' => trim($_aw_list),
114
+ 'api_method' => 'listUnsubscribe'
115
+ );
116
+ if(!$_aw['list']) continue; // List missing.
117
+
118
+ $_aw['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars());
119
+
120
+ if($_aw['wp_mail_response'] = wp_mail($_aw['list_id'].'@aweber.com', // Converts to email address @aweber.com.
121
+ ($_aw['wp_mail_sbj'] = apply_filters('ws_plugin__s2member_aweber_removal_sbj', 'REMOVE#'.$args->email.'#s2Member#'.$_aw['list_id'], get_defined_vars())), // Bug fix. AWeber does not like dots (possibly other chars) in the Ad Tracking field. Now using just: `s2Member`.
122
+ ($_aw['wp_mail_msg'] = 'REMOVE'), ($_aw['wp_mail_headers'] = 'From: "'.preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']).'" <'.$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'].'>'.($_aw['removal_bcc'] ? "\r\n".'Bcc: '.$_aw['removal_bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
123
+ ) $_aw['wp_mail_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
124
+
125
+ c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
126
+ }
127
+ unset($_aw_list, $_aw); // Just a little housekeeping.
128
+
129
+ if(!$email_configs_were_on) // Turn them off now?
130
+ c_ws_plugin__s2member_email_configs::email_config_release();
131
+
132
+ return !empty($success); // If one suceeds.
133
+ }
134
+
135
+ /**
136
+ * Transition.
137
+ *
138
+ * @since 141004
139
+ * @package s2Member\List_Servers
140
+ *
141
+ * @param array $old_args Input arguments.
142
+ * @param array $new_args Input arguments.
143
+ *
144
+ * @return bool True if successful.
145
+ */
146
+ public static function transition($old_args, $new_args)
147
+ {
148
+ return self::unsubscribe($old_args) && self::subscribe($new_args);
149
+ }
150
+ }
151
+ }
includes/classes/aweber.inc.php ADDED
@@ -0,0 +1,314 @@
1
+ <?php
2
+ /**
3
+ * AWeber
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @since 141004
15
+ * @package s2Member\List_Servers
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_aweber'))
21
+ {
22
+ /**
23
+ * AWeber
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_aweber extends c_ws_plugin__s2member_list_server_base
29
+ {
30
+ /**
31
+ * API instance.
32
+ *
33
+ * @since 141004
34
+ * @package s2Member\List_Servers
35
+ *
36
+ * @return AWeberAPI|null AWeber API instance.
37
+ */
38
+ public static function aw_api()
39
+ {
40
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key'])
41
+ return NULL; // Not possible.
42
+
43
+ if(!class_exists('AWeberAPI')) // Include the AWeber API class here.
44
+ include_once dirname(dirname(__FILE__)).'/externals/aweber/aweber_api.php';
45
+
46
+ if(count($key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key'])) < 5)
47
+ return NULL; // It's an invalid API key; i.e. authorization code.
48
+
49
+ list($consumerKey, $consumerSecret, $requestToken, $tokenSecret, $verifier) = $key_parts;
50
+ $internal_api_key_checksum = md5($consumerKey.$consumerSecret.$requestToken.$tokenSecret.$verifier);
51
+
52
+ if(count($internal_key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'])) >= 5)
53
+ list(, , , , $checksum) = $internal_key_parts; // Only need checksum for now.
54
+
55
+ if(empty($checksum) || $checksum !== $internal_api_key_checksum)
56
+ {
57
+ try // Catch any AWeber exceptions that occur here.
58
+ {
59
+ $aw_api = new AWeberAPI($consumerKey, $consumerSecret);
60
+ $aw_api->user->requestToken = $requestToken;
61
+ $aw_api->user->tokenSecret = $tokenSecret;
62
+ $aw_api->user->verifier = $verifier;
63
+
64
+ if(!is_array($accessToken = $aw_api->getAccessToken()) || count($accessToken) < 2)
65
+ return NULL; // Not possible.
66
+
67
+ list($accessTokenKey, $accessTokenSecret) = $accessToken;
68
+ if(!$accessTokenKey || !$accessTokenSecret)
69
+ return NULL; // Not possible.
70
+
71
+ $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'] = $internal_api_key
72
+ = $consumerKey.'|'.$consumerSecret.'|'.$accessTokenKey.'|'.$accessTokenSecret.'|'.$internal_api_key_checksum;
73
+
74
+ c_ws_plugin__s2member_menu_pages::update_all_options
75
+ (array('ws_plugin__s2member_aweber_internal_api_key' => $internal_api_key),
76
+ TRUE, FALSE, FALSE, FALSE, FALSE);
77
+ }
78
+ catch(Exception $exception)
79
+ {
80
+ return NULL; // API initialization failure.
81
+ }
82
+ }
83
+ if(count($internal_key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'])) < 5)
84
+ return NULL; // It's an invalid internal API key. Cannot continue.
85
+
86
+ list($consumerKey, $consumerSecret, $accessTokenKey, $accessTokenSecret, $checksum) = $internal_key_parts;
87
+
88
+ try // Catch any AWeber exceptions that occur here.
89
+ {
90
+ $aw_api = new AWeberAPI($consumerKey, $consumerSecret);
91
+ $aw_api->___account = $aw_api->getAccount($accessTokenKey, $accessTokenSecret);
92
+
93
+ return $aw_api; // AWeberAPI instance.
94
+ }
95
+ catch(Exception $exception)
96
+ {
97
+ return NULL; // API initialization failure.
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Checks a countable obj.
103
+ *
104
+ * @since 141004
105
+ * @package s2Member\List_Servers
106
+ *
107
+ * @param Countable $countable Countable obj.
108
+ *
109
+ * @return bool True if has `count()` > `0`.
110
+ */
111
+ public static function count($countable)
112
+ {
113
+ return $countable instanceof Countable && $countable->count();
114
+ }
115
+
116
+ /**
117
+ * Subscribe.
118
+ *
119
+ * @since 141004
120
+ * @package s2Member\List_Servers
121
+ *
122
+ * @param array $args Input arguments.
123
+ *
124
+ * @return bool True if successful.
125
+ */
126
+ public static function subscribe($args)
127
+ {
128
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_type'] === 'email')
129
+ return c_ws_plugin__s2member_aweber_e::subscribe($args);
130
+
131
+ if(!($args = self::validate_args($args)))
132
+ return FALSE; // Invalid args.
133
+
134
+ if(!$args->opt_in) // Double check.
135
+ return FALSE; // Must say explicitly.
136
+
137
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key'])
138
+ return FALSE; // Not possible.
139
+
140
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
141
+ return FALSE; // No list configured at this level.
142
+
143
+ if(!($aw_api = self::aw_api()) || !@$aw_api->___account->id)
144
+ return FALSE; // Unable to acquire API instance.
145
+
146
+ $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
147
+
148
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_aw_list)
149
+ {
150
+ $_aw = array(
151
+ 'args' => $args,
152
+ 'function' => __FUNCTION__,
153
+ 'list' => trim($_aw_list),
154
+ 'list_id' => trim($_aw_list),
155
+ 'api_method' => 'listSubscribe'
156
+ );
157
+ if(!$_aw['list'] || !$_aw['list_id'])
158
+ continue; // List missing.
159
+
160
+ try // Catch any AWeber exceptions that occur here.
161
+ {
162
+ if(self::count($_aw['foundLists'] = $aw_api->___account->lists->find(array('name' => $_aw['list_id']))))
163
+ if(($_aw['listUrl'] = '/accounts/'.$aw_api->___account->id.'/lists/'.$_aw['foundLists'][0]->id))
164
+ if(($_aw['list'] = $aw_api->___account->loadFromUrl($_aw['listUrl'])))
165
+ {
166
+ $_aw['subscriber_props'] = array(
167
+ 'name' => $args->name,
168
+ 'email' => $args->email,
169
+ 'ip_address' => $args->ip,
170
+ 'ad_tracking' => 's2-'.(is_multisite() && !is_main_site()
171
+ ? $GLOBALS['current_blog']->domain.$GLOBALS['current_blog']->path
172
+ : $_SERVER['HTTP_HOST']),
173
+ 'custom_fields' => apply_filters('ws_plugin__s2member_aweber_custom_fields_array', array(), get_defined_vars()),
174
+ 'status' => !$args->double_opt_in ? 'subscribed' : '', // Try to bypass confirmation?
175
+ );
176
+ $_aw['subscriber_props']['name'] = substr($_aw['subscriber_props']['name'], 0, 60);
177
+ $_aw['subscriber_props']['email'] = substr($_aw['subscriber_props']['email'], 0, 50);
178
+ $_aw['subscriber_props']['ip_address'] = substr($_aw['subscriber_props']['ip_address'], 0, 60);
179
+ $_aw['subscriber_props']['ad_tracking'] = substr($_aw['subscriber_props']['ad_tracking'], 0, 20);
180
+
181
+ foreach($_aw['subscriber_props'] as $_key => $_value)
182
+ if(!$_value && $_value !== FALSE) // Empty?
183
+ unset($_aw['subscriber_props'][$_key]);
184
+ unset($_key, $_value); // Housekeeping.
185
+
186
+ $_aw['findSubscriber'] = array('email' => $args->email);
187
+ if(self::count($_aw['foundSubscribers'] = $_aw['list']->subscribers->find($_aw['findSubscriber']))
188
+ && $_aw['foundSubscribers'][0]->status !== 'unconfirmed' // i.e. `subscribed|unsubscribed`.
189
+ ) // Cannot modify an `unconfirmed` subscriber.
190
+ {
191
+ /** @var AWeberEntry $_existing_subscriber */
192
+ $_existing_subscriber = $_aw['foundSubscribers'][0];
193
+ $_existing_subscriber->status = 'subscribed'; // Subscribe.
194
+
195
+ foreach($_aw['subscriber_props'] as $_key => $_value)
196
+ if(in_array($_key, array('name', 'ad_tracking', 'custom_fields'), TRUE))
197
+ $_existing_subscriber->{$_key} = $_value;
198
+ unset($_key, $_value); // Housekeeping.
199
+
200
+ if($_existing_subscriber->save() && ($_aw['subscriber'] = $_existing_subscriber))
201
+ $_aw['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
202
+
203
+ unset($_existing_subscriber); // Housekeeping.
204
+ }
205
+ else if(($_aw['subscriber'] = $_aw['list']->subscribers->create($_aw['subscriber_props'])) && @$_aw['subscriber']->id)
206
+ $_aw['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
207
+ }
208
+ }
209
+ catch(Exception $exception)
210
+ {
211
+ $_aw['exception'] = $exception;
212
+ }
213
+ c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
214
+ }
215
+ unset($_aw_list, $_aw); // Just a little housekeeping.
216
+
217
+ return !empty($success); // If one suceeds.
218
+ }
219
+
220
+ /**
221
+ * Unsubscribe.
222
+ *
223
+ * @since 141004
224
+ * @package s2Member\List_Servers
225
+ *
226
+ * @param array $args Input arguments.
227
+ *
228
+ * @return bool True if successful.
229
+ */
230
+ public static function unsubscribe($args)
231
+ {
232
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_type'] === 'email')
233
+ return c_ws_plugin__s2member_aweber_e::unsubscribe($args);
234
+
235
+ if(!($args = self::validate_args($args)))
236
+ return FALSE; // Invalid args.
237
+
238
+ if(!$args->opt_out) // Double check.
239
+ return FALSE; // Must say explicitly.
240
+
241
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key'])
242
+ return FALSE; // Not possible.
243
+
244
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
245
+ return FALSE; // No list configured at this level.
246
+
247
+ if(!($aw_api = self::aw_api()) || !@$aw_api->___account->id)
248
+ return FALSE; // Unable to acquire API instance.
249
+
250
+ $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
251
+
252
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_aw_list)
253
+ {
254
+ $_aw = array(
255
+ 'args' => $args,
256
+ 'function' => __FUNCTION__,
257
+ 'list' => trim($_aw_list),
258
+ 'list_id' => trim($_aw_list),
259
+ 'api_method' => 'listUnsubscribe'
260
+ );
261
+ if(!$_aw['list'] || !$_aw['list_id'])
262
+ continue; // List missing.
263
+
264
+ try // Catch any AWeber exceptions that occur here.
265
+ {
266
+ if(self::count($_aw['foundLists'] = $aw_api->___account->lists->find(array('name' => $_aw['list_id']))))
267
+ if(($_aw['listUrl'] = '/accounts/'.$aw_api->___account->id.'/lists/'.$_aw['foundLists'][0]->id))
268
+ if(($_aw['list'] = $aw_api->___account->loadFromUrl($_aw['listUrl'])))
269
+ {
270
+ $_aw['findSubscriber'] = array('email' => $args->email, 'status' => 'subscribed');
271
+ if(self::count($_aw['foundSubscribers'] = $_aw['list']->subscribers->find($_aw['findSubscriber'])))
272
+ {
273
+ /** @var AWeberEntry $_existing_subscriber */
274
+ $_existing_subscriber = $_aw['foundSubscribers'][0];
275
+ $_existing_subscriber->status = 'unsubscribed'; // Unsubscribe.
276
+
277
+ if($_existing_subscriber->save() && ($_aw['subscriber'] = $_existing_subscriber))
278
+ $_aw['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
279
+
280
+ unset($_existing_subscriber); // Housekeeping.
281
+ }
282
+ }
283
+ }
284
+ catch(Exception $exception)
285
+ {
286
+ $_aw['exception'] = $exception;
287
+ }
288
+ c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
289
+ }
290
+ unset($_aw_list, $_aw); // Just a little housekeeping.
291
+
292
+ return !empty($success); // If one suceeds.
293
+ }
294
+
295
+ /**
296
+ * Transition.
297
+ *
298
+ * @since 141004
299
+ * @package s2Member\List_Servers
300
+ *
301
+ * @param array $old_args Input arguments.
302
+ * @param array $new_args Input arguments.
303
+ *
304
+ * @return bool True if successful.
305
+ */
306
+ public static function transition($old_args, $new_args)
307
+ {
308
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_type'] === 'email')
309
+ return c_ws_plugin__s2member_aweber_e::transition($old_args, $new_args);
310
+
311
+ return self::unsubscribe($old_args) && self::subscribe($new_args);
312
+ }
313
+ }
314
+ }
includes/classes/catgs-sp.inc.php CHANGED
@@ -1,89 +1,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,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Categories
15
- * @since 3.5
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit("Do not access this file directly.");
19
20
- if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
21
{
22
/**
23
- * s2Member's Category protection routines *(for specific Categories)*.
24
- *
25
- * @package s2Member\Categories
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_catgs_sp
29
- {
30
- /**
31
- * Handles Category Level Access *(for specific Categories)*.
32
- *
33
- * @package s2Member\Categories
34
- * @since 3.5
35
- *
36
- * @param int|string $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, "/") . "#x2F;", $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
}
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,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Categories
15
+ * @since 3.5
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit('Do not access this file directly.');
19
20
+ if(!class_exists('c_ws_plugin__s2member_catgs_sp'))
21
+ {
22
+ /**
23
+ * s2Member's Category protection routines *(for specific Categories)*.
24
+ *
25
+ * @package s2Member\Categories
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_catgs_sp
29
{
30
/**
31
+ * Handles Category Level Access *(for specific Categories)*.
32
+ *
33
+ * @package s2Member\Categories
34
+ * @since 3.5
35
+ *
36
+ * @param int|string $cat_id Numeric Category ID.
37
+ * @param bool $check_user Test permissions against the current User? Defaults to true.
38
+ *
39
+ * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
40
+ */
41
+ public static function check_specific_catg_level_access($cat_id = '', $check_user = TRUE)
42
+ {
43
+ do_action('ws_plugin__s2member_before_check_specific_catg_level_access', get_defined_vars());
44
45
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
46
+ $excluded = apply_filters('ws_plugin__s2member_check_specific_catg_level_access_excluded', FALSE, get_defined_vars());
47
48
+ if(!$excluded && is_numeric($cat_id) && ($cat_id = (int)$cat_id) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
49
+ {
50
+ $cat_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_category_link($cat_id));
51
52
+ if(!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $cat_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_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, '/').'#x2F;'.$ci, $cat_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
57
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', array('s2member_level_req' => 0), get_defined_vars());
58
59
+ else if(!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $cat_uri))
60
+ {
61
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--)
62
+ {
63
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
64
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', array('s2member_level_req' => $n), get_defined_vars());
65
66
+ 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)))
67
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', array('s2member_level_req' => $n), get_defined_vars());
68
69
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'])
70
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs']) as $catg)
71
+ if($catg && cat_is_ancestor_of($catg, $cat_id) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
72
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', array('s2member_level_req' => $n), get_defined_vars());
73
+ }
74
75
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--)
76
+ {
77
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'])
78
+ 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)
79
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $cat_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
80
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', array('s2member_level_req' => $n), get_defined_vars());
81
+ }
82
}
83
+ do_action('ws_plugin__s2member_during_check_specific_catg_level_access', get_defined_vars());
84
+ }
85
}
86
+ return apply_filters('ws_plugin__s2member_check_specific_catg_level_access', NULL, get_defined_vars());
87
+ }
88
}
89
+ }
includes/classes/catgs.inc.php CHANGED
@@ -1,88 +1,85 @@
1
<?php
2
/**
3
- * s2Member's Category protection routines *(for current page)*.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Categories
15
- * @since 3.5
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit("Do not access this file directly.");
19
20
- if (!class_exists ("c_ws_plugin__s2member_catgs"))
21
{
22
/**
23
- * s2Member's Category protection routines *(for current page)*.
24
- *
25
- * @package s2Member\Categories
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_catgs
29
- {
30
- /**
31
- * Handles Category Level Access *(for current page)*.
32
- *
33
- * @package s2Member\Categories
34
- * @since 3.5
35
- *
36
- * @return null Or exits script execution after redirection.
37
- */
38
- public static function check_catg_level_access ()
39
- {
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, "/") . "#x2F;", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants ('restricted') && (!$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 ('restricted') && (!$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 ('restricted') && (!$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 ('restricted') && (!$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 ('restricted') && (!$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
}
88
- ?>
1
<?php
2
/**
3
+ * s2Member's Category protection routines *(for current page)*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Categories
15
+ * @since 3.5
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit('Do not access this file directly.');
19
20
+ if(!class_exists('c_ws_plugin__s2member_catgs'))
21
+ {
22
+ /**
23
+ * s2Member's Category protection routines *(for current page)*.
24
+ *
25
+ * @package s2Member\Categories
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_catgs
29
{
30
/**
31
+ * Handles Category Level Access *(for current page)*.
32
+ *
33
+ * @package s2Member\Categories
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
37
+ */
38
+ public static function check_catg_level_access()
39
+ {
40
+ global $post; // ``get_the_ID()`` is NOT available outside The Loop.
41
42
+ do_action('ws_plugin__s2member_before_check_catg_level_access', get_defined_vars());
43
44
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
45
+ $excluded = apply_filters('ws_plugin__s2member_check_catg_level_access_excluded', FALSE, get_defined_vars());
46
47
+ if(!$excluded && is_category() && ($cat_id = get_query_var('cat')) && ($cat_id = (int)$cat_id) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
48
+ {
49
+ if(!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page())
50
+ {
51
+ $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE;
52
53
+ 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, '/').'#x2F;'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
54
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
55
56
+ else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page())
57
+ {
58
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--)
59
+ {
60
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
61
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']).exit ();
62
63
+ 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('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
64
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']).exit ();
65
66
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'] /* Check Category ancestry. */)
67
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs']) as $catg)
68
+ if($catg && cat_is_ancestor_of($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
69
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']).exit ();
70
+ }
71
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--)
72
+ {
73
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'])
74
+ foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
75
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
76
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('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
}
85
+ }
includes/classes/getresponse.inc.php ADDED
@@ -0,0 +1,196 @@
1
+ <?php
2
+ /**
3
+ * GetResponse
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @since 141004
15
+ * @package s2Member\List_Servers
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_getresponse'))
21
+ {
22
+ /**
23
+ * GetResponse
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_getresponse extends c_ws_plugin__s2member_list_server_base
29
+ {
30
+ /**
31
+ * Subscribe.
32
+ *
33
+ * @since 141004
34
+ * @package s2Member\List_Servers
35
+ *
36
+ * @param array $args Input arguments.
37
+ *
38
+ * @return bool True if successful.
39
+ */
40
+ public static function subscribe($args)
41
+ {
42
+ if(!($args = self::validate_args($args)))
43
+ return FALSE; // Invalid args.
44
+
45
+ if(!$args->opt_in) // Double check.
46
+ return FALSE; // Must say explicitly.
47
+
48
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'])
49
+ return FALSE; // Not possible.
50
+
51
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_getresponse_list_ids']))
52
+ return FALSE; // No list configured at this level.
53
+
54
+ $gr_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_getresponse_list_ids'];
55
+
56
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
57
+
58
+ foreach(preg_split('/['."\r\n\t".';,]+/', $gr_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_gr_list)
59
+ {
60
+ $_gr = array(
61
+ 'args' => $args,
62
+ 'function' => __FUNCTION__,
63
+ 'list' => trim($_gr_list),
64
+ 'list_id' => trim($_gr_list),
65
+ 'api_method' => 'add_contact'
66
+ );
67
+ if(!$_gr['list'] || !$_gr['list_id'])
68
+ continue; // List missing.
69
+
70
+ $_gr['api_method'] = 'get_contacts'; // Check if exists.
71
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
72
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
73
+ array('campaigns' => array($_gr['list_id']), 'email' => array('EQUALS' => $args->email)));
74
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
75
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error)
76
+ && ($_gr['api_response_contact_ids'] = array_keys((array)$_gr['api_response']->result)) && ($_gr['api_response_contact_id'] = $_gr['api_response_contact_ids'][0])
77
+ ) // They already exist on this list, we need to update the existing subscription here instead of adding a new one.
78
+ {
79
+ $_gr['api_method'] = 'set_contact_name'; // Update.
80
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
81
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
82
+ array('contact' => $_gr['api_response_contact_id'], 'name' => $args->name));
83
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
84
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error))
85
+ {
86
+ $_gr['api_method'] = 'set_contact_customs'; // Update.
87
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
88
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
89
+ array('contact' => $_gr['api_response_contact_id'], 'customs' => apply_filters('ws_plugin__s2member_getresponse_customs_array', array(), get_defined_vars())));
90
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
91
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error))
92
+ $_gr['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
93
+ }
94
+ }
95
+ else // Create a new contact; i.e. they do not exist yet.
96
+ {
97
+ $_gr['api_method'] = 'add_contact'; // Add new contact.
98
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
99
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
100
+ array('name' => $args->name, 'email' => $args->email, 'ip' => $args->ip,
101
+ 'campaign' => $_gr['list_id'], 'action' => 'standard', 'cycle_day' => 0,
102
+ 'customs' => apply_filters('ws_plugin__s2member_getresponse_customs_array', array(), get_defined_vars())));
103
+ if(!$_gr['api_params'][1]['ip'] || $_gr['api_params'][1]['ip'] === 'unknown') unset($_gr['api_params'][1]['ip']);
104
+
105
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
106
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error) && $_gr['api_response']->result->queued)
107
+ $_gr['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
108
+ }
109
+ c_ws_plugin__s2member_utils_logs::log_entry('getresponse-api', $_gr);
110
+ }
111
+ unset($_gr_list, $_gr); // Just a little housekeeping.
112
+
113
+ return !empty($success); // If one suceeds.
114
+ }
115
+
116
+ /**
117
+ * Unsubscribe.
118
+ *
119
+ * @since 141004
120
+ * @package s2Member\List_Servers
121
+ *
122
+ * @param array $args Input arguments.
123
+ *
124
+ * @return bool True if successful.
125
+ */
126
+ public static function unsubscribe($args)
127
+ {
128
+ if(!($args = self::validate_args($args)))
129
+ return FALSE; // Invalid args.
130
+
131
+ if(!$args->opt_out) // Double check.
132
+ return FALSE; // Must say explicitly.
133
+
134
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'])
135
+ return FALSE; // Not possible.
136
+
137
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_getresponse_list_ids']))
138
+ return FALSE; // No list configured at this level.
139
+
140
+ $gr_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_getresponse_list_ids'];
141
+
142
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
143
+
144
+ foreach(preg_split('/['."\r\n\t".';,]+/', $gr_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_gr_list)
145
+ {
146
+ $_gr = array(
147
+ 'args' => $args,
148
+ 'function' => __FUNCTION__,
149
+ 'list' => trim($_gr_list),
150
+ 'list_id' => trim($_gr_list),
151
+ 'api_method' => 'delete_contact'
152
+ );
153
+ if(!$_gr['list'] || !$_gr['list_id'])
154
+ continue; // List missing.
155
+
156
+ $_gr['api_method'] = 'get_contacts'; // Check if exists.
157
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
158
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
159
+ array('campaigns' => array($_gr['list_id']), 'email' => array('EQUALS' => $args->email)));
160
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
161
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error)
162
+ && ($_gr['api_response_contact_ids'] = array_keys((array)$_gr['api_response']->result)) && ($_gr['api_response_contact_id'] = $_gr['api_response_contact_ids'][0])
163
+ )// They exist on this list, so we can remove theme here via `delete_contact`.
164
+ {
165
+ $_gr['api_method'] = 'delete_contact'; // Delete.
166
+ $_gr['api_headers'] = array('Content-Type' => 'application/json');
167
+ $_gr['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
168
+ array('contact' => $_gr['api_response_contact_id']));
169
+ $_gr['api_request'] = json_encode(array('method' => $_gr['api_method'], 'params' => $_gr['api_params'], 'id' => uniqid('', TRUE)));
170
+ if(is_object($_gr['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $_gr['api_request'], array('headers' => $_gr['api_headers'])))) && empty($_gr['api_response']->error) && $_gr['api_response']->result->deleted)
171
+ $_gr['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
172
+ }
173
+ c_ws_plugin__s2member_utils_logs::log_entry('getresponse-api', $_gr);
174
+ }
175
+ unset($_gr_list, $_gr); // Just a little housekeeping.
176
+
177
+ return !empty($success); // If one suceeds.
178
+ }
179
+
180
+ /**
181
+ * Transition.
182
+ *
183
+ * @since 141004
184
+ * @package s2Member\List_Servers
185
+ *
186
+ * @param array $old_args Input arguments.
187
+ * @param array $new_args Input arguments.
188
+ *
189
+ * @return bool True if successful.
190
+ */
191
+ public static function transition($old_args, $new_args)
192
+ {
193
+ return self::unsubscribe($old_args) && self::subscribe($new_args);
194
+ }
195
+ }
196
+ }
includes/classes/list-server-base.inc.php ADDED
@@ -0,0 +1,118 @@
1
+ <?php
2
+ /**
3
+ * List Server Base
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @since 141004
15
+ * @package s2Member\List_Servers
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_server_base'))
21
+ {
22
+ /**
23
+ * List Server Base
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_list_server_base
29
+ {
30
+ /**
31
+ * Validates args.
32
+ *
33
+ * @since 141004
34
+ * @package s2Member\List_Servers
35
+ *
36
+ * @param array $args Input arguments.
37
+ *
38
+ * @return \stdClass|null An object with only valid properties.
39
+ * If unable to validate, this returns a `NULL` value.
40
+ */
41
+ public static function validate_args($args)
42
+ {
43
+ if(!$args || !is_array($args))
44
+ return NULL;
45
+
46
+ $defaults = array(
47
+ 'role' => '',
48
+ 'level' => '',
49
+ 'ccaps' => '',
50
+ 'login' => '',
51
+ 'pass' => '',
52
+ 'email' => '',
53
+ 'fname' => '',
54
+ 'lname' => '',
55
+ 'ip' => '',
56
+ 'opt_out' => FALSE,
57
+ 'opt_in' => FALSE,
58
+ 'double_opt_in' => FALSE,
59
+ 'user' => NULL,
60
+ 'user_id' => 0
61
+ );
62
+ $args = array_merge($defaults, $args);
63
+ $args = (object)array_intersect_key($args, $defaults);
64
+
65
+ foreach($args as $_key => &$_value)
66
+ switch($_key) // Typify.
67
+ {
68
+ case 'role':
69
+ case 'level':
70
+ $_value = (string)$_value;
71
+ break;
72
+
73
+ case 'ccaps': // Input can be a string or an array.
74
+ $_value = is_array($_value) ? implode(',', $_value) : (string)$_value;
75
+ break;
76
+
77
+ case 'login':
78
+ case 'pass':
79
+ case 'email':
80
+ case 'fname':
81
+ case 'lname':
82
+ case 'ip':
83
+ $_value = (string)$_value;
84
+ break;
85
+
86
+ case 'opt_in':
87
+ case 'double_opt_in':
88
+ $_value = (boolean)$_value;
89
+ break;
90
+
91
+ case 'user': // A `WP_User` object instance.
92
+ $_value = $_value instanceof WP_User ? $_value : NULL;
93
+ break;
94
+
95
+ case 'user_id': // User ID.
96
+ $_value = (integer)$_value;
97
+ break;
98
+ }
99
+ unset($_key, $_value); // Housekeeping.
100
+
101
+ if(!$args->user_id && $args->user && $args->user->exists())
102
+ $args->user_id = $args->user->ID; // Use this ID.
103
+ $args->user = new WP_User($args->user_id); // Always based on ID.
104
+
105
+ $args->ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($args->user));
106
+ $args->fname = !$args->fname ? ucwords((string)strstr($args->email, '@', TRUE)) : $args->fname;
107
+ $args->lname = !$args->lname ? '-' : $args->lname; // Default last name to `-` because MC requires this.
108
+ $args->name = $args->fname || $args->lname ? trim($args->fname.' '.$args->lname) : ucwords((string)strstr($args->email, '@', TRUE));
109
+
110
+ if(!$args->role || !isset($args->level[0]) || !is_numeric($args->level)
111
+ || !$args->login || !$args->email || !is_email($args->email)
112
+ || !$args->user_id || !$args->user || !$args->user->exists()
113
+ ) return NULL; // Required arguments missing.
114
+
115
+ return $args; // Now a \stdClass object.
116
+ }
117
+ }
118
+ }
includes/classes/list-servers.inc.php CHANGED
@@ -28,245 +28,66 @@ if(!class_exists('c_ws_plugin__s2member_list_servers'))
28
class c_ws_plugin__s2member_list_servers
29
{
30
/**
31
- * Determines whether or not any List Servers have been integrated.
32
*
33
- * @package s2Member\List_Servers
34
* @since 3.5
35
- *
36
- * @return bool True if List Servers have been integrated, else false.
37
- */
38
- public static function list_servers_integrated()
39
- {
40
- do_action('ws_plugin__s2member_before_list_servers_integrated', get_defined_vars());
41
-
42
- for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++ /* Go through each Level; looking for a configured list. */)
43
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_mailchimp_list_ids']) || !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_getresponse_list_ids']) || !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_aweber_list_ids']))
44
- return apply_filters('ws_plugin__s2member_list_servers_integrated', TRUE, get_defined_vars());
45
-
46
- return apply_filters('ws_plugin__s2member_list_servers_integrated', FALSE, get_defined_vars());
47
- }
48
-
49
- /**
50
- * Processes List Server integrations for s2Member.
51
- *
52
* @package s2Member\List_Servers
53
- * @since 3.5
54
*
55
- * @param string $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`.
56
- * @param int|string $level A numeric s2Member Access Level number.
57
- * @param string $login Username for the User.
58
- * @param string $pass Plain Text Password for the User.
59
- * @param string $email Email Address for the User.
60
- * @param string $fname First Name for the User.
61
- * @param string $lname Last Name for the User.
62
- * @param string $ip IP Address for the User.
63
- * @param bool $opt_in Defaults to false; must be set to true. Indicates the User IS opting in.
64
- * @param bool $double_opt_in Defaults to true. If false, no email confirmation is required. Use at your own risk.
65
* @param int|string $user_id A WordPress User ID, numeric string or integer.
66
*
67
- * @return bool True if at least one List Server is processed successfully, else false.
68
- *
69
- * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
70
- * @todo Add a separate option for mail debugging; or consolidate?
71
- * @todo Integrate AWeber API (much like the MailChimp API).
72
*/
73
- public static function process_list_servers($role = '', $level = '', $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '', $opt_in = FALSE, $double_opt_in = TRUE, $user_id = 0)
74
{
75
- global $current_site, $current_blog; // For Multisite support.
76
-
77
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
78
do_action('ws_plugin__s2member_before_process_list_servers', get_defined_vars());
79
- unset($__refs, $__v);
80
81
- 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))
82
{
83
- $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
84
-
85
- $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
86
- c_ws_plugin__s2member_email_configs::email_config_release( /* Release s2Member Filters before we begin this routine. */);
87
-
88
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_mailchimp_list_ids']))
89
- {
90
- if(!class_exists('NC_MCAPI')) // Include the MailChimp API Class here.
91
- include_once dirname(dirname(__FILE__)).'/externals/mailchimp/nc-mcapi.inc.php';
92
-
93
- $mcapi = new NC_MCAPI ($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], TRUE);
94
-
95
- foreach(preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_mailchimp_list_ids']) as $mailchimp_list)
96
- {
97
- $mailchimp = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_method' => 'listSubscribe');
98
-
99
- if(($mailchimp['list'] = trim($mailchimp_list)))
100
- {
101
- if(strpos($mailchimp['list'], '::') !== FALSE) // Also contains Interest Groups?
102
- {
103
- list ($mailchimp['list_id'], $mailchimp['interest_groups_title'], $mailchimp['interest_groups']) = preg_split('/\:\:/', $mailchimp['list'], 3);
104
-
105
- if(($mailchimp['interest_groups_title'] = trim($mailchimp['interest_groups_title'])) /* This is a title configured by the list master. */)
106
- if(($mailchimp['interest_groups'] = (trim($mailchimp['interest_groups'])) ? preg_split('/\|/', trim($mailchimp['interest_groups'])) : FALSE))
107
- $mailchimp['interest_groups'] = array('GROUPINGS' => array(array('name' => $mailchimp['interest_groups_title'], 'groups' => implode(',', $mailchimp['interest_groups']))));
108
-
109
- if(empty($mailchimp['list_id']) /* Need to double-check this. If empty, skip over this entry. */)
110
- continue; // Continue to next List, if there is one.
111
- }
112
- else $mailchimp['list_id'] = $mailchimp['list']; // Else, it's just a List ID.
113
114
- $fname = (!$fname) ? ucwords(strstr($email, '@', TRUE)) : $fname;
115
- $lname = (!$lname) ? '-' : $lname;
116
- $name = ($fname || $lname) ? trim($fname.' '.$lname) : ucwords(preg_replace('/^(.+?)@.+/', '$1', $email));
117
- $mailchimp['merge_array'] = array('MERGE1' => $fname, 'MERGE2' => $lname, 'OPTIN_IP' => $ip, 'OPTIN_TIME' => date('Y-m-d H:i:s'));
118
- $mailchimp['merge_array'] = (!empty($mailchimp['interest_groups'])) ? array_merge($mailchimp['merge_array'], $mailchimp['interest_groups']) : $mailchimp['merge_array'];
119
- $mailchimp['merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_array', $mailchimp['merge_array'], get_defined_vars()); // Deprecated.
120
- // Filter: `ws_plugin__s2member_mailchimp_array` deprecated in v110523. Please use Filter: `ws_plugin__s2member_mailchimp_merge_array`.
121
-
122
- if($mailchimp['api_response'] = $mcapi->{$mailchimp['api_method']}($mailchimp['list_id'], $email, // See: `http://apidocs.mailchimp.com/` for full details.
123
- ($mailchimp['api_merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_merge_array', $mailchimp['merge_array'], get_defined_vars())), // Configured merge array above.
124
- ($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).
125
- ($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.
126
- ($mailchimp['api_update_existing'] = apply_filters('ws_plugin__s2member_mailchimp_update_existing', TRUE, get_defined_vars())), // Existing subscribers should be updated with this?
127
- ($mailchimp['api_replace_interests'] = apply_filters('ws_plugin__s2member_mailchimp_replace_interests', TRUE, get_defined_vars())), // Replace interest groups? (only if provided).
128
- ($mailchimp['api_send_welcome'] = apply_filters('ws_plugin__s2member_mailchimp_send_welcome', FALSE, get_defined_vars())))
129
- ) $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.
130
-
131
- $mailchimp['api_properties'] = $mcapi; // Include API instance too; as it contains some additional information for logs.
132
-
133
- $logt = c_ws_plugin__s2member_utilities::time_details();
134
- $logv = c_ws_plugin__s2member_utilities::ver_details();
135
- $logm = c_ws_plugin__s2member_utilities::mem_details();
136
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
137
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
138
- $log2 = (is_multisite() && !is_main_site()) ? 'mailchimp-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'mailchimp-api.log';
139
-
140
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
141
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
142
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
143
- file_put_contents($logs_dir.'/'.$log2,
144
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
145
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($mailchimp, TRUE))."\n\n",
146
- FILE_APPEND);
147
- }
148
- }
149
- }
150
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_getresponse_list_ids']))
151
- {
152
- foreach(preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_getresponse_list_ids']) as $getresponse_list)
153
- {
154
- $getresponse = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_method' => 'add_contact');
155
-
156
- if(($getresponse['list_id'] = $getresponse['list'] = trim($getresponse_list)))
157
- {
158
- $getresponse['api_method'] = 'add_contact';
159
- $getresponse['api_headers'] = array('Content-Type' => 'application/json');
160
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('campaigns' => array($getresponse['list_id']), 'email' => array('EQUALS' => $email)));
161
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
162
- $name = ($fname || $lname) ? trim($fname.' '.$lname) : ucwords(preg_replace('/^(.+?)@.+/', '$1', $email));
163
-
164
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && ($getresponse['api_response_contact_ids'] = array_keys((array)$getresponse['api_response']->result)) && ($getresponse['api_response_contact_id'] = $getresponse['api_response_contact_ids'][0]))
165
- {
166
- $getresponse['api_method'] = 'set_contact_name';
167
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('contact' => $getresponse['api_response_contact_id'], 'name' => $name));
168
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
169
-
170
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error))
171
- {
172
- $getresponse['api_method'] = 'set_contact_customs';
173
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('contact' => $getresponse['api_response_contact_id'], 'customs' => apply_filters('ws_plugin__s2member_getresponse_customs_array', array(), get_defined_vars())));
174
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
175
-
176
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error))
177
- $getresponse['api_success'] = $success = TRUE;
178
- }
179
- }
180
- else // Create a new contact; i.e. they do not exist on this list yet.
181
- {
182
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'],
183
- array('name' => $name, 'email' => $email, 'ip' => $ip,
184
- 'campaign' => $getresponse['list_id'], 'action' => 'standard', 'cycle_day' => 0,
185
- 'customs' => apply_filters('ws_plugin__s2member_getresponse_customs_array', array(), get_defined_vars())));
186
- if(!$getresponse['api_params'][1]['ip'] || $getresponse['api_params'][1]['ip'] === 'unknown') unset($getresponse['api_params'][1]['ip']);
187
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
188
-
189
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && $getresponse['api_response']->result->queued)
190
- $getresponse['api_success'] = $success = TRUE;
191
- }
192
- $logt = c_ws_plugin__s2member_utilities::time_details();
193
- $logv = c_ws_plugin__s2member_utilities::ver_details();
194
- $logm = c_ws_plugin__s2member_utilities::mem_details();
195
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
196
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
197
- $log2 = (is_multisite() && !is_main_site()) ? 'getresponse-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'getresponse-api.log';
198
-
199
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
200
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
201
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
202
- file_put_contents($logs_dir.'/'.$log2,
203
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
204
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($getresponse, TRUE))."\n\n",
205
- FILE_APPEND);
206
- }
207
- }
208
- }
209
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_aweber_list_ids']))
210
- {
211
- foreach(preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_aweber_list_ids']) as $aweber_list)
212
- {
213
- $aweber = array('function' => __FUNCTION__, 'func_get_args' => $args, 'wp_mail_method' => 'listSubscribe');
214
-
215
- if(($aweber['list_id'] = trim($aweber_list)))
216
- {
217
- $aweber['bcc'] = apply_filters('ws_plugin__s2member_aweber_bcc', FALSE, get_defined_vars());
218
- $aweber['pass_inclusion'] = (apply_filters('ws_plugin__s2member_aweber_pass_inclusion', FALSE, get_defined_vars()) && $pass) ? '\nPass: '.$pass : FALSE;
219
- $name = $buyer = ($fname || $lname) ? trim($fname.' '.$lname) : ucwords(preg_replace('/^(.+?)@.+/', '$1', $email)); // Must have. AWeber's PayPal Email Parser chokes on an empty value.
220
-
221
- if($aweber['wp_mail_response'] = wp_mail($aweber['list_id'].'@aweber.com', // AWeber List ID converts to email address @aweber.com.
222
- ($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.
223
- ($aweber['wp_mail_msg'] = apply_filters('ws_plugin__s2member_aweber_msg', 's2Member Subscription Request'."\n".'s2Member w/ PayPal Email ID'."\n".'Ad Tracking: s2Member-'.((is_multisite() && !is_main_site()) ? $current_blog->domain.$current_blog->path : $_SERVER['HTTP_HOST'])."\n".'EMail Address: '.$email."\n".'Buyer: '.$buyer."\n".'Full Name: '.trim($fname.' '.$lname)."\n".'First Name: '.$fname."\n".'Last Name: '.$lname."\n".'IP Address: '.$ip."\n".'User ID: '.$user_id."\n".'Login: '.$login.$aweber['pass_inclusion']."\n".'Role: '.$role."\n".'Level: '.$level."\n".'CCaps: '.$ccaps."\n".' - end.', get_defined_vars())),
224
- ($aweber['wp_mail_headers'] = 'From: "'.preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']).'" <'.$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'].'>'.(($aweber['bcc']) ? "\r\n".'Bcc: '.$aweber['bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
225
- ) $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.
226
-
227
- $logt = c_ws_plugin__s2member_utilities::time_details();
228
- $logv = c_ws_plugin__s2member_utilities::ver_details();
229
- $logm = c_ws_plugin__s2member_utilities::mem_details();
230
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
231
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
232
- $log2 = (is_multisite() && !is_main_site()) ? 'aweber-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'aweber-api.log';
233
234
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
235
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
236
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
237
- file_put_contents($logs_dir.'/'.$log2,
238
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
239
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($aweber, TRUE))."\n\n",
240
- FILE_APPEND);
241
- }
242
- }
243
- }
244
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
245
do_action('ws_plugin__s2member_during_process_list_servers', get_defined_vars());
246
- unset($__refs, $__v);
247
-
248
- if($email_configs_were_on)
249
- c_ws_plugin__s2member_email_configs::email_config();
250
-
251
- if($user_id) update_user_option($user_id, 's2member_opt_in', '1');
252
}
253
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
254
do_action('ws_plugin__s2member_after_process_list_servers', get_defined_vars());
255
- unset($__refs, $__v);
256
257
- return apply_filters('ws_plugin__s2member_process_list_servers', (isset ($success) && $success), get_defined_vars());
258
}
259
260
/**
261
- * See {@link process_list_servers()} for further details about this wrapper.
262
*
263
- * @param bool $opt_in Defaults to false; must be set to true. Indicates the User IS opting in.
264
- * @param bool $double_opt_in Defaults to true. If false, no email confirmation is required. Use at your own risk.
265
- * @param bool $clean_user_cache Defaults to true; i.e. we start from a fresh copy of the current user.
266
*
267
- * @return bool True if at least one List Server is processed successfully, else false.
268
*/
269
- public static function process_list_servers_against_current_user($opt_in = TRUE, $double_opt_in = TRUE, $clean_user_cache = TRUE)
270
{
271
if($clean_user_cache) // Start from a fresh user object here?
272
{
@@ -284,188 +105,72 @@ if(!class_exists('c_ws_plugin__s2member_list_servers'))
284
($email = $user->user_email),
285
($fname = $user->first_name),
286
($lname = $user->last_name),
287
- ($ip = $_SERVER['REMOTE_ADDR']),
288
- ($opt_in = $opt_in), ($double_opt_in = $double_opt_in),
289
($user_id = $user->ID)
290
);
291
}
292
293
/**
294
- * Processes List Server removals for s2Member.
295
*
296
- * @package s2Member\List_Servers
297
* @since 3.5
298
*
299
- * @param string $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`.
300
- * @param int|string $level A numeric s2Member Access Level number.
301
- * @param string $login Username for the User.
302
- * @param string $pass Plain Text Password for the User.
303
- * @param string $email Email address for the User.
304
- * @param string $fname First Name for the User.
305
- * @param string $lname Last Name for the User.
306
- * @param string $ip IP Address for the User.
307
- * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out.
308
* @param int|string $user_id A WordPress User ID, numeric string or integer.
309
*
310
- * @return bool True if at least one List Server is processed successfully, else false.
311
- *
312
- * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
313
- * @todo Add a separate option for mail debugging; or consolidate?
314
- * @todo Integrate AWeber API (much like the MailChimp API).
315
*/
316
- public static function process_list_server_removals($role = '', $level = '', $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '', $opt_out = FALSE, $user_id = 0)
317
{
318
- global $current_site, $current_blog; // For Multisite support.
319
-
320
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
321
do_action('ws_plugin__s2member_before_process_list_server_removals', get_defined_vars());
322
- unset($__refs, $__v);
323
324
- 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))
325
{
326
- $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
327
-
328
- $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
329
- c_ws_plugin__s2member_email_configs::email_config_release( /* Release s2Member Filters before we begin this routine. */);
330
-
331
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_mailchimp_list_ids']))
332
- {
333
- if(!class_exists('NC_MCAPI')) // Include the MailChimp API Class here.
334
- include_once dirname(dirname(__FILE__)).'/externals/mailchimp/nc-mcapi.inc.php';
335
-
336
- $mcapi = new NC_MCAPI ($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], TRUE);
337
-
338
- foreach(preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_mailchimp_list_ids']) as $mailchimp_list)
339
- {
340
- $mailchimp = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'listUnsubscribe');
341
-
342
- if(($mailchimp['list_id'] = trim(preg_replace('/\:\:.*#x2F;', '', $mailchimp_list))))
343
- {
344
- if($mailchimp['api_removal_response'] = $mcapi->{$mailchimp['api_removal_method']}($mailchimp['list_id'], $email, // See: `http://apidocs.mailchimp.com/`.
345
- ($mailchimp['api_removal_delete_member'] = apply_filters('ws_plugin__s2member_mailchimp_removal_delete_member', FALSE, get_defined_vars())), // Completely delete?
346
- ($mailchimp['api_removal_send_goodbye'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_goodbye', FALSE, get_defined_vars())), // Send goodbye letter?
347
- ($mailchimp['api_removal_send_notify'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_notify', FALSE, get_defined_vars())))
348
- ) $mailchimp['api_removal_success'] = $removal_success = TRUE; // Flag indicating that we DO have a successful removal; affects the function's overall return value.
349
- $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).
350
-
351
- $logt = c_ws_plugin__s2member_utilities::time_details();
352
- $logv = c_ws_plugin__s2member_utilities::ver_details();
353
- $logm = c_ws_plugin__s2member_utilities::mem_details();
354
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
355
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
356
- $log2 = (is_multisite() && !is_main_site()) ? 'mailchimp-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'mailchimp-api.log';
357
-
358
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
359
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
360
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
361
- file_put_contents($logs_dir.'/'.$log2,
362
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
363
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($mailchimp, TRUE))."\n\n",
364
- FILE_APPEND);
365
- }
366
- }
367
- }
368
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_getresponse_list_ids']))
369
- {
370
- foreach(preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_getresponse_list_ids']) as $getresponse_list)
371
- {
372
- $getresponse = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'delete_contact');
373
-
374
- if(($getresponse['list_id'] = $getresponse['list'] = trim($getresponse_list)))
375
- {
376
- $getresponse['api_method'] = 'get_contacts';
377
- $getresponse['api_headers'] = array('Content-Type' => 'application/json');
378
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('campaigns' => array($getresponse['list_id']), 'email' => array('EQUALS' => $email)));
379
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
380
-
381
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && ($getresponse['api_response_contact_ids'] = array_keys((array)$getresponse['api_response']->result)) && ($getresponse['api_response_contact_id'] = $getresponse['api_response_contact_ids'][0]))
382
- {
383
- $getresponse['api_method'] = 'delete_contact'; // Update method now.
384
- $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('contact' => $getresponse['api_response_contact_id']));
385
- $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
386
-
387
- if(is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && $getresponse['api_response']->result->deleted)
388
- $getresponse['api_success'] = $success = TRUE;
389
- }
390
- $logt = c_ws_plugin__s2member_utilities::time_details();
391
- $logv = c_ws_plugin__s2member_utilities::ver_details();
392
- $logm = c_ws_plugin__s2member_utilities::mem_details();
393
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
394
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
395
- $log2 = (is_multisite() && !is_main_site()) ? 'getresponse-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'getresponse-api.log';
396
-
397
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
398
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
399
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
400
- file_put_contents($logs_dir.'/'.$log2,
401
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
402
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($getresponse, TRUE))."\n\n",
403
- FILE_APPEND);
404
- }
405
- }
406
- }
407
- if(!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_aweber_list_ids']))
408
- {
409
- foreach(preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_aweber_list_ids']) as $aweber_list)
410
- {
411
- $aweber = array('function' => __FUNCTION__, 'func_get_args' => $args, 'wp_mail_removal_method' => 'listUnsubscribe');
412
-
413
- if(($aweber['list_id'] = trim($aweber_list)))
414
- {
415
- $aweber['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars());
416
417
- c_ws_plugin__s2member_email_configs::email_config(); // Email configs MUST be ON for removal requests.
418
- // The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
419
-
420
- if($aweber['wp_mail_removal_response'] = wp_mail($aweber['list_id'].'@aweber.com', // AWeber List ID converts to email address @aweber.com.
421
- ($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`.
422
- ($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\n".'Bcc: '.$aweber['removal_bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
423
- ) $aweber['wp_mail_removal_success'] = $removal_success = TRUE; // Flag indicating that we DO have a successful removal; affects the function's overall return value.
424
-
425
- c_ws_plugin__s2member_email_configs::email_config_release( /* Release. */);
426
-
427
- $logt = c_ws_plugin__s2member_utilities::time_details();
428
- $logv = c_ws_plugin__s2member_utilities::ver_details();
429
- $logm = c_ws_plugin__s2member_utilities::mem_details();
430
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
431
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
432
- $log2 = (is_multisite() && !is_main_site()) ? 'aweber-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'aweber-api.log';
433
-
434
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
435
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
436
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
437
- file_put_contents($logs_dir.'/'.$log2,
438
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
439
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($aweber, TRUE))."\n\n",
440
- FILE_APPEND);
441
- }
442
- }
443
- }
444
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
445
do_action('ws_plugin__s2member_during_process_list_server_removals', get_defined_vars());
446
- unset($__refs, $__v);
447
-
448
- if($email_configs_were_on)
449
- c_ws_plugin__s2member_email_configs::email_config();
450
451
if($user_id) update_user_option($user_id, 's2member_opt_in', '0');
452
}
453
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
454
do_action('ws_plugin__s2member_after_process_list_server_removals', get_defined_vars());
455
- unset($__refs, $__v);
456
457
- return apply_filters('ws_plugin__s2member_process_list_server_removals', (isset ($removal_success) && $removal_success), get_defined_vars());
458
}
459
460
/**
461
- * See {@link process_list_server_removals()} for further details about this wrapper.
462
*
463
- * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out.
464
- * @param bool $clean_user_cache Defaults to true; i.e. we start from a fresh copy of the current user.
465
*
466
- * @return bool True if at least one List Server removal is processed successfully, else false.
467
*/
468
- public static function process_list_server_removals_against_current_user($opt_out = TRUE, $clean_user_cache = TRUE)
469
{
470
if($clean_user_cache) // Start from a fresh user object here?
471
{
@@ -483,73 +188,114 @@ if(!class_exists('c_ws_plugin__s2member_list_servers'))
483
($email = $user->user_email),
484
($fname = $user->first_name),
485
($lname = $user->last_name),
486
- ($ip = $_SERVER['REMOTE_ADDR']),
487
($opt_out = $opt_out),
488
($user_id = $user->ID)
489
);
490
}
491
492
/**
493
- * Listens to Collective EOT/MOD Events processed internally by s2Member.
494
- *
495
- * This is only applicable when ``['custom_reg_auto_opt_outs']`` contains related Event(s).
496
*
497
- * @package s2Member\List_Servers
498
* @since 3.5
499
*
500
- * @attaches-to ``add_action('ws_plugin__s2member_during_collective_mods');``
501
- * @attaches-to ``add_action('ws_plugin__s2member_during_collective_eots');``
502
*
503
* @param int|string $user_id Required. A WordPress User ID, numeric string or integer.
504
- * @param array $vars Required. An array of defined variables passed by the calling Hook.
505
- * @param string $event Required. A specific event that triggered this call from the Action Hook.
506
* @param string $event_spec Required. A specific event specification *(a broader classification)*.
507
- * @param string $mod_new_role Required if ``$event_spec === 'modification'`` (but can be empty). Role the User is being modified to.
508
- * @param string $mod_new_user Optional. If ``$event_spec === 'modification'``, the new User object with current details.
509
- * @param string $mod_old_user Optional. If ``$event_spec === 'modification'``, the old/previous User obj with old details.
510
*/
511
public static function auto_process_list_server_removals($user_id, $vars, $event, $event_spec, $mod_new_role = NULL, $mod_new_user = NULL, $mod_old_user = NULL)
512
{
513
- global $current_site, $current_blog; // For Multisite support.
514
- static $auto_processed = array( /* Process ONE time for each User. */);
515
516
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
517
do_action('ws_plugin__s2member_before_auto_process_list_server_removals', get_defined_vars());
518
- unset($__refs, $__v);
519
-
520
- $custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_auto_opt_outs'], '/^', '#x2F;i');
521
-
522
- 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))
523
- {
524
- $mod_new_role = ($event_spec === 'modification' && $mod_new_role && is_string($mod_new_role)) ? $mod_new_role : FALSE; // Might be empty(i.e. they now have NO Role).
525
- $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;
526
- $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;
527
-
528
- $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?
529
-
530
- if(($event_spec !== 'modification' || ($event_spec === 'modification' && (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))
531
- {
532
- $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);
533
-
534
- 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)))
535
- {
536
- $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?
537
538
- $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);
539
540
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
541
- do_action('ws_plugin__s2member_during_auto_process_list_server_removal_transitions', get_defined_vars());
542
- unset($__refs, $__v);
543
- }
544
545
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
546
- do_action('ws_plugin__s2member_during_auto_process_list_server_removals', get_defined_vars());
547
- unset($__refs, $__v);
548
- }
549
- }
550
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
551
- do_action('ws_plugin__s2member_after_auto_process_list_server_removals', get_defined_vars());
552
- unset($__refs, $__v);
553
}
554
}
555
}
28
class c_ws_plugin__s2member_list_servers
29
{
30
/**
31
+ * Processes list server integrations.
32
*
33
* @since 3.5
34
* @package s2Member\List_Servers
35
*
36
+ * @param string $role A WP role.
37
+ * @param int|string $level A numeric level.
38
+ * @param string $login Username for the user.
39
+ * @param string $pass Plain text password for the User.
40
+ * @param string $email Email address for the user.
41
+ * @param string $fname First name for the user.
42
+ * @param string $lname Last name for the user.
43
+ * @param string $ip IP address for the user.
44
+ * @param bool $opt_in Defaults to `FALSE`; must be set to `TRUE`.
45
+ * @param bool $double_opt_in Defaults to `TRUE`. Use at your own risk.
46
* @param int|string $user_id A WordPress User ID, numeric string or integer.
47
*
48
+ * @return bool True if at least one list server is processed successfully.
49
*/
50
+ public static function process_list_servers($role = '', $level = '',
51
+ $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '',
52
+ $opt_in = FALSE, $double_opt_in = TRUE,
53
+ $user_id = 0)
54
{
55
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $__v;
56
do_action('ws_plugin__s2member_before_process_list_servers', get_defined_vars());
57
+ unset($__refs, $__v); // Allows vars to be modified by reference.
58
59
+ if(c_ws_plugin__s2member_list_servers::list_servers_integrated())
60
{
61
+ $args = get_defined_vars(); // Function args.
62
+ $mailchimp_success = c_ws_plugin__s2member_mailchimp::subscribe($args);
63
+ $getresponse_success = c_ws_plugin__s2member_getresponse::subscribe($args);
64
+ $aweber_success = c_ws_plugin__s2member_aweber::subscribe($args);
65
+ $success = $mailchimp_success || $getresponse_success || $aweber_success;
66
67
+ if($user_id) update_user_option($user_id, 's2member_opt_in', '1');