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 (76) 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
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 ("/\:(.*)$/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('/\:(.*)$/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, "/") . "$/", $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, '/').'$/'.$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, "/") . "$/", $_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, '/').'$/'.$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('/\:\:.*$/', '', $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'], '/^', '$/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');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
 
 
 
 
 
 
 
 
 
 
 
69
  do_action('ws_plugin__s2member_during_process_list_servers', get_defined_vars());
 
 
 
 
 
 
70
  }
 
71
  do_action('ws_plugin__s2member_after_process_list_servers', get_defined_vars());
 
72
 
73
+ return apply_filters('ws_plugin__s2member_process_list_servers', !empty($success), get_defined_vars());
74
  }
75
 
76
  /**
77
+ * Process list servers against current user.
78
  *
79
+ * @since 141004
80
+ * @package s2Member\List_Servers
81
+ *
82
+ * See {@link process_list_servers()} for further details.
83
+ *
84
+ * @param bool $opt_in Defaults to `FALSE`; must be set to `TRUE`.
85
+ * @param bool $double_opt_in Defaults to `TRUE`. Use at your own risk.
86
+ * @param bool $clean_user_cache Defaults to `TRUE`; i.e. we start from a fresh copy of the current user.
87
  *
88
+ * @return bool True if at least one list server is processed successfully.
89
  */
90
+ public static function process_list_servers_against_current_user($opt_in = FALSE, $double_opt_in = TRUE, $clean_user_cache = TRUE)
91
  {
92
  if($clean_user_cache) // Start from a fresh user object here?
93
  {
105
  ($email = $user->user_email),
106
  ($fname = $user->first_name),
107
  ($lname = $user->last_name),
108
+ ($ip = @$_SERVER['REMOTE_ADDR']),
109
+ ($opt_in = $opt_in),
110
+ ($double_opt_in = $double_opt_in),
111
  ($user_id = $user->ID)
112
  );
113
  }
114
 
115
  /**
116
+ * Processes list server removals.
117
  *
 
118
  * @since 3.5
119
+ * @package s2Member\List_Servers
120
  *
121
+ * @param string $role A WP role.
122
+ * @param int|string $level A numeric level.
123
+ * @param string $login Username for the user.
124
+ * @param string $pass Plain text password for the User.
125
+ * @param string $email Email address for the user.
126
+ * @param string $fname First name for the user.
127
+ * @param string $lname Last name for the user.
128
+ * @param string $ip IP address for the user.
129
+ * @param bool $opt_out Defaults to `FALSE`; must be set to `TRUE`.
130
  * @param int|string $user_id A WordPress User ID, numeric string or integer.
131
  *
132
+ * @return bool True if at least one list server removal is processed successfully.
 
 
 
 
133
  */
134
+ public static function process_list_server_removals($role = '', $level = '',
135
+ $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '',
136
+ $opt_out = FALSE,
137
+ $user_id = 0)
138
  {
 
 
139
  foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
140
  do_action('ws_plugin__s2member_before_process_list_server_removals', get_defined_vars());
141
+ unset($__refs, $__v); // Allows vars to be modified by reference.
142
 
143
+ if(c_ws_plugin__s2member_list_servers::list_servers_integrated())
144
  {
145
+ $args = get_defined_vars(); // Function args.
146
+ $mailchimp_success = c_ws_plugin__s2member_mailchimp::unsubscribe($args);
147
+ $getresponse_success = c_ws_plugin__s2member_getresponse::unsubscribe($args);
148
+ $aweber_success = c_ws_plugin__s2member_aweber::unsubscribe($args);
149
+ $success = $mailchimp_success || $getresponse_success || $aweber_success;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  do_action('ws_plugin__s2member_during_process_list_server_removals', get_defined_vars());
 
 
 
 
152
 
153
  if($user_id) update_user_option($user_id, 's2member_opt_in', '0');
154
  }
 
155
  do_action('ws_plugin__s2member_after_process_list_server_removals', get_defined_vars());
 
156
 
157
+ return apply_filters('ws_plugin__s2member_process_list_server_removals', !empty($success), get_defined_vars());
158
  }
159
 
160
  /**
161
+ * Process list server removals against current user.
162
  *
163
+ * See {@link process_list_server_removals()} for further details.
 
164
  *
165
+ * @since 141004
166
+ * @package s2Member\List_Servers
167
+ *
168
+ * @param bool $opt_out Defaults to `FALSE`; must be set to `TRUE`.
169
+ * @param bool $clean_user_cache Defaults to `TRUE`; i.e. we start from a fresh copy of the current user.
170
+ *
171
+ * @return bool True if at least one list server removal is processed successfully.
172
  */
173
+ public static function process_list_server_removals_against_current_user($opt_out = FALSE, $clean_user_cache = TRUE)
174
  {
175
  if($clean_user_cache) // Start from a fresh user object here?
176
  {
188
  ($email = $user->user_email),
189
  ($fname = $user->first_name),
190
  ($lname = $user->last_name),
191
+ ($ip = @$_SERVER['REMOTE_ADDR']),
192
  ($opt_out = $opt_out),
193
  ($user_id = $user->ID)
194
  );
195
  }
196
 
197
  /**
198
+ * Listens to Collective EOT/MOD events processed by s2Member.
 
 
199
  *
 
200
  * @since 3.5
201
+ * @package s2Member\List_Servers
202
  *
203
+ * @attaches-to `add_action('ws_plugin__s2member_during_collective_mods');`.
204
+ * @attaches-to `add_action('ws_plugin__s2member_during_collective_eots');`.
205
  *
206
  * @param int|string $user_id Required. A WordPress User ID, numeric string or integer.
207
+ * @param array $vars Required. An array of defined variables passed by the calling hook.
208
+ * @param string $event Required. A specific event that triggered this call from the action hook.
209
  * @param string $event_spec Required. A specific event specification *(a broader classification)*.
210
+ * @param string $mod_new_role Required if `$event_spec === 'modification'`; but can be empty. User role.
211
+ * @param string $mod_new_user Optional. If `$event_spec === 'modification'`, the new user object with current details.
212
+ * @param string $mod_old_user Optional. If `$event_spec === 'modification'`, the old/previous user obj with old details.
213
+ *
214
+ * @note This is only applicable when `['custom_reg_auto_opt_outs']` contains related Event(s).
215
  */
216
  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)
217
  {
218
+ static $auto_processed = array(); // Static cache.
 
219
 
220
  foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
221
  do_action('ws_plugin__s2member_before_auto_process_list_server_removals', get_defined_vars());
222
+ unset($__refs, $__v); // Allows vars to be modified by reference.
223
+
224
+ if(c_ws_plugin__s2member_list_servers::list_servers_integrated())
225
+ if($user_id && is_numeric($user_id) && !isset($auto_processed[$user_id]))
226
+ if(is_array($vars) && is_string($event = (string)$event) && is_string($event_spec = (string)$event_spec))
227
+ if(($custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_auto_opt_outs'], '/^', '$/i')))
228
+ if(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))
229
+ if(is_object($dynamic_user = $user_now = new WP_User($user_id)) && $dynamic_user->exists() && !empty($dynamic_user->ID))
230
+ {
231
+ $mod_new_role = $event_spec === 'modification' && is_string($mod_new_role) ? $mod_new_role : ''; // Might be empty.
232
+ $mod_new_user = $event_spec === 'modification' && !empty($mod_new_user->ID) && $mod_new_user->ID === $dynamic_user->ID ? $mod_new_user : NULL;
233
+ $mod_old_user = $event_spec === 'modification' && !empty($mod_old_user->ID) && $mod_old_user->ID === $dynamic_user->ID ? $mod_old_user : NULL;
234
+ $dynamic_user = $event_spec === 'modification' && $mod_old_user ? $mod_old_user : $user_now; // Use old user when applicable.
235
+
236
+ if( // Secondary conditionals.
237
+
238
+ ($event_spec !== 'modification' // Not a modification.
239
+
240
+ || ($event_spec === 'modification' // Or it is, with a role change!
241
+ && $mod_new_role !== c_ws_plugin__s2member_user_access::user_access_role($dynamic_user)
242
+ && strtotime($dynamic_user->user_registered) < strtotime('-10 seconds') // Hackety hack.
243
+ && ($event !== 'user-role-change' // Ignore this event, UNLESS it has confirmation.
244
+ || ($event === 'user-role-change' // An admin has specifically asked for this to occur?
245
+ && !empty($vars['_p']['ws_plugin__s2member_custom_reg_auto_opt_out_transitions']))))
246
+ )
247
+ ) // Let us proceed now; with list removals at the very least.
248
+ {
249
+ $auto_processed[$dynamic_user->ID] = -1; // Flag as auto-processed!
250
+
251
+ $auto_removal_success = c_ws_plugin__s2member_list_servers::process_list_server_removals
252
+ (
253
+ c_ws_plugin__s2member_user_access::user_access_role($dynamic_user), // Old role w/ modifications.
254
+ c_ws_plugin__s2member_user_access::user_access_level($dynamic_user), // Old level w/ modifications.
255
+ $dynamic_user->user_login, '', $dynamic_user->user_email, $dynamic_user->first_name, $dynamic_user->last_name, '', TRUE, $dynamic_user->ID
256
+ );
257
+ if( // Now let's determine if they should be subscribed to the new lists.
258
+
259
+ $event_spec === 'modification' && $mod_new_role // And they have a role now?
260
+ && ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_auto_opt_out_transitions'] === '2'
261
+ || ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_auto_opt_out_transitions'] === '1' && $auto_removal_success))
262
+
263
+ ) // Let us proceed now; we want to subscribe the user to the list they should be on now; based on role/level.
264
+ {
265
+ $dynamic_user = $event_spec === 'modification' && $mod_new_user ? $mod_new_user : $user_now; // New user; when applicable.
266
+
267
+ $auto_transition_success = c_ws_plugin__s2member_list_servers::process_list_servers
268
+ (
269
+ $mod_new_role, // Subscribe to lists associated w/ their new role/level.
270
+ c_ws_plugin__s2member_user_access::user_access_role_to_level($mod_new_role),
271
+ $dynamic_user->user_login, '', $dynamic_user->user_email, $dynamic_user->first_name, $dynamic_user->last_name,
272
+ '', TRUE, ($auto_removal_success ? FALSE : TRUE), $dynamic_user->ID
273
+ );
274
+ do_action('ws_plugin__s2member_during_auto_process_list_server_removal_transitions', get_defined_vars());
275
+ }
276
+ do_action('ws_plugin__s2member_during_auto_process_list_server_removals', get_defined_vars());
277
+ }
278
+ }
279
+ do_action('ws_plugin__s2member_after_auto_process_list_server_removals', get_defined_vars());
280
+ }
281
 
282
+ /**
283
+ * List servers have been integrated?
284
+ *
285
+ * @since 3.5
286
+ * @package s2Member\List_Servers
287
+ *
288
+ * @return bool True if list servers have been integrated.
289
+ */
290
+ public static function list_servers_integrated()
291
+ {
292
+ do_action('ws_plugin__s2member_before_list_servers_integrated', get_defined_vars());
293
 
294
+ for($n = 0; $n <= $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n++ /* Go through each Level; looking for a configured list. */)
295
+ 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']))
296
+ return apply_filters('ws_plugin__s2member_list_servers_integrated', TRUE, get_defined_vars());
 
297
 
298
+ return apply_filters('ws_plugin__s2member_list_servers_integrated', FALSE, get_defined_vars());
 
 
 
 
 
 
 
299
  }
300
  }
301
  }
includes/classes/login-redirects.inc.php CHANGED
@@ -46,6 +46,8 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
46
  do_action('ws_plugin__s2member_before_login_redirect', get_defined_vars());
47
  unset($__refs, $__v); // Housekeeping.
48
 
 
 
49
  if(is_string($username) && $username && is_object($user) && !empty($user->ID) && ($user_id = $user->ID))
50
  {
51
  update_user_option($user_id, 's2member_last_login_time', time());
@@ -61,8 +63,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
61
 
62
  if(($ok = TRUE) && !is_super_admin($user_id) && $username !== 'demo' // Exclude super admins, the `demo` user, and anyone who can edit posts.
63
  && !apply_filters('ws_plugin__s2member_disable_login_ip_restrictions', (($user->has_cap('edit_posts')) ? TRUE : FALSE), get_defined_vars())
64
- )
65
- $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER['REMOTE_ADDR'], strtolower($username));
66
 
67
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) // Alter value of `redirect_to`?
68
  if(!empty($_REQUEST['redirect_to']) && is_string($_REQUEST['redirect_to']) && strpos($_REQUEST['redirect_to'], 'wp-admin') === FALSE)
@@ -71,7 +72,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
71
  if(stripos($_REQUEST['redirect_to'], 'http://') !== 0) // Force an absolute URL in this case.
72
  {
73
  $home_path = trim((string)@parse_url(home_url('/'), PHP_URL_PATH), '/');
74
- $http_home_base = trim(preg_replace('/\/'.preg_quote($home_path, '/').'\/$/', '', home_url('/', 'http')), '/');
75
  $_REQUEST['redirect_to'] = $http_home_base.'/'.ltrim($_REQUEST['redirect_to'], '/');
76
  }
77
  }
@@ -79,7 +80,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
79
  {
80
  $obey_redirect_to = apply_filters('ws_plugin__s2member_obey_login_redirect_to', TRUE, get_defined_vars());
81
 
82
- if($obey_redirect_to && (empty($_REQUEST['redirect_to']) || !is_string($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] === admin_url() || preg_match('/^\/?wp-admin\/?$/', $_REQUEST['redirect_to'])))
83
  $obey_redirect_to = FALSE; // Do not obey default redirect_to locations; like those inside the default admin area.
84
 
85
  else if($obey_redirect_to && !empty($_REQUEST['redirect_to_automatic']) && is_string($redirect))
@@ -109,7 +110,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
109
  if(stripos($redirect, 'http://') !== 0) // Force absolute.
110
  {
111
  $home_path = trim((string)@parse_url(home_url('/'), PHP_URL_PATH), '/');
112
- $http_home_base = trim(preg_replace('/\/'.preg_quote($home_path, '/').'\/$/', '', home_url('/', 'http')), '/');
113
  $redirect = $http_home_base.'/'.ltrim($redirect, '/');
114
  }
115
  }
@@ -117,9 +118,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
117
  }
118
  }
119
  }
120
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
121
  do_action('ws_plugin__s2member_after_login_redirect', get_defined_vars());
122
- unset($__refs, $__v); // Housekeeping.
123
  }
124
 
125
  /**
@@ -165,7 +164,7 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
165
  if(($url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user, $root_returns_false)))
166
  $uri = c_ws_plugin__s2member_utils_urls::parse_uri($url);
167
 
168
- return apply_filters('ws_plugin__s2member_login_redirection_uri', ((!empty($uri)) ? $uri : FALSE), get_defined_vars());
169
  }
170
 
171
  /**
@@ -189,7 +188,8 @@ if(!class_exists('c_ws_plugin__s2member_login_redirects'))
189
  $url = (string)$url; // Force ``$url`` to a string value.
190
  $orig_url = $url; // Record the original URL that was passed in.
191
 
192
- $user = ((is_object($user) || is_object($user = (is_user_logged_in()) ? wp_get_current_user() : NULL)) && !empty($user->ID)) ? $user : NULL;
 
193
 
194
  $user_id = ($user) ? (string)$user->ID : '';
195
  $user_login = ($user) ? (string)strtolower($user->user_login) : '';
46
  do_action('ws_plugin__s2member_before_login_redirect', get_defined_vars());
47
  unset($__refs, $__v); // Housekeeping.
48
 
49
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
50
+
51
  if(is_string($username) && $username && is_object($user) && !empty($user->ID) && ($user_id = $user->ID))
52
  {
53
  update_user_option($user_id, 's2member_last_login_time', time());
63
 
64
  if(($ok = TRUE) && !is_super_admin($user_id) && $username !== 'demo' // Exclude super admins, the `demo` user, and anyone who can edit posts.
65
  && !apply_filters('ws_plugin__s2member_disable_login_ip_restrictions', (($user->has_cap('edit_posts')) ? TRUE : FALSE), get_defined_vars())
66
+ ) $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER['REMOTE_ADDR'], strtolower($username));
 
67
 
68
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) // Alter value of `redirect_to`?
69
  if(!empty($_REQUEST['redirect_to']) && is_string($_REQUEST['redirect_to']) && strpos($_REQUEST['redirect_to'], 'wp-admin') === FALSE)
72
  if(stripos($_REQUEST['redirect_to'], 'http://') !== 0) // Force an absolute URL in this case.
73
  {
74
  $home_path = trim((string)@parse_url(home_url('/'), PHP_URL_PATH), '/');
75
+ $http_home_base = trim(preg_replace('/\/'.preg_quote($home_path, '/').'\/$/'.$ci, '', home_url('/', 'http')), '/');
76
  $_REQUEST['redirect_to'] = $http_home_base.'/'.ltrim($_REQUEST['redirect_to'], '/');
77
  }
78
  }
80
  {
81
  $obey_redirect_to = apply_filters('ws_plugin__s2member_obey_login_redirect_to', TRUE, get_defined_vars());
82
 
83
+ if($obey_redirect_to && (empty($_REQUEST['redirect_to']) || !is_string($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] === admin_url() || preg_match('/^\/?wp-admin\/?$/'.$ci, $_REQUEST['redirect_to'])))
84
  $obey_redirect_to = FALSE; // Do not obey default redirect_to locations; like those inside the default admin area.
85
 
86
  else if($obey_redirect_to && !empty($_REQUEST['redirect_to_automatic']) && is_string($redirect))
110
  if(stripos($redirect, 'http://') !== 0) // Force absolute.
111
  {
112
  $home_path = trim((string)@parse_url(home_url('/'), PHP_URL_PATH), '/');
113
+ $http_home_base = trim(preg_replace('/\/'.preg_quote($home_path, '/').'\/$/'.$ci, '', home_url('/', 'http')), '/');
114
  $redirect = $http_home_base.'/'.ltrim($redirect, '/');
115
  }
116
  }
118
  }
119
  }
120
  }
 
121
  do_action('ws_plugin__s2member_after_login_redirect', get_defined_vars());
 
122
  }
123
 
124
  /**
164
  if(($url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user, $root_returns_false)))
165
  $uri = c_ws_plugin__s2member_utils_urls::parse_uri($url);
166
 
167
+ return apply_filters('ws_plugin__s2member_login_redirection_uri', !empty($uri) ? $uri : FALSE, get_defined_vars());
168
  }
169
 
170
  /**
188
  $url = (string)$url; // Force ``$url`` to a string value.
189
  $orig_url = $url; // Record the original URL that was passed in.
190
 
191
+ $user = (is_object($user) || is_object($user = wp_get_current_user()))
192
+ && !empty($user->ID) ? $user : NULL;
193
 
194
  $user_id = ($user) ? (string)$user->ID : '';
195
  $user_login = ($user) ? (string)strtolower($user->user_login) : '';
includes/classes/mailchimp-o.inc.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MailChimp (Old API)
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_mailchimp_o'))
21
+ {
22
+ /**
23
+ * MailChimp (Old API)
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_mailchimp_o 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 Mailchimp_o|null MailChimp API instance.
37
+ */
38
+ public static function mc_api()
39
+ {
40
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
41
+ return NULL; // Not possible.
42
+
43
+ if(!class_exists('Mailchimp_o')) // Include the MailChimp API class here.
44
+ include_once dirname(dirname(__FILE__)).'/externals/mailchimp/Mailchimp-o.php';
45
+ return new Mailchimp_o($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], TRUE);
46
+ }
47
+
48
+ /**
49
+ * Subscribe.
50
+ *
51
+ * @since 141004
52
+ * @package s2Member\List_Servers
53
+ *
54
+ * @param array $args Input arguments.
55
+ *
56
+ * @return bool True if successful.
57
+ */
58
+ public static function subscribe($args)
59
+ {
60
+ if(!($args = self::validate_args($args)))
61
+ return FALSE; // Invalid args.
62
+
63
+ if(!$args->opt_in) // Double check.
64
+ return FALSE; // Must say explicitly.
65
+
66
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
67
+ return FALSE; // Not possible.
68
+
69
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids']))
70
+ return FALSE; // No list configured at this level.
71
+
72
+ if(!($mc_api = self::mc_api())) return FALSE; // Unable to acquire API instance.
73
+
74
+ $mc_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids'];
75
+
76
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
77
+
78
+ foreach(preg_split('/['."\r\n\t".';,]+/', $mc_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_mc_list)
79
+ {
80
+ $_mc = array(
81
+ 'args' => $args,
82
+ 'function' => __FUNCTION__,
83
+ 'list' => trim($_mc_list),
84
+ 'list_id' => trim($_mc_list),
85
+ 'api_method' => 'listSubscribe',
86
+ 'api_properties' => $mc_api
87
+ );
88
+ if(!$_mc['list'] || !$_mc['list_id'])
89
+ continue; // List missing.
90
+
91
+ if(strpos($_mc['list'], '::') !== FALSE) // Contains Interest Groups?
92
+ {
93
+ list($_mc['list_id'], $_mc['interest_groups_title'], $_mc['interest_groups']) = preg_split('/\:\:/', $_mc['list'], 3);
94
+
95
+ if(($_mc['interest_groups_title'] = trim($_mc['interest_groups_title'])))
96
+ if(($_mc['interest_groups'] = $_mc['interest_groups'] ? preg_split('/\|/', trim($_mc['interest_groups']), NULL, PREG_SPLIT_NO_EMPTY) : array()))
97
+ $_mc['interest_groups'] = array('GROUPINGS' => array(array('name' => $_mc['interest_groups_title'], 'groups' => implode(',', $_mc['interest_groups']))));
98
+
99
+ if(!$_mc['list_id']) continue; // List ID is missing now; after parsing interest groups.
100
+ }
101
+ $_mc['merge_array'] = array('MERGE1' => $args->fname, 'MERGE2' => $args->lname, 'OPTIN_IP' => $args->ip, 'OPTIN_TIME' => date('Y-m-d H:i:s'));
102
+ $_mc['merge_array'] = !empty($_mc['interest_groups']) ? array_merge($_mc['merge_array'], $_mc['interest_groups']) : $_mc['merge_array'];
103
+ $_mc['merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_array', $_mc['merge_array'], get_defined_vars()); // Deprecated!
104
+ // Filter: `ws_plugin__s2member_mailchimp_array` deprecated in v110523. Please use Filter: `ws_plugin__s2member_mailchimp_merge_array`.
105
+
106
+ if($_mc['api_response'] = $mc_api->{$_mc['api_method']}($_mc['list_id'], $args->email, // See: `http://apidocs.mailchimp.com/` for full details.
107
+ ($_mc['api_merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_merge_array', $_mc['merge_array'], get_defined_vars())), // Configured merge array above.
108
+ ($_mc['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).
109
+ ($_mc['api_double_optin'] = apply_filters('ws_plugin__s2member_mailchimp_double_optin', $args->double_opt_in, get_defined_vars())), // Abuse of this may cause account suspension.
110
+ ($_mc['api_update_existing'] = apply_filters('ws_plugin__s2member_mailchimp_update_existing', TRUE, get_defined_vars())), // Existing subscribers should be updated with this?
111
+ ($_mc['api_replace_interests'] = apply_filters('ws_plugin__s2member_mailchimp_replace_interests', TRUE, get_defined_vars())), // Replace interest groups? (only if provided).
112
+ ($_mc['api_send_welcome'] = apply_filters('ws_plugin__s2member_mailchimp_send_welcome', FALSE, get_defined_vars())))
113
+ ) $_mc['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
114
+
115
+ c_ws_plugin__s2member_utils_logs::log_entry('mailchimp-api', $_mc);
116
+ }
117
+ unset($_mc_list, $_mc); // Just a little housekeeping.
118
+
119
+ return !empty($success); // If one suceeds.
120
+ }
121
+
122
+ /**
123
+ * Unsubscribe.
124
+ *
125
+ * @since 141004
126
+ * @package s2Member\List_Servers
127
+ *
128
+ * @param array $args Input arguments.
129
+ *
130
+ * @return bool True if successful.
131
+ */
132
+ public static function unsubscribe($args)
133
+ {
134
+ if(!($args = self::validate_args($args)))
135
+ return FALSE; // Invalid args.
136
+
137
+ if(!$args->opt_out) // Double check.
138
+ return FALSE; // Must say explicitly.
139
+
140
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
141
+ return FALSE; // Not possible.
142
+
143
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids']))
144
+ return FALSE; // No list configured at this level.
145
+
146
+ if(!($mc_api = self::mc_api())) return FALSE; // Unable to acquire API instance.
147
+
148
+ $mc_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids'];
149
+
150
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
151
+
152
+ foreach(preg_split('/['."\r\n\t".';,]+/', $mc_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_mc_list)
153
+ {
154
+ $_mc = array(
155
+ 'args' => $args,
156
+ 'function' => __FUNCTION__,
157
+ 'list' => trim($_mc_list),
158
+ 'list_id' => trim($_mc_list),
159
+ 'api_method' => 'listUnsubscribe',
160
+ 'api_properties' => $mc_api
161
+ );
162
+ if(!$_mc['list'] || !$_mc['list_id'])
163
+ continue; // List missing.
164
+
165
+ if(strpos($_mc['list'], '::') !== FALSE) // Contains Interest Groups?
166
+ {
167
+ list($_mc['list_id'], $_mc['interest_groups_title'], $_mc['interest_groups']) = preg_split('/\:\:/', $_mc['list'], 3);
168
+
169
+ if(($_mc['interest_groups_title'] = trim($_mc['interest_groups_title'])))
170
+ if(($_mc['interest_groups'] = $_mc['interest_groups'] ? preg_split('/\|/', trim($_mc['interest_groups']), NULL, PREG_SPLIT_NO_EMPTY) : array()))
171
+ $_mc['interest_groups'] = array('GROUPINGS' => array(array('name' => $_mc['interest_groups_title'], 'groups' => implode(',', $_mc['interest_groups']))));
172
+
173
+ if(!$_mc['list_id']) continue; // List ID is missing now; after parsing interest groups.
174
+ }
175
+ if($_mc['api_response'] = $mc_api->{$_mc['api_method']}($_mc['list_id'], $args->email, // See: `http://apidocs.mailchimp.com/`.
176
+ ($_mc['api_delete_member'] = apply_filters('ws_plugin__s2member_mailchimp_removal_delete_member', FALSE, get_defined_vars())), // Completely delete?
177
+ ($_mc['api_send_goodbye'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_goodbye', FALSE, get_defined_vars())), // Send goodbye letter?
178
+ ($_mc['api_send_notify'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_notify', FALSE, get_defined_vars())))
179
+ ) $_mc['api_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
180
+
181
+ c_ws_plugin__s2member_utils_logs::log_entry('mailchimp-api', $_mc);
182
+ }
183
+ unset($_mc_list, $_mc); // Just a little housekeeping.
184
+
185
+ return !empty($success); // If one suceeds.
186
+ }
187
+
188
+ /**
189
+ * Transition.
190
+ *
191
+ * @since 141004
192
+ * @package s2Member\List_Servers
193
+ *
194
+ * @param array $old_args Input arguments.
195
+ * @param array $new_args Input arguments.
196
+ *
197
+ * @return bool True if successful.
198
+ */
199
+ public static function transition($old_args, $new_args)
200
+ {
201
+ return self::unsubscribe($old_args) && self::subscribe($new_args);
202
+ }
203
+ }
204
+ }
includes/classes/mailchimp.inc.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MailChimp
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_mailchimp'))
21
+ {
22
+ /**
23
+ * MailChimp
24
+ *
25
+ * @since 141004
26
+ * @package s2Member\List_Servers
27
+ */
28
+ class c_ws_plugin__s2member_mailchimp 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 Mailchimp|null MailChimp API instance.
37
+ */
38
+ public static function mc_api()
39
+ {
40
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
41
+ return NULL; // Not possible.
42
+
43
+ if(!class_exists('Mailchimp')) // Include the MailChimp API class here.
44
+ include_once dirname(dirname(__FILE__)).'/externals/mailchimp/Mailchimp.php';
45
+ return new Mailchimp($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], array('timeout' => 30));
46
+ }
47
+
48
+ /**
49
+ * Subscribe.
50
+ *
51
+ * @since 141004
52
+ * @package s2Member\List_Servers
53
+ *
54
+ * @param array $args Input arguments.
55
+ *
56
+ * @return bool True if successful.
57
+ */
58
+ public static function subscribe($args)
59
+ {
60
+ if(!($args = self::validate_args($args)))
61
+ return FALSE; // Invalid args.
62
+
63
+ if(!$args->opt_in) // Double check.
64
+ return FALSE; // Must say explicitly.
65
+
66
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
67
+ return FALSE; // Not possible.
68
+
69
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids']))
70
+ return FALSE; // No list configured at this level.
71
+
72
+ if(!($mc_api = self::mc_api())) return FALSE; // Unable to acquire API instance.
73
+
74
+ $mc_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids'];
75
+
76
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
77
+
78
+ foreach(preg_split('/['."\r\n\t".';,]+/', $mc_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_mc_list)
79
+ {
80
+ $_mc = array(
81
+ 'args' => $args,
82
+ 'function' => __FUNCTION__,
83
+ 'list' => trim($_mc_list),
84
+ 'list_id' => trim($_mc_list),
85
+ 'api_method' => 'listSubscribe',
86
+ 'api_properties' => $mc_api
87
+ );
88
+ if(!$_mc['list'] || !$_mc['list_id'])
89
+ continue; // List missing.
90
+
91
+ if(strpos($_mc['list'], '::') !== FALSE) // Contains Interest Groups?
92
+ {
93
+ list($_mc['list_id'], $_mc['interest_groups_title'], $_mc['interest_groups']) = preg_split('/\:\:/', $_mc['list'], 3);
94
+
95
+ if(($_mc['interest_groups_title'] = trim($_mc['interest_groups_title'])))
96
+ if(($_mc['interest_groups'] = $_mc['interest_groups'] ? preg_split('/\|/', trim($_mc['interest_groups']), NULL, PREG_SPLIT_NO_EMPTY) : array()))
97
+ $_mc['interest_groups'] = array('GROUPINGS' => array(array('name' => $_mc['interest_groups_title'], 'groups' => implode(',', $_mc['interest_groups']))));
98
+
99
+ if(!$_mc['list_id']) continue; // List ID is missing now; after parsing interest groups.
100
+ }
101
+ $_mc['merge_array'] = array('MERGE1' => $args->fname, 'MERGE2' => $args->lname, 'OPTIN_IP' => $args->ip, 'OPTIN_TIME' => date('Y-m-d H:i:s'));
102
+ $_mc['merge_array'] = !empty($_mc['interest_groups']) ? array_merge($_mc['merge_array'], $_mc['interest_groups']) : $_mc['merge_array'];
103
+ $_mc['merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_array', $_mc['merge_array'], get_defined_vars()); // Deprecated!
104
+ // Filter: `ws_plugin__s2member_mailchimp_array` deprecated in v110523. Please use Filter: `ws_plugin__s2member_mailchimp_merge_array`.
105
+
106
+ try // Catch any Mailchimp exceptions that occur here.
107
+ {
108
+ if(($_mc['api_response'] = $mc_api->lists->subscribe($_mc['list_id'], array('email' => $args->email), // See: `http://apidocs.mailchimp.com/` for full details.
109
+ ($_mc['api_merge_array'] = apply_filters('ws_plugin__s2member_mailchimp_merge_array', $_mc['merge_array'], get_defined_vars())), // Configured merge array above.
110
+ ($_mc['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).
111
+ ($_mc['api_double_optin'] = apply_filters('ws_plugin__s2member_mailchimp_double_optin', $args->double_opt_in, get_defined_vars())), // Abuse of this may cause account suspension.
112
+ ($_mc['api_update_existing'] = apply_filters('ws_plugin__s2member_mailchimp_update_existing', TRUE, get_defined_vars())), // Existing subscribers should be updated with this?
113
+ ($_mc['api_replace_interests'] = apply_filters('ws_plugin__s2member_mailchimp_replace_interests', TRUE, get_defined_vars())), // Replace interest groups? (only if provided).
114
+ ($_mc['api_send_welcome'] = apply_filters('ws_plugin__s2member_mailchimp_send_welcome', FALSE, get_defined_vars()))))
115
+ && !empty($_mc['api_response']['email'])
116
+ ) $_mc['api_success'] = $success = TRUE;
117
+ }
118
+ catch(Exception $exception)
119
+ {
120
+ $_mc['exception'] = $exception;
121
+ }
122
+ c_ws_plugin__s2member_utils_logs::log_entry('mailchimp-api', $_mc);
123
+ }
124
+ unset($_mc_list, $_mc); // Just a little housekeeping.
125
+
126
+ return !empty($success); // If one suceeds.
127
+ }
128
+
129
+ /**
130
+ * Unsubscribe.
131
+ *
132
+ * @since 141004
133
+ * @package s2Member\List_Servers
134
+ *
135
+ * @param array $args Input arguments.
136
+ *
137
+ * @return bool True if successful.
138
+ */
139
+ public static function unsubscribe($args)
140
+ {
141
+ if(!($args = self::validate_args($args)))
142
+ return FALSE; // Invalid args.
143
+
144
+ if(!$args->opt_out) // Double check.
145
+ return FALSE; // Must say explicitly.
146
+
147
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'])
148
+ return FALSE; // Not possible.
149
+
150
+ if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids']))
151
+ return FALSE; // No list configured at this level.
152
+
153
+ if(!($mc_api = self::mc_api())) return FALSE; // Unable to acquire API instance.
154
+
155
+ $mc_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_mailchimp_list_ids'];
156
+
157
+ extract((array)$args); // Extract the arguments for back compat. w/ filters that relied upon them.
158
+
159
+ foreach(preg_split('/['."\r\n\t".';,]+/', $mc_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_mc_list)
160
+ {
161
+ $_mc = array(
162
+ 'args' => $args,
163
+ 'function' => __FUNCTION__,
164
+ 'list' => trim($_mc_list),
165
+ 'list_id' => trim($_mc_list),
166
+ 'api_method' => 'listUnsubscribe',
167
+ 'api_properties' => $mc_api
168
+ );
169
+ if(!$_mc['list'] || !$_mc['list_id'])
170
+ continue; // List missing.
171
+
172
+ if(strpos($_mc['list'], '::') !== FALSE) // Contains Interest Groups?
173
+ {
174
+ list($_mc['list_id'], $_mc['interest_groups_title'], $_mc['interest_groups']) = preg_split('/\:\:/', $_mc['list'], 3);
175
+
176
+ if(($_mc['interest_groups_title'] = trim($_mc['interest_groups_title'])))
177
+ if(($_mc['interest_groups'] = $_mc['interest_groups'] ? preg_split('/\|/', trim($_mc['interest_groups']), NULL, PREG_SPLIT_NO_EMPTY) : array()))
178
+ $_mc['interest_groups'] = array('GROUPINGS' => array(array('name' => $_mc['interest_groups_title'], 'groups' => implode(',', $_mc['interest_groups']))));
179
+
180
+ if(!$_mc['list_id']) continue; // List ID is missing now; after parsing interest groups.
181
+ }
182
+ try // Catch any Mailchimp exceptions that occur here.
183
+ {
184
+ if(($_mc['api_response'] = $mc_api->lists->unsubscribe($_mc['list_id'], array('email' => $args->email), // See: `http://apidocs.mailchimp.com/`.
185
+ ($_mc['api_delete_member'] = apply_filters('ws_plugin__s2member_mailchimp_removal_delete_member', FALSE, get_defined_vars())), // Completely delete?
186
+ ($_mc['api_send_goodbye'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_goodbye', FALSE, get_defined_vars())), // Send goodbye letter?
187
+ ($_mc['api_send_notify'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_notify', FALSE, get_defined_vars()))))
188
+ && !empty($_mc['api_response']['complete'])
189
+ ) $_mc['api_success'] = $success = TRUE;
190
+ }
191
+ catch(Exception $exception)
192
+ {
193
+ $_mc['exception'] = $exception;
194
+ }
195
+ c_ws_plugin__s2member_utils_logs::log_entry('mailchimp-api', $_mc);
196
+ }
197
+ unset($_mc_list, $_mc); // Just a little housekeeping.
198
+
199
+ return !empty($success); // If one suceeds.
200
+ }
201
+
202
+ /**
203
+ * Transition.
204
+ *
205
+ * @since 141004
206
+ * @package s2Member\List_Servers
207
+ *
208
+ * @param array $old_args Input arguments.
209
+ * @param array $new_args Input arguments.
210
+ *
211
+ * @return bool True if successful.
212
+ */
213
+ public static function transition($old_args, $new_args)
214
+ {
215
+ return self::unsubscribe($old_args) && self::subscribe($new_args);
216
+ }
217
+ }
218
+ }
includes/classes/pages-sp.inc.php CHANGED
@@ -42,6 +42,7 @@ if(!class_exists('c_ws_plugin__s2member_pages_sp'))
42
  {
43
  do_action('ws_plugin__s2member_before_check_specific_page_level_access', get_defined_vars());
44
 
 
45
  $excluded = apply_filters('ws_plugin__s2member_check_specific_page_level_access_excluded', FALSE, get_defined_vars());
46
 
47
  if(!$excluded && is_numeric($page_id) && ($page_id = (int)$page_id) && ($page = get_post($page_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -55,7 +56,7 @@ if(!class_exists('c_ws_plugin__s2member_pages_sp'))
55
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page->ID === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
56
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
57
 
58
- else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
59
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
60
 
61
  else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page->ID === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -90,7 +91,7 @@ if(!class_exists('c_ws_plugin__s2member_pages_sp'))
90
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
91
 
92
  foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
93
- if($str && preg_match('/'.preg_quote($str, '/').'/', $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
94
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
95
  }
96
  if(is_array($ccaps_req = get_post_meta($page->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req))
42
  {
43
  do_action('ws_plugin__s2member_before_check_specific_page_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_page_level_access_excluded', FALSE, get_defined_vars());
47
 
48
  if(!$excluded && is_numeric($page_id) && ($page_id = (int)$page_id) && ($page = get_post($page_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
56
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page->ID === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
57
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
58
 
59
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
60
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
61
 
62
  else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page->ID === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
91
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
92
 
93
  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)
94
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
95
  return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
96
  }
97
  if(is_array($ccaps_req = get_post_meta($page->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req))
includes/classes/pages.inc.php CHANGED
@@ -41,6 +41,7 @@ if(!class_exists('c_ws_plugin__s2member_pages'))
41
 
42
  do_action('ws_plugin__s2member_before_check_page_level_access', get_defined_vars());
43
 
 
44
  $excluded = apply_filters('ws_plugin__s2member_check_page_level_access_excluded', FALSE, get_defined_vars());
45
 
46
  if(!$excluded && is_page() && is_object($post) && !empty($post->ID) && ($page_id = (int)$post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -52,7 +53,7 @@ if(!class_exists('c_ws_plugin__s2member_pages'))
52
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
53
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
54
 
55
- else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
56
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
57
 
58
  else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -87,7 +88,7 @@ if(!class_exists('c_ws_plugin__s2member_pages'))
87
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
88
 
89
  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)
90
- 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)))
91
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
92
  }
93
  if(is_array($ccaps_req = get_post_meta($page_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted'))
41
 
42
  do_action('ws_plugin__s2member_before_check_page_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_page_level_access_excluded', FALSE, get_defined_vars());
46
 
47
  if(!$excluded && is_page() && is_object($post) && !empty($post->ID) && ($page_id = (int)$post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
53
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
54
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
55
 
56
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
57
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
58
 
59
  else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
88
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
89
 
90
  foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
91
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
92
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
93
  }
94
  if(is_array($ccaps_req = get_post_meta($page_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted'))
includes/classes/posts-sp.inc.php CHANGED
@@ -42,6 +42,7 @@ if(!class_exists('c_ws_plugin__s2member_posts_sp'))
42
  {
43
  do_action('ws_plugin__s2member_before_check_specific_post_level_access', get_defined_vars());
44
 
 
45
  $excluded = apply_filters('ws_plugin__s2member_check_specific_post_level_access_excluded', FALSE, get_defined_vars());
46
 
47
  if(!$excluded && is_numeric($post_id) && ($post_id = (int)$post_id) && ($post = get_post($post_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -52,7 +53,7 @@ if(!class_exists('c_ws_plugin__s2member_posts_sp'))
52
  {
53
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
54
 
55
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
56
  return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => 0), get_defined_vars());
57
 
58
  else if(!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($post->ID, $post_uri)) // However, there is the one exception above.
@@ -107,7 +108,7 @@ if(!class_exists('c_ws_plugin__s2member_posts_sp'))
107
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
108
 
109
  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)
110
- if($str && preg_match('/'.preg_quote($str, '/').'/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
111
  return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
112
  }
113
  if(is_array($ccaps_req = get_post_meta($post->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req))
42
  {
43
  do_action('ws_plugin__s2member_before_check_specific_post_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_post_level_access_excluded', FALSE, get_defined_vars());
47
 
48
  if(!$excluded && is_numeric($post_id) && ($post_id = (int)$post_id) && ($post = get_post($post_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
53
  {
54
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
55
 
56
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_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, '/').'$/'.$ci, $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
57
  return apply_filters('ws_plugin__s2member_check_specific_post_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($post->ID, $post_uri)) // However, there is the one exception above.
108
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
109
 
110
  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)
111
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
112
  return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
113
  }
114
  if(is_array($ccaps_req = get_post_meta($post->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req))
includes/classes/posts.inc.php CHANGED
@@ -41,6 +41,7 @@ if(!class_exists('c_ws_plugin__s2member_posts'))
41
 
42
  do_action('ws_plugin__s2member_before_check_post_level_access', get_defined_vars());
43
 
 
44
  $excluded = apply_filters('ws_plugin__s2member_check_post_level_access_excluded', FALSE, get_defined_vars());
45
 
46
  if(!$excluded && is_single() && is_object($post) && !empty($post->ID) && ($post_id = (int)$post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
@@ -49,7 +50,7 @@ if(!class_exists('c_ws_plugin__s2member_posts'))
49
  {
50
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
51
 
52
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
53
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
54
 
55
  else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // However, there is the one exception above.
@@ -104,7 +105,7 @@ if(!class_exists('c_ws_plugin__s2member_posts'))
104
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
105
 
106
  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)
107
- 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)))
108
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
109
  }
110
  if(is_array($ccaps_req = get_post_meta($post_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted'))
41
 
42
  do_action('ws_plugin__s2member_before_check_post_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_post_level_access_excluded', FALSE, get_defined_vars());
46
 
47
  if(!$excluded && is_single() && is_object($post) && !empty($post->ID) && ($post_id = (int)$post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
50
  {
51
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
52
 
53
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$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('post', $post_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
55
 
56
  else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // However, there is the one exception above.
105
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
106
 
107
  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)
108
+ 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)))
109
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
110
  }
111
  if(is_array($ccaps_req = get_post_meta($post_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted'))
includes/classes/ptags-sp.inc.php CHANGED
@@ -1,105 +1,102 @@
1
  <?php
2
  /**
3
- * s2Member's Tag protection routines *(for specific Tags)*.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Tags
15
- * @since 3.5
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit("Do not access this file directly.");
19
 
20
- if (!class_exists ("c_ws_plugin__s2member_ptags_sp"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * s2Member's Tag protection routines *(for specific Tags)*.
24
- *
25
- * @package s2Member\Tags
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_ptags_sp
29
- {
30
- /**
31
- * Handles Tag Level Access *(for specific Tags)*.
32
- *
33
- * @package s2Member\Tags
34
- * @since 3.5
35
- *
36
- * @param int|string $_tag Numeric Tag ID, Tag Slug, or Tag Name.
37
- * @param bool $check_user Test permissions against the current User? Defaults to true.
38
- * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
39
- */
40
- public static function check_specific_ptag_level_access ($_tag = FALSE, $check_user = TRUE)
41
- {
42
- do_action("ws_plugin__s2member_before_check_specific_ptag_level_access", get_defined_vars ());
43
-
44
- if ($_tag && is_numeric ($_tag) && is_object ($term = get_term_by ("id", $_tag, "post_tag")))
45
- {
46
- $tag_id = (int)$_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
47
- $tag_slug = $term->slug; // Tag slug.
48
- $tag_name = $term->name; // Tag name.
49
- }
50
- else if ($_tag && is_string ($_tag) && is_object ($term = get_term_by ("name", $_tag, "post_tag")))
51
- {
52
- $tag_name = $_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
53
- $tag_id = (int)$term->term_id; // Tag ID.
54
- $tag_slug = $term->slug; // Tag slug.
55
- }
56
- else if ($_tag && is_string ($_tag) && is_object ($term = get_term_by ("slug", $_tag, "post_tag")))
57
- {
58
- $tag_slug = $_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
59
- $tag_id = (int)$term->term_id; // Tag ID.
60
- $tag_name = $term->name; // Tag name.
61
- }
62
-
63
- $excluded = apply_filters("ws_plugin__s2member_check_specific_ptag_level_access_excluded", false, get_defined_vars ());
64
 
65
- if (!$excluded && !empty($tag_id) && !empty($tag_slug) && !empty($tag_name) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
66
- {
67
- $tag_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_tag_link ($tag_id)); // Get a full valid URI for this Tag.
68
-
69
- if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page (null, $tag_uri)) // Do NOT touch WordPress Systematics.
70
- {
71
- $user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty($user->ID)) ? $user : false; // Current User's object.
72
-
73
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $tag_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")))
74
- return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => 0), get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
75
 
76
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $tag_uri)) // Never restrict Systematics. However, there is 1 exception above.
77
- {
78
- for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Tag Level restrictions. Go through each Level.
79
- {
80
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
81
- return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars ());
82
 
83
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (in_array($tag_name, ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]))) || in_array($tag_slug, $tags)) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
84
- return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars ());
85
- }
86
 
87
- for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // URIs. Go through each Level.
88
- {
89
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) // URIs configured at this Level?
90
 
91
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
92
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $tag_uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
93
- return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars ());
94
- }
95
- }
 
96
 
97
- do_action("ws_plugin__s2member_during_check_specific_ptag_level_access", get_defined_vars ());
98
- }
99
- }
 
 
 
100
 
101
- return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", null, get_defined_vars ());
 
 
 
102
  }
 
 
103
  }
 
 
104
  }
105
- ?>
1
  <?php
2
  /**
3
+ * s2Member's Tag protection routines *(for specific Tags)*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Tags
15
+ * @since 3.5
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit('Do not access this file directly.');
19
 
20
+ if(!class_exists('c_ws_plugin__s2member_ptags_sp'))
21
+ {
22
+ /**
23
+ * s2Member's Tag protection routines *(for specific Tags)*.
24
+ *
25
+ * @package s2Member\Tags
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_ptags_sp
29
  {
30
  /**
31
+ * Handles Tag Level Access *(for specific Tags)*.
32
+ *
33
+ * @package s2Member\Tags
34
+ * @since 3.5
35
+ *
36
+ * @param int|string $_tag Numeric Tag ID, Tag Slug, or Tag Name.
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_ptag_level_access($_tag = '', $check_user = TRUE)
42
+ {
43
+ do_action('ws_plugin__s2member_before_check_specific_ptag_level_access', get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ if($_tag && is_numeric($_tag) && is_object($term = get_term_by('id', $_tag, 'post_tag')))
46
+ {
47
+ $tag_id = (int)$_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
48
+ $tag_slug = $term->slug; // Tag slug.
49
+ $tag_name = $term->name; // Tag name.
50
+ }
51
+ else if($_tag && is_string($_tag) && is_object($term = get_term_by('name', $_tag, 'post_tag')))
52
+ {
53
+ $tag_name = $_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
54
+ $tag_id = (int)$term->term_id; // Tag ID.
55
+ $tag_slug = $term->slug; // Tag slug.
56
+ }
57
+ else if($_tag && is_string($_tag) && is_object($term = get_term_by('slug', $_tag, 'post_tag')))
58
+ {
59
+ $tag_slug = $_tag; // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
60
+ $tag_id = (int)$term->term_id; // Tag ID.
61
+ $tag_name = $term->name; // Tag name.
62
+ }
63
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
64
+ $excluded = apply_filters('ws_plugin__s2member_check_specific_ptag_level_access_excluded', FALSE, get_defined_vars());
65
 
66
+ if(!$excluded && !empty($tag_id) && !empty($tag_slug) && !empty($tag_name) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
67
+ {
68
+ $tag_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_tag_link($tag_id)); // Get a full valid URI for this Tag.
 
 
 
69
 
70
+ if(!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $tag_uri)) // Do NOT touch WordPress Systematics.
71
+ {
72
+ $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
73
 
74
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $tag_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
75
+ return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => 0), get_defined_vars());
 
76
 
77
+ else if(!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $tag_uri)) // Never restrict Systematics. However, there is 1 exception above.
78
+ {
79
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Tag Level restrictions. Go through each Level.
80
+ {
81
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
82
+ return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
83
 
84
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] && (in_array($tag_name, ($tags = preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags']))) || in_array($tag_slug, $tags)) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
85
+ return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
86
+ }
87
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. Go through each Level.
88
+ {
89
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
90
 
91
+ foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
92
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $tag_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
93
+ return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
94
+ }
95
  }
96
+ do_action('ws_plugin__s2member_during_check_specific_ptag_level_access', get_defined_vars());
97
+ }
98
  }
99
+ return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', NULL, get_defined_vars());
100
+ }
101
  }
102
+ }
includes/classes/ptags.inc.php CHANGED
@@ -1,86 +1,85 @@
1
  <?php
2
  /**
3
- * s2Member's Tag protection routines *(for current page)*.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Tags
15
- * @since 3.5
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit("Do not access this file directly.");
19
 
20
- if (!class_exists ("c_ws_plugin__s2member_ptags"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * s2Member's Tag protection routines *(for current page)*.
24
- *
25
- * @package s2Member\Tags
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_ptags
29
- {
30
- /**
31
- * Handles Tag Level Access permissions *(for current page)*.
32
- *
33
- * @package s2Member\Tags
34
- * @since 3.5
35
- *
36
- * @return null Or exits script execution after redirection.
37
- */
38
- public static function check_ptag_level_access ()
39
- {
40
- global $wp_query, $post; // ``get_the_ID()`` is NOT available outside The Loop.
41
-
42
- do_action("ws_plugin__s2member_before_check_ptag_level_access", get_defined_vars ());
43
-
44
- $excluded = apply_filters("ws_plugin__s2member_check_ptag_level_access_excluded", false, get_defined_vars ());
45
 
46
- if (!$excluded && is_tag () && is_object ($tag = $wp_query->get_queried_object ()) && !empty($tag->term_id) && ($tag_id = (int)$tag->term_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
47
- {
48
- if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page ()) // Do NOT touch WordPress Systematics. This excludes all WordPress Systematics.
49
- {
50
- $user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty($user->ID)) ? $user : false; // Current User's object.
51
 
52
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants ('restricted') && (!$user || !$user->has_cap ("access_s2member_level0")))
53
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("ptag", $tag_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit ();
54
 
55
- else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) // Do NOT protect Systematics. However, there is 1 exception above.
56
- {
57
- for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // Tag Level restrictions. Go through each Level.
58
- {
59
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants ('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. */ ("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
61
-
62
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (is_tag ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) || in_array($tag_id, $tags)) && c_ws_plugin__s2member_no_cache::no_cache_constants ('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. */ ("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit ();
64
- }
65
-
66
- for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // URIs. Go through each Level.
67
- {
68
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) // URIs configured at this Level?
69
 
70
- 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)
71
- 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)))
72
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit ();
73
- }
74
- }
75
 
76
- do_action("ws_plugin__s2member_during_check_ptag_level_access", get_defined_vars ());
77
- }
78
- }
 
 
 
79
 
80
- do_action("ws_plugin__s2member_after_check_ptag_level_access", get_defined_vars ());
 
 
 
 
 
81
 
82
- return; // For uniformity.
 
 
 
83
  }
 
 
84
  }
 
 
85
  }
86
- ?>
1
  <?php
2
  /**
3
+ * s2Member's Tag protection routines *(for current page)*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Tags
15
+ * @since 3.5
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit('Do not access this file directly.');
19
 
20
+ if(!class_exists('c_ws_plugin__s2member_ptags'))
21
+ {
22
+ /**
23
+ * s2Member's Tag protection routines *(for current page)*.
24
+ *
25
+ * @package s2Member\Tags
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_ptags
29
  {
30
  /**
31
+ * Handles Tag Level Access permissions *(for current page)*.
32
+ *
33
+ * @package s2Member\Tags
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
37
+ */
38
+ public static function check_ptag_level_access()
39
+ {
40
+ /**
41
+ * @var $post WP_Post Reference for IDEs.
42
+ * @var $wp_query WP_Query Reference for IDEs.
43
+ */
44
+ global $wp_query, $post; // ``get_the_ID()`` NOT available outside The Loop.
 
 
 
 
 
 
 
 
45
 
46
+ do_action('ws_plugin__s2member_before_check_ptag_level_access', get_defined_vars());
 
 
 
 
47
 
48
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
49
+ $excluded = apply_filters('ws_plugin__s2member_check_ptag_level_access_excluded', FALSE, get_defined_vars());
50
 
51
+ if(!$excluded && is_tag() && is_object($tag = $wp_query->get_queried_object()) && !empty($tag->term_id) && ($tag_id = (int)$tag->term_id) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
52
+ {
53
+ if(!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) // Do NOT touch WordPress Systematics. This excludes all WordPress Systematics.
54
+ {
55
+ $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
 
 
 
 
 
 
 
 
 
56
 
57
+ 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, '/').'$/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
58
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
 
 
 
59
 
60
+ else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // Do NOT protect Systematics. However, there is 1 exception above.
61
+ {
62
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Tag Level restrictions. Go through each Level.
63
+ {
64
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
65
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI']).exit ();
66
 
67
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] && (is_tag($tags = preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'])) || in_array($tag_id, $tags)) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
68
+ c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI']).exit ();
69
+ }
70
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. Go through each Level.
71
+ {
72
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
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, '/').'/'.$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('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
77
+ }
78
  }
79
+ do_action('ws_plugin__s2member_during_check_ptag_level_access', get_defined_vars());
80
+ }
81
  }
82
+ do_action('ws_plugin__s2member_after_check_ptag_level_access', get_defined_vars());
83
+ }
84
  }
85
+ }
includes/classes/querys.inc.php CHANGED
@@ -266,7 +266,7 @@ if(!class_exists('c_ws_plugin__s2member_querys'))
266
  * @package s2Member\Queries
267
  * @since 3.5
268
  *
269
- * @param object $wp_query Expects ``$wp_query`` by reference.
270
  */
271
  public static function _query_level_access_sys(&$wp_query = NULL)
272
  {
266
  * @package s2Member\Queries
267
  * @since 3.5
268
  *
269
+ * @param WP_Query $wp_query Expects ``$wp_query`` by reference.
270
  */
271
  public static function _query_level_access_sys(&$wp_query = NULL)
272
  {
includes/classes/register-access.inc.php CHANGED
@@ -1,110 +1,112 @@
1
  <?php
2
  /**
3
- * Registration Access Links.
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\Registrations
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_register_access"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Registration Access Links.
24
- *
25
- * @package s2Member\Registrations
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_register_access
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  {
30
- /**
31
- * Generates Registration Access Links.
32
- *
33
- * @package s2Member\Registrations
34
- * @since 3.5
35
- *
36
- * @param string $subscr_gateway Payment Gateway associated with a Customer.
37
- * @param string $subscr_id Unique Subscr. ID associated with Payment Gateway; associated with a Customer.
38
- * @param string $custom Custom String value *(as supplied in Shortcode)*; must start with installation domain name.
39
- * @param int|string $item_number An s2Member-generated `item_number` *( i.e. `1` for Level 1, or `level|ccaps|fixed-term`, or `sp|ids|expiration` )*.
40
- * @param bool $shrink Optional. Defaults to true. If false, the raw registration link will NOT be reduced in size through the tinyURL API.
41
- * @return string|bool A Registration Access Link on success, else false on failure.
42
- */
43
- public static function register_link_gen ($subscr_gateway = FALSE, $subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
44
- {
45
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
46
- do_action("ws_plugin__s2member_before_register_link_gen", get_defined_vars ());
47
- unset($__refs, $__v);
48
 
49
- if ($subscr_gateway && is_string ($subscr_gateway) && $subscr_id && is_string ($subscr_id) && $custom && is_string ($custom) && $item_number && (is_string ($item_number) || is_numeric ($item_number)))
50
- {
51
- $register = c_ws_plugin__s2member_utils_encryption::encrypt ("subscr_gateway_subscr_id_custom_item_number_time:.:|:.:" . $subscr_gateway . ":.:|:.:" . $subscr_id . ":.:|:.:" . $custom . ":.:|:.:" . $item_number . ":.:|:.:" . strtotime ("now"));
52
 
53
- $register_link = home_url ("/?s2member_register=" . urlencode ($register)); // Generate long URL/link.
 
 
 
 
54
 
55
- if ($shrink && ($shorter_url = c_ws_plugin__s2member_utils_urls::shorten ($register_link)))
56
- $register_link = $shorter_url . "#" . $_SERVER["HTTP_HOST"];
57
- }
 
 
 
 
 
 
 
 
 
 
58
 
59
- return apply_filters("ws_plugin__s2member_register_link_gen", ((!empty($register_link)) ? $register_link : false), get_defined_vars ());
60
- }
61
- /**
62
- * Generates Registration Access Links via AJAX.
63
- *
64
- * @package s2Member\Registrations
65
- * @since 3.5
66
- *
67
- * @attaches-to ``add_action("wp_ajax_ws_plugin__s2member_reg_access_link_via_ajax");``
68
- *
69
- * @return null Exits script execution after output is generated for AJAX caller.
70
- */
71
- public static function reg_access_link_via_ajax ()
72
- {
73
- do_action("ws_plugin__s2member_before_reg_access_link_via_ajax", get_defined_vars ());
74
 
75
- status_header(200); // Send a 200 OK status header.
76
- header("Content-Type: text/plain; charset=UTF-8"); // Content-Type with UTF-8.
77
- while (@ob_end_clean ()); // Clean any existing output buffers.
78
 
79
- if (current_user_can ("create_users")) // Check privileges as well. Ability to create Users?
80
 
81
- if (!empty($_POST["ws_plugin__s2member_reg_access_link_via_ajax"]) && is_string ($nonce = $_POST["ws_plugin__s2member_reg_access_link_via_ajax"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-reg-access-link-via-ajax"))
 
82
 
83
- if (($_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))) && isset ($_p["s2member_reg_access_link_subscr_gateway"], $_p["s2member_reg_access_link_subscr_id"], $_p["s2member_reg_access_link_custom"], $_p["s2member_reg_access_link_item_number"]))
84
- $register_link = c_ws_plugin__s2member_register_access::register_link_gen ((string)$_p["s2member_reg_access_link_subscr_gateway"], (string)$_p["s2member_reg_access_link_subscr_id"], (string)$_p["s2member_reg_access_link_custom"], (string)$_p["s2member_reg_access_link_item_number"]);
85
 
86
- exit(apply_filters("ws_plugin__s2member_reg_access_link_via_ajax", ((!empty($register_link)) ? $register_link : ""), get_defined_vars ()));
87
- }
88
- /**
89
- * Checks registration cookies.
90
- *
91
- * @package s2Member\Registrations
92
- * @since 110707
93
- *
94
- * @return array|bool An array of cookies if they're OK, else false.
95
- */
96
- public static function reg_cookies_ok ()
97
- {
98
- global $wpdb; /** @var $wpdb \wpdb */
99
 
100
- do_action("ws_plugin__s2member_before_reg_cookies_ok", get_defined_vars ());
101
 
102
- if (isset ($_COOKIE["s2member_subscr_gateway"], $_COOKIE["s2member_subscr_id"], $_COOKIE["s2member_custom"], $_COOKIE["s2member_item_number"]))
103
- if (($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt ((string)$_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ((string)$_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = c_ws_plugin__s2member_utils_encryption::decrypt ((string)$_COOKIE["s2member_custom"]))) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], ($item_number = c_ws_plugin__s2member_utils_encryption::decrypt ((string)$_COOKIE["s2member_item_number"]))) && !$wpdb->get_var ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . esc_sql($subscr_id) . "' LIMIT 1"))
104
- $reg_cookies_ok = $reg_cookies = array("subscr_gateway" => $subscr_gateway, "subscr_id" => $subscr_id, "custom" => $custom, "item_number" => $item_number);
105
 
106
- return apply_filters("ws_plugin__s2member_reg_cookies_ok", ((isset ($reg_cookies_ok) && $reg_cookies_ok && !empty($reg_cookies)) ? $reg_cookies : false), get_defined_vars ());
107
- }
108
- }
109
  }
110
- ?>
1
  <?php
2
  /**
3
+ * Registration Access Links.
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\Registrations
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_register_access'))
21
+ {
22
+ /**
23
+ * Registration Access Links.
24
+ *
25
+ * @package s2Member\Registrations
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_register_access
29
  {
30
  /**
31
+ * Generates Registration Access Links.
32
+ *
33
+ * @package s2Member\Registrations
34
+ * @since 3.5
35
+ *
36
+ * @param string $subscr_gateway Payment Gateway associated with a Customer.
37
+ * @param string $subscr_id Unique Subscr. ID associated with Payment Gateway; associated with a Customer.
38
+ * @param string $custom Custom String value *(as supplied in Shortcode)*; must start with installation domain name.
39
+ * @param int|string $item_number An s2Member-generated `item_number` *( i.e. `1` for Level 1, or `level|ccaps|fixed-term`, or `sp|ids|expiration` )*.
40
+ * @param bool $shrink Optional. Defaults to true. If false, the raw registration link will NOT be reduced in size through the tinyURL API.
41
+ *
42
+ * @return string|bool A Registration Access Link on success, else false on failure.
43
+ */
44
+ public static function register_link_gen($subscr_gateway = '', $subscr_id = '', $custom = '', $item_number = '', $shrink = TRUE)
45
+ {
46
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
47
+ do_action('ws_plugin__s2member_before_register_link_gen', get_defined_vars());
48
+ unset($__refs, $__v);
49
+
50
+ if($subscr_gateway && is_string($subscr_gateway) && $subscr_id && is_string($subscr_id) && $custom && is_string($custom) && $item_number && (is_string($item_number) || is_numeric($item_number)))
51
  {
52
+ $register = c_ws_plugin__s2member_utils_encryption::encrypt('subscr_gateway_subscr_id_custom_item_number_time:.:|:.:'.$subscr_gateway.':.:|:.:'.$subscr_id.':.:|:.:'.$custom.':.:|:.:'.$item_number.':.:|:.:'.strtotime('now'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ $register_link = home_url('/?s2member_register='.urlencode($register)); // Generate long URL/link.
 
 
55
 
56
+ if($shrink && ($shorter_url = c_ws_plugin__s2member_utils_urls::shorten($register_link)))
57
+ $register_link = $shorter_url.'#'.$_SERVER['HTTP_HOST'];
58
+ }
59
+ return apply_filters('ws_plugin__s2member_register_link_gen', ((!empty($register_link)) ? $register_link : FALSE), get_defined_vars());
60
+ }
61
 
62
+ /**
63
+ * Generates Registration Access Links via AJAX.
64
+ *
65
+ * @package s2Member\Registrations
66
+ * @since 3.5
67
+ *
68
+ * @attaches-to ``add_action('wp_ajax_ws_plugin__s2member_reg_access_link_via_ajax');``
69
+ *
70
+ * @return null Exits script execution after output is generated for AJAX caller.
71
+ */
72
+ public static function reg_access_link_via_ajax()
73
+ {
74
+ do_action('ws_plugin__s2member_before_reg_access_link_via_ajax', get_defined_vars());
75
 
76
+ status_header(200); // Send a 200 OK status header.
77
+ header('Content-Type: text/plain; charset=UTF-8'); // Content-Type with UTF-8.
78
+ while(@ob_end_clean()) ; // Clean any existing output buffers.
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ if(current_user_can('create_users')) // Check privileges as well. Ability to create Users?
 
 
81
 
82
+ if(!empty($_POST['ws_plugin__s2member_reg_access_link_via_ajax']) && is_string($nonce = $_POST['ws_plugin__s2member_reg_access_link_via_ajax']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-reg-access-link-via-ajax'))
83
 
84
+ if(($_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST))) && isset ($_p['s2member_reg_access_link_subscr_gateway'], $_p['s2member_reg_access_link_subscr_id'], $_p['s2member_reg_access_link_custom'], $_p['s2member_reg_access_link_item_number']))
85
+ $register_link = c_ws_plugin__s2member_register_access::register_link_gen((string)$_p['s2member_reg_access_link_subscr_gateway'], (string)$_p['s2member_reg_access_link_subscr_id'], (string)$_p['s2member_reg_access_link_custom'], (string)$_p['s2member_reg_access_link_item_number']);
86
 
87
+ exit(apply_filters('ws_plugin__s2member_reg_access_link_via_ajax', ((!empty($register_link)) ? $register_link : ''), get_defined_vars()));
88
+ }
89
 
90
+ /**
91
+ * Checks registration cookies.
92
+ *
93
+ * @package s2Member\Registrations
94
+ * @since 110707
95
+ *
96
+ * @return array|bool An array of cookies if they're OK, else false.
97
+ */
98
+ public static function reg_cookies_ok()
99
+ {
100
+ global $wpdb;
101
+ /** @var $wpdb \wpdb */
 
102
 
103
+ do_action('ws_plugin__s2member_before_reg_cookies_ok', get_defined_vars());
104
 
105
+ if(isset ($_COOKIE['s2member_subscr_gateway'], $_COOKIE['s2member_subscr_id'], $_COOKIE['s2member_custom'], $_COOKIE['s2member_item_number']))
106
+ if(($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt((string)$_COOKIE['s2member_subscr_gateway'])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt((string)$_COOKIE['s2member_subscr_id'])) && preg_match('/^'.preg_quote(preg_replace('/\:([0-9]+)$/', '', $_SERVER['HTTP_HOST']), '/').'/i', ($custom = c_ws_plugin__s2member_utils_encryption::decrypt((string)$_COOKIE['s2member_custom']))) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], ($item_number = c_ws_plugin__s2member_utils_encryption::decrypt((string)$_COOKIE['s2member_item_number']))) && !$wpdb->get_var("SELECT `user_id` FROM `".$wpdb->usermeta."` WHERE `meta_key` = '".$wpdb->prefix."s2member_subscr_id' AND `meta_value` = '".esc_sql($subscr_id)."' LIMIT 1"))
107
+ $reg_cookies_ok = $reg_cookies = array('subscr_gateway' => $subscr_gateway, 'subscr_id' => $subscr_id, 'custom' => $custom, 'item_number' => $item_number);
108
 
109
+ return apply_filters('ws_plugin__s2member_reg_cookies_ok', !empty($reg_cookies_ok) && !empty($reg_cookies) ? $reg_cookies : FALSE, get_defined_vars());
110
+ }
 
111
  }
112
+ }
includes/classes/registrations.inc.php CHANGED
@@ -1,1162 +1,1207 @@
1
  <?php
2
  /**
3
- * Registration handlers.
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\Registrations
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_registrations"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Registration handlers.
24
- *
25
- * @package s2Member\Registrations
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_registrations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  {
30
- /**
31
- * Filters WordPress randomly generated Passwords.
32
- *
33
- * Also captures Passwords generated by WordPress
34
- * *(with a global var)*, for internal use.
35
- *
36
- * @package s2Member\Registrations
37
- * @since 3.5
38
- *
39
- * @attaches-to ``add_filter("random_password");``
40
- *
41
- * @param string $password Expects a plain text Password passed through by the Filter.
42
- * @return string Password, possibly assigned through s2Member Custom Registration/Profile Field input.
43
- */
44
- public static function generate_password ($password = FALSE)
45
- {
46
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
47
- do_action("ws_plugin__s2member_before_generate_password", get_defined_vars ());
48
- unset($__refs, $__v);
49
-
50
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] || (c_ws_plugin__s2member_utils_conds::pro_is_installed () && c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user")))
51
- {
52
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !empty($_POST["ws_plugin__s2member_custom_reg_field_user_pass1"]))
53
- {
54
- if (($custom = trim (stripslashes ((string)$_POST["ws_plugin__s2member_custom_reg_field_user_pass1"]))))
55
- $password = $custom; // Yes, use s2Member custom Password supplied by User.
56
- }
57
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !empty($GLOBALS['ws_plugin__s2member_registration_vars']) && !empty($GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1']))
58
- {
59
- if (($custom = trim ((string)$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'])))
60
- $password = $custom; // Yes, use s2Member custom Password supplied by User.
61
- }
62
- else if (c_ws_plugin__s2member_utils_conds::pro_is_installed () && c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user") && !empty($GLOBALS["ws_plugin__s2member_generate_password_return"]))
63
- {
64
- if (($custom = trim (stripslashes ((string)$GLOBALS["ws_plugin__s2member_generate_password_return"]))))
65
- $password = $custom; // Yes, use s2Member custom Password supplied by Remote Op.
66
- }
67
- }
68
- return apply_filters("ws_plugin__s2member_generate_password", ($GLOBALS["ws_plugin__s2member_generate_password_return"] = $password), get_defined_vars ());
69
- }
70
-
71
- /**
72
- * Intersects with ``register_new_user()`` in the WordPress core.
73
- *
74
- * This function Filters registration errors inside `/wp-login.php` via ``register_new_user()``.
75
- *
76
- * This can ONLY be fired through `/wp-login.php` on the front-side.
77
- *
78
- * @package s2Member\Registrations
79
- * @since 140518
80
- *
81
- * @attaches-to ``add_filter("registration_errors");``
82
- *
83
- * @param WP_Error $errors Expects a `WP_Error` object passed in by the Filter.
84
- * @param string $user_login Expects the User's Username, passed in by the Filter.
85
- * @param string $user_email Expects the User's Email Address, passed in by the Filter.
86
- * @return WP_Error A `WP_Error` object instance.
87
- */
88
- public static function custom_registration_field_errors($errors = FALSE, $user_login = FALSE, $user_email = FALSE)
89
  {
90
- foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
91
- do_action("ws_plugin__s2member_before_custom_registration_field_errors", get_defined_vars());
92
- unset($__refs, $__v);
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- if (!is_admin () && preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
95
- if (is_wp_error ($errors) && !empty($_POST) && is_array($_POST))
96
- {
97
- foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $_key => $_value)
98
- if(strpos($_key, "ws_plugin__s2member_custom_reg_field_") === 0)
99
- $input[str_replace("ws_plugin__s2member_custom_reg_field_", "", $_key)] = $_value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- $fields_to_validate = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration", TRUE);
102
- $validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(!empty($input) ? $input : array(), $fields_to_validate);
103
 
104
- if($validation_errors) foreach($validation_errors as $_field_var => $_error)
105
- $errors->add("custom_reg_field_".$_field_var, $_error);
106
- unset($_field_var, $_error);
107
- }
108
- return apply_filters("ws_plugin__s2member_custom_registration_field_errors", $errors, get_defined_vars ());
109
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- /**
112
- * Intersects with ``bp_core_screen_signup()`` in the BuddyPress core.
113
- *
114
- * This can ONLY be fired through `/register` via BuddyPress.
115
- *
116
- * @package s2Member\Registrations
117
- * @since 140518
118
- *
119
- * @attaches-to ``add_action("bp_signup_validate");``
120
- */
121
- public static function custom_registration_field_errors_4bp()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  {
 
 
 
 
 
 
 
 
 
123
  foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
124
- do_action("ws_plugin__s2member_before_custom_registration_field_errors_4bp", get_defined_vars());
125
  unset($__refs, $__v);
 
 
 
126
 
127
- if (!is_admin () && c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())
128
- if(in_array("registration", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
129
- if(apply_filters("ws_plugin__s2member_custom_registration_fields_4bp_display", true, get_defined_vars ()))
130
- if (!empty($GLOBALS["bp"]->signup) && is_object($GLOBALS["bp"]->signup) && !empty($_POST) && is_array($_POST))
131
- {
132
- foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $_key => $_value)
133
- if(strpos($_key, "ws_plugin__s2member_custom_reg_field_") === 0)
134
- $input[str_replace("ws_plugin__s2member_custom_reg_field_", "", $_key)] = $_value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
136
- $fields_to_validate = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration", TRUE);
137
- $validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(!empty($input) ? $input : array(), $fields_to_validate);
 
 
138
 
139
- if($validation_errors) foreach($validation_errors as $_field_var => $_error)
140
- $GLOBALS["bp"]->signup->errors["custom_reg_field_".$_field_var] = $_error;
141
- unset($_field_var, $_error);
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
 
 
144
 
145
- /**
146
- * Filters Multisite User validation.
147
- *
148
- * This can ONLY be fired through `/wp-signup.php` on the front-side.
149
- * Or through `/register` via BuddyPress.
150
- *
151
- * @package s2Member\Registrations
152
- * @since 3.5
153
- *
154
- * @attaches-to ``add_filter("wpmu_validate_user_signup");``
155
- *
156
- * @param array $result Expects a ``$result`` array to be passed through by the Filter.
157
- * @return array The Filtered ``$result`` array. Possibly containing errors introduced by s2Member.
158
- */
159
- public static function ms_validate_user_signup ($result = FALSE)
160
- {
161
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
162
- do_action("ws_plugin__s2member_before_ms_validate_user_signup", get_defined_vars ());
163
- unset($__refs, $__v);
164
-
165
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
166
- if (!is_admin () && isset ($result["user_name"], $result["user_email"], $result["errors"]) && ((preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && !empty($_POST["stage"]) && preg_match ("/^validate-(user|blog)-signup$/", (string)$_POST["stage"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())))
167
- {
168
- $errors =& $result["errors"]; /** @var $errors WP_Error */
169
- if (in_array($errors->get_error_code (), array("user_name", "user_email", "user_email_used")))
170
- if (c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($result["user_name"], $result["user_email"]))
171
- {
172
- unset($errors->errors["user_name"], $errors->errors["user_email"], $errors->errors["user_email_used"]);
173
- unset($errors->error_data["user_name"], $errors->error_data["user_email"], $errors->error_data["user_email_used"]);
174
- }
175
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
176
- do_action("ws_plugin__s2member_during_ms_validate_user_signup", get_defined_vars ());
177
- unset($__refs, $__v);
178
- }
179
- return apply_filters("ws_plugin__s2member_ms_validate_user_signup", $result, get_defined_vars ());
180
- }
181
- /**
182
- * Adds hidden fields for ``$_POST`` vars on signup.
183
- *
184
- * This can ONLY be fired through `/wp-signup.php` on the front-side.
185
- * Or through `/register` via BuddyPress.
186
- *
187
- * @package s2Member\Registrations
188
- * @since 3.5
189
- *
190
- * @attaches-to ``add_filter("signup_hidden_fields");``
191
- */
192
- public static function ms_process_signup_hidden_fields ()
193
- {
194
- do_action("ws_plugin__s2member_before_ms_process_signup_hidden_fields", get_defined_vars ());
195
-
196
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
197
- if (!is_admin () && !empty($_POST) && is_array($_POST) && ((preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && !empty($_POST["stage"]) && preg_match ("/^validate-(user|blog)-signup$/", (string)$_POST["stage"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())))
198
- {
199
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) as $key => $value)
200
- if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
201
- if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
202
- echo '<input type="hidden" name="' . esc_attr ($key) . '" value="' . esc_attr (maybe_serialize ($value)) . '" />' . "\n";
203
-
204
- do_action("ws_plugin__s2member_during_ms_process_signup_hidden_fields", get_defined_vars ());
205
- }
206
- do_action("ws_plugin__s2member_after_ms_process_signup_hidden_fields", get_defined_vars ());
207
- }
208
- /**
209
- * Adds Customs Fields to ``$meta`` on signup.
210
- *
211
- * This can ONLY be fired through `/wp-signup.php` on the front-side.
212
- * Or possibly through `/user-new.php` in the admin.
213
- * Or through `/register` via BuddyPress.
214
- *
215
- * @package s2Member\Registrations
216
- * @since 3.5
217
- *
218
- * @attaches-to ``add_filter("add_signup_meta");``
219
- * @attaches-to ``add_filter("bp_signup_usermeta");``
220
- *
221
- * @param array $meta Expects an array of meta-data to be passed in by the Filter.
222
- * @return array Full ``$meta`` array with s2Member Custom Fields included.
223
- */
224
- public static function ms_process_signup_meta($meta = FALSE)
225
- {
226
- global /* Multisite Networking. */ $current_site, $current_blog;
227
- global $pagenow; // Need this to detect the current admin page.
228
-
229
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
230
- do_action("ws_plugin__s2member_before_ms_process_signup_meta", get_defined_vars ());
231
- unset($__refs, $__v);
232
-
233
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
234
- if (!empty($_POST) && is_array($_POST) && ((is_blog_admin () && $pagenow === "user-new.php") || (!is_admin () && ((preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && !empty($_POST["stage"]) && preg_match ("/^validate-(user|blog)-signup$/", (string)$_POST["stage"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())))))
235
- {
236
- c_ws_plugin__s2member_email_configs::email_config (); // Configures `From:` header used in notifications.
237
-
238
- $meta["add_to_blog"] = (empty($meta["add_to_blog"])) ? $current_blog->blog_id : $meta["add_to_blog"];
239
- $meta["new_role"] = (empty($meta["new_role"])) ? get_option("default_role") : $meta["new_role"];
240
-
241
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) as $key => $value)
242
- if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
243
- if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
244
- $meta["s2member_ms_signup_meta"][$key] = maybe_unserialize ($value);
245
- }
246
- return apply_filters("ws_plugin__s2member_ms_process_signup_meta", $meta, get_defined_vars ());
247
- }
248
- /**
249
- * Intersects with ``wpmu_activate_signup()`` through s2Member's Multisite Networking patch.
250
- *
251
- * This function should return the same array that `wpmu_activate_signup()` returns; with the assumption that ``$user_already_exists``.
252
- * Which is exactly where this function intersects inside the `/wp-includes/ms-functions.php`.
253
- *
254
- * This can ONLY be fired through `/wp-activate.php` on the front-side.
255
- * Or through `/activate` via BuddyPress.
256
- *
257
- * @package s2Member\Registrations
258
- * @since 3.5
259
- *
260
- * @attaches-to ``add_filter("_wpmu_activate_existing_error_");``
261
- *
262
- * @param WP_Error $_error Expects a `WP_Error` object to be passed through by the Filter.
263
- * @param array $vars Expects the defined variables from the scope of the calling Filter.
264
- * @return WP_Error|array If unable to add an existing User, the original ``$_error`` obj is returned.
265
- * Otherwise we return an array of User details for continued processing by the caller.
266
- */
267
- public static function ms_activate_existing_user ($_error = FALSE, $vars = FALSE)
268
- {
269
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
270
- do_action("ws_plugin__s2member_before_ms_activate_existing_user", get_defined_vars ());
271
- unset($__refs, $__v);
272
 
273
- extract ($vars); // Extract all variables from ``wpmu_activate_signup()`` function.
274
 
275
- if (is_multisite()) // This event should ONLY be processed with Multisite Networking.
276
- if (!is_admin () && ((preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page())))
277
- {
278
- if (!empty($user_id) && !empty($user_login) && !empty($user_email) && !empty($password) && !empty($meta) && !empty($meta["add_to_blog"]) && !empty($meta["new_role"]))
279
- if (!empty($user_already_exists) && c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email, $meta["add_to_blog"]))
280
- {
281
- add_user_to_blog($meta["add_to_blog"], $user_id, $meta["new_role"]); // Add this User to the specified Blog.
282
- wp_update_user(array("ID" => $user_id, "user_pass" => $password)); // Update Password so it's the same as in the following msg.
283
- wpmu_welcome_user_notification($user_id, $password, $meta); // Send welcome letter via email just like ``wpmu_activate_signup()`` does.
284
 
285
- do_action("wpmu_activate_user", $user_id, $password, $meta); // Process Hook that would have been fired inside ``wpmu_activate_signup()``.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
- return apply_filters("ws_plugin__s2member_ms_activate_existing_user", array("user_id" => $user_id, "password" => $password, "meta" => $meta), get_defined_vars ());
288
- }
289
- }
290
- return apply_filters("ws_plugin__s2member_ms_activate_existing_user", $_error, get_defined_vars ()); // Else, return the standardized error.
291
- }
292
- /**
293
- * Configures new Users on a Multisite Network installation.
294
- *
295
- * This can ONLY be fired in the admin via `/user-new.php`.
296
- * Or also during an actual activation; through `/wp-activate.php`.
297
- * Or also during an actual activation; through `/activate` via BuddyPress.
298
- *
299
- * @package s2Member\Registrations
300
- * @since 3.5
301
- *
302
- * @attaches-to ``add_action("wpmu_activate_user");``
303
- *
304
- * @param int|string $user_id A numeric WordPress User ID.
305
- * @param string $password Plain text Password should be passed through by the Action Hook.
306
- * @param array $meta Expects an array of ``$meta`` details, passed through by the Action Hook.
307
- */
308
- public static function configure_user_on_ms_user_activation ($user_id = FALSE, $password = FALSE, $meta = FALSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  {
310
- global $pagenow; // Detect the current admin page.
 
 
 
 
311
 
312
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
313
- do_action("ws_plugin__s2member_before_configure_user_on_ms_user_activation", get_defined_vars ());
314
- unset($__refs, $__v);
 
 
 
315
 
316
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
317
- if ((is_blog_admin () && $pagenow === "user-new.php" && isset ($_POST["noconfirmation"])) || (!is_admin () && ((preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_activation_page ()))))
318
- {
319
- c_ws_plugin__s2member_registrations::configure_user_registration ($user_id, $password, ((isset ($meta["s2member_ms_signup_meta"]) && is_array($meta["s2member_ms_signup_meta"])) ? $meta["s2member_ms_signup_meta"] : array()));
320
- delete_user_meta ($user_id, "s2member_ms_signup_meta");
321
- }
322
 
323
- do_action("ws_plugin__s2member_after_configure_user_on_ms_user_activation", get_defined_vars ());
324
- }
325
- /**
326
- * Configures new Users on a Multisite Network installation.
327
- *
328
- * This does NOT fire for a Super Admin managing Network Blogs.
329
- * Actually it does; BUT it's blocked by the routine below.
330
- * A Super Admin should NOT trigger this event.
331
- *
332
- * This function should ONLY be fired through `/wp-activate.php`.
333
- * Or also through `/activate` via BuddyPress.
334
- *
335
- * @package s2Member\Registrations
336
- * @since 3.5
337
- *
338
- * @attaches-to ``add_action("wpmu_activate_blog");``
339
- *
340
- * @param int|string $blog_id A numeric WordPress Blog ID.
341
- * @param int|string $user_id A numeric WordPress User ID.
342
- * @param string $password Plain text Password should be passed through by the Action Hook.
343
- * @param string $title The title that a User chose during signup; for their new Blog on the Network.
344
- * @param array $meta Expects an array of ``$meta`` details, passed through by the Action Hook.
345
- */
346
- public static function configure_user_on_ms_blog_activation ($blog_id = FALSE, $user_id = FALSE, $password = FALSE, $title = FALSE, $meta = FALSE)
347
- {
348
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
349
- do_action("ws_plugin__s2member_before_configure_user_on_ms_blog_activation", get_defined_vars ());
350
- unset($__refs, $__v);
351
-
352
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
353
- if (!is_admin () && ((preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_activation_page ())))
354
- {
355
- c_ws_plugin__s2member_registrations::configure_user_registration ($user_id, $password, ((isset ($meta["s2member_ms_signup_meta"]) && is_array($meta["s2member_ms_signup_meta"])) ? $meta["s2member_ms_signup_meta"] : array()));
356
- delete_user_meta ($user_id, "s2member_ms_signup_meta");
357
- }
358
- do_action("ws_plugin__s2member_after_configure_user_on_ms_blog_activation", get_defined_vars ());
359
- }
360
 
361
- /**
362
- * Assigns the proper role/ccaps on BP user activation.
363
- *
364
- * @attaches-to `bp_core_activated_user`
365
- *
366
- * @param string|integer $user_id Passed in by hook.
367
- */
368
- public static function bp_user_activation($user_id)
369
- {
370
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
371
- do_action("ws_plugin__s2member_before_bp_user_activation", get_defined_vars ());
372
- unset($__refs, $__v);
373
 
374
- if(is_multisite() || !$user_id) return; // Nothing to do.
 
375
 
376
- $role = get_user_option('s2member_bp_activation_role', $user_id);
377
- $ccaps = get_user_option('s2member_bp_activation_ccaps', $user_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
 
379
- delete_user_option($user_id, 's2member_bp_activation_role');
380
- delete_user_option($user_id, 's2member_bp_activation_ccaps');
381
 
382
- if($role && ($user = new WP_User($user_id)) && $user->ID)
383
- {
384
- $user->set_role($role);
385
- if($ccaps && is_array($ccaps)) foreach($ccaps as $_ccap)
386
- $user->add_cap('access_s2member_ccap_'.$_ccap);
387
- unset($_ccap); // Housekeeping.
388
- }
389
  }
 
 
 
390
 
391
- /**
392
- * Intersects with ``register_new_user()`` through s2Member's Multisite Networking patch.
393
- *
394
- * This function Filters registration errors inside `/wp-login.php` via ``register_new_user()``.
395
- * When an existing Multisite User is registering, this takes over registration processing.
396
- *
397
- * This can ONLY be fired through `/wp-login.php` on the front-side.
398
- *
399
- * @package s2Member\Registrations
400
- * @since 3.5
401
- *
402
- * @attaches-to ``add_filter("registration_errors");``
403
- *
404
- * @param WP_Error $errors Expects a `WP_Error` object passed in by the Filter.
405
- * @param string $user_login Expects the User's Username, passed in by the Filter.
406
- * @param string $user_email Expects the User's Email Address, passed in by the Filter.
407
- * @return WP_Error A `WP_Error` object, or exits script execution after handling registration redirection.
408
- */
409
- public static function ms_register_existing_user ($errors = FALSE, $user_login = FALSE, $user_email = FALSE)
410
- {
411
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
412
- do_action("ws_plugin__s2member_before_ms_register_existing_user", get_defined_vars ());
413
- unset($__refs, $__v);
414
-
415
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
416
- if (!is_admin () && /* `/wp-login.php`? */ preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
417
- if (is_wp_error ($errors) && $errors->get_error_codes ()) // Errors?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  {
419
- if (($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email)))
420
- {
421
- foreach ($errors->get_error_codes () as $error_code)
422
- if (!in_array($error_code, array("username_exists", "email_exists")))
423
- $other_important_errors_exist[] = $error_code;
424
 
425
- if (empty($other_important_errors_exist)) // Only if/when NO other important errors exist already.
426
- {
427
- $user_pass = wp_generate_password (); // A new Password for this User/Member will be generated now.
428
- c_ws_plugin__s2member_registrations::ms_create_existing_user ($user_login, $user_email, $user_pass, $user_id);
429
- update_user_option ($user_id, "default_password_nag", true, true); // Setup Password-change nag screen.
430
- wp_new_user_notification ($user_id, $user_pass); // Welcome email, just like ``register_new_user()``.
431
 
432
- $redirect_to = (!empty($_REQUEST["redirect_to"])) ? trim (stripslashes ($_REQUEST["redirect_to"])) : false;
433
- $redirect_to = ($redirect_to) ? $redirect_to : add_query_arg ("checkemail", urlencode ("registered"), wp_login_url ());
 
 
 
434
 
435
- do_action("ws_plugin__s2member_during_ms_register_existing_user", get_defined_vars ());
 
436
 
437
- wp_safe_redirect ($redirect_to) . exit (); // Safe, like: ``register_new_user()``.
438
- }
439
- }
440
- }
441
- else if (($ms = wpmu_validate_user_signup ($user_login, $user_email)) && isset ($ms["errors"]) && is_wp_error ($ms["errors"]) && $ms["errors"]->get_error_code ())
442
- $errors->add ($ms["errors"]->get_error_code (), $ms["errors"]->get_error_message ());
443
 
444
- return apply_filters("ws_plugin__s2member_ms_register_existing_user", $errors, get_defined_vars ());
445
- }
446
- /**
447
- * For Multisite Networks, this function is used to add a User to an existing Blog; and to simulate ``wp_create_user()`` behavior.
448
- *
449
- * The ``$user_id`` value will be returned by this function, just like ``wp_create_user()`` does.
450
- * This function will fire the Hook `user_register`.
451
- *
452
- * @package s2Member\Registrations
453
- * @since 3.5
454
- *
455
- * @param string $user_login Expects the User's Username.
456
- * @param string $user_email Expects the User's Email Address.
457
- * @param string $user_pass Expects the User's plain text Password.
458
- * @param int|string $user_id Optional. A numeric WordPress User ID.
459
- * If unspecified, a lookup is performed with ``$user_login`` and ``$user_email``.
460
- * @return int|false Returns numeric ``$user_id`` on success, else false on failure.
461
- */
462
- public static function ms_create_existing_user ($user_login = FALSE, $user_email = FALSE, $user_pass = FALSE, $user_id = FALSE)
463
- {
464
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
465
- do_action("ws_plugin__s2member_before_ms_create_existing_user", get_defined_vars ());
466
- unset($__refs, $__v);
467
 
468
- if (is_multisite ()) // This event should ONLY be processed with Multisite Networking.
469
- {
470
- if (($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog ($user_login, $user_email))) && $user_pass)
471
- {
472
- $role = get_option ("default_role"); // Use default Role.
473
- add_existing_user_to_blog (array("user_id" => $user_id, "role" => $role)); // Add User.
474
- wp_update_user (array("ID" => $user_id, "user_pass" => $user_pass)); // Update to ``$user_pass``.
475
-
476
- do_action("ws_plugin__s2member_during_ms_create_existing_user", get_defined_vars ());
477
- do_action("user_register", $user_id); // So s2Member knows a User is registering.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
 
479
- return apply_filters("ws_plugin__s2member_ms_create_existing_user", $user_id, get_defined_vars ());
480
- }
481
- }
482
- return apply_filters("ws_plugin__s2member_ms_create_existing_user", false, get_defined_vars ());
483
- }
484
- /**
485
- * Configures all new Users.
486
- *
487
- * The Hook `user_register` is also fired by calling:
488
- * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
489
- *
490
- * This function also receives hand-offs from s2Member's handlers for these two Hooks:
491
- * `wpmu_activate_user` and `wpmu_activate_blog`.
492
- *
493
- * @package s2Member\Registrations
494
- * @since 3.5
495
- *
496
- * @attaches-to ``add_action("user_register");``
497
- *
498
- * @param int|string $user_id A numeric WordPress User ID.
499
- * @param string $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
500
- * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
501
- *
502
- * @TODO Impossible to delete cookies when fired inside: `/wp-activate.php`?
503
- */
504
- public static function configure_user_registration ($user_id = FALSE, $password = FALSE, $meta = FALSE)
505
- {
506
- global /* Global database object reference. */ $wpdb;
507
- global $pagenow; // We need this to detect the current administration page.
508
- global $current_site, $current_blog; // Adds support for Multisite Networking.
509
- static $email_config, $processed; // Static vars prevent duplicate processing.
510
 
511
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
512
- do_action("ws_plugin__s2member_before_configure_user_registration", get_defined_vars ());
513
- unset($__refs, $__v);
514
 
515
- // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
516
- if (!isset ($email_config) && ($email_config = true)) // Anytime this routine is fired; we configure email.
517
- c_ws_plugin__s2member_email_configs::email_config (); // Configures `From:` email header.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
 
519
- $_p = /* Grab global ``$_POST`` array here, if it's possible to do so. */ (isset ($_POST)) ? $_POST : null;
520
- $rvs = (isset ($GLOBALS["ws_plugin__s2member_registration_vars"])) ? $GLOBALS["ws_plugin__s2member_registration_vars"] : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
 
522
- if (!$processed /* Process only once. Safeguard this routine against duplicate processing via plugins (or even WordPress itself). */)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
 
524
- if ( /* We MUST have at least ONE of these three arrays. Any of these will do in most cases. */is_array($_p) || is_array($meta) || is_array($rvs))
 
 
525
 
526
- if (!(is_multisite () && is_blog_admin () && $pagenow === "user-new.php" && isset ($_p["noconfirmation"]) && is_super_admin () && !is_array($meta)))
527
- if (!(preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"]) && !is_array($meta)) /* If activating; we absolutely MUST have a ``$meta`` array. */)
528
- if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_activation_page () && !is_array($meta)) /* If activating; MUST have ``$meta``. */)
529
- if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed () && c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user") && !is_array($rvs)))
530
 
531
- if ($user_id && is_object ($user = new WP_User ($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = true))
532
- {
533
- settype /* Force arrays here. */ ($_p, "array") . settype ($meta, "array") . settype ($rvs, "array");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
 
535
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_p));
536
- $meta = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($meta));
537
- $rvs = c_ws_plugin__s2member_utils_strings::trim_deep /* Do NOT strip. */ ($rvs);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
538
 
539
- foreach ($_p as $_key => $_value) // Scan ``$_p`` vars; adding `custom_reg_field` keys.
540
- if (preg_match ("/^ws_plugin__s2member_user_new_/", $_key)) // Look for keys.
541
- if ($_key = str_replace ("_user_new_", "_custom_reg_field_", $_key))
542
- $_p[$_key] = $_value; // Add each of these key conversions.
543
- unset /* Just a little housekeeping here. */ ($_key, $_value);
544
 
545
- if (!is_admin () && (isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_baid"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_cid"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_custom"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) || isset ($_p["ws_plugin__s2member_custom_reg_field_s2member_notes"])))
546
- exit (_x ("s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!", "s2member-front", "s2member"));
 
547
 
548
- $_pmr = array_merge ($_p, $meta, $rvs); // Merge all of these arrays together now, in this specific order.
549
- unset($_p, $meta, $rvs); // These variables can all be unset now; we have them all in the ``$_pmr`` array.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
 
551
- $custom_reg_display_name = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_display_name"]; // Can be configured by the site owner.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
 
553
- if (!is_admin () && (!c_ws_plugin__s2member_utils_conds::pro_is_installed () || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user")) && /* A paying Customer? */ ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok ()) && extract ($reg_cookies))
554
- { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
555
- This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
556
- If processed through `/wp-activate.php`, it could've originated inside the admin — via `/user-new.php`. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
- $processed = "yes"; // Mark this as yes.
559
-
560
- $current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
561
- @list ($level, $ccaps, $eotper) = preg_split ("/\:/", $item_number, 3);
562
- $role = "s2member_level" . $level; // Membership Level.
563
-
564
- $email = $user->user_email;
565
- $login = $user->user_login;
566
- $ip = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
567
- $ip = (!$ip) ? $_SERVER["REMOTE_ADDR"] : $ip; // Else use environment variable.
568
- $subscr_baid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_baid"];
569
- $subscr_cid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_cid"];
570
- $cv = preg_split ("/\|/", $custom);
571
-
572
- if (!($auto_eot_time = "") && $eotper) // If a specific EOT Period is included.
573
- $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $eotper);
574
-
575
- $notes = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
576
-
577
- $opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
578
- $opt_in = (!$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"])) ? true : $opt_in;
579
-
580
- if (!($fname = $user->first_name))
581
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"]))
582
- $fname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
583
-
584
- if (!$fname) // Also try BuddyPress.
585
- if (!empty($_pmr["field_1"])) // BuddyPress?
586
- $fname = trim (preg_replace ("/ (.*)$/", "", (string)$_pmr["field_1"]));
587
-
588
- if (!($lname = $user->last_name))
589
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"]))
590
- $lname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
591
-
592
- if (!$lname) // Also try BuddyPress.
593
- if (!empty($_pmr["field_1"]) && preg_match ("/^(.+?) (.+)$/", (string)$_pmr["field_1"]))
594
- $lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", (string)$_pmr["field_1"]));
595
-
596
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login)
597
- { $fname = trim ($login); $lname = ""; } // Username and empty Last Name.
598
-
599
- $name = trim ($fname . " " . $lname); // Both names.
600
-
601
- if (!($pass = $password)) // Try s2Member's generator.
602
- if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"]))
603
- $pass = (string)$GLOBALS["ws_plugin__s2member_generate_password_return"];
604
-
605
- if (!$pass) // Also try BuddyPress Password.
606
- if (!empty($_pmr["signup_password"])) // BuddyPress?
607
- $pass = (string)$_pmr["signup_password"];
608
-
609
- if ($pass) // No Password nag. Update this globally.
610
- {
611
- (!headers_sent ()) ? delete_user_setting ("default_password_nag", $user_id) : null;
612
- update_user_option ($user_id, "default_password_nag", false, true);
613
- }
614
- update_user_option ($user_id, "s2member_registration_ip", $ip);
615
- update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
616
- update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
617
- update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
618
- update_user_option ($user_id, "s2member_subscr_baid", $subscr_baid);
619
- update_user_option ($user_id, "s2member_subscr_cid", $subscr_cid);
620
- update_user_option ($user_id, "s2member_custom", $custom);
621
- update_user_option ($user_id, "s2member_notes", $notes);
622
-
623
- if (!$user->first_name && $fname)
624
- update_user_meta ($user_id, "first_name", $fname);
625
-
626
- if (!$user->last_name && $lname)
627
- update_user_meta ($user_id, "last_name", $lname);
628
-
629
- if (!$user->display_name || $user->display_name === $user->user_login)
630
- {
631
- if ($custom_reg_display_name === "full" && $name)
632
- wp_update_user (array("ID" => $user_id, "display_name" => $name));
633
- else if ($custom_reg_display_name === "first" && $fname)
634
- wp_update_user (array("ID" => $user_id, "display_name" => $fname));
635
- else if ($custom_reg_display_name === "last" && $lname)
636
- wp_update_user (array("ID" => $user_id, "display_name" => $lname));
637
- else if ($custom_reg_display_name === "login" && $login)
638
- wp_update_user (array("ID" => $user_id, "display_name" => $login));
639
- }
640
- if (is_multisite ()) // Should we handle Main Site permissions and Originating Blog ID#?
641
- {
642
- if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
643
- remove_user_from_blog ($user_id, $current_site->blog_id); // No Main Site Role.
644
-
645
- if (!get_user_meta ($user_id, "s2member_originating_blog", true)) // Recorded yet?
646
- update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
647
- }
648
- if ($current_role !== $role) // Only if NOT the current Role.
649
- $user->set_role ($role); // s2Member.
650
-
651
- if ($ccaps && preg_match ("/^-all/", str_replace ("+", "", $ccaps)))
652
- foreach ($user->allcaps as $cap => $cap_enabled)
653
- if (preg_match ("/^access_s2member_ccap_/", $cap))
654
- $user->remove_cap ($ccap = $cap);
655
-
656
- if ($ccaps && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps)))
657
- foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps))) as $ccap)
658
- if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
659
- $user->add_cap ("access_s2member_ccap_" . $ccap);
660
-
661
- if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
662
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
663
- {
664
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
665
- $field_id_class = preg_replace ("/_/", "-", $field_var);
666
-
667
- if (isset ($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]))
668
- $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
669
- }
670
- unset($field, $field_var, $field_id_class); // Housekeeping.
671
-
672
- if (!empty($fields)) // Only if NOT empty.
673
- update_user_option ($user_id, "s2member_custom_fields", $fields);
674
-
675
- if ($level > 0) // We ONLY process this if they are higher than Level #0.
676
- {
677
- $pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
678
- $pr_times["level"] = (empty($pr_times["level"])) ? time () : $pr_times["level"];
679
- $pr_times["level" . $level] = (empty($pr_times["level" . $level])) ? time () : $pr_times["level" . $level];
680
- update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); // Update now.
681
- }
682
- if(!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())
683
- {
684
- update_user_option($user_id, "s2member_bp_activation_role", $role);
685
- update_user_option($user_id, "s2member_bp_activation_ccaps", c_ws_plugin__s2member_user_access::user_access_ccaps($user));
686
- }
687
- if (($transient = "s2m_" . md5 ("s2member_transient_ipn_signup_vars_" . $subscr_id)) && is_array($ipn_signup_vars = get_transient ($transient)))
688
- {
689
- update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars); // For future reference.
690
- delete_transient ($transient); // This can be deleted now.
691
- }
692
- if (($transient = "s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array($subscr_payment = get_transient ($transient)) && !empty($subscr_payment["subscr_gateway"]))
693
- {
694
- $proxy = array("s2member_paypal_proxy" => stripslashes ((string)$subscr_payment["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen ());
695
- c_ws_plugin__s2member_utils_urls::remote (home_url ("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep ($subscr_payment), $proxy), array("timeout" => 20));
696
- delete_transient ($transient); // This can be deleted now.
697
- }
698
- if (($transient = "s2m_" . md5 ("s2member_transient_ipn_subscr_eot_" . $subscr_id)) && is_array($subscr_eot = get_transient ($transient)) && !empty($subscr_eot["subscr_gateway"]))
699
- {
700
- $proxy = array("s2member_paypal_proxy" => stripslashes ((string)$subscr_eot["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen ());
701
- c_ws_plugin__s2member_utils_urls::remote (home_url ("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep ($subscr_eot), $proxy), array("timeout" => 20));
702
- delete_transient ($transient); // This can be deleted now.
703
- }
704
- if (!headers_sent ()) // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
705
- @setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id)), time () + 31556926, COOKIEPATH, COOKIE_DOMAIN).
706
- @setcookie("s2member_tracking", $s2member_tracking, time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).
707
- ($_COOKIE["s2member_tracking"] = $s2member_tracking);
708
-
709
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
710
- do_action("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars ());
711
- do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
712
- unset($__refs, $__v);
713
- }
714
- else if (!is_admin () && (!c_ws_plugin__s2member_utils_conds::pro_is_installed () || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user")))
715
- { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
716
- This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
717
- If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
718
 
719
- $processed = "yes"; // Mark this as yes.
720
-
721
- $current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
722
- $role = ""; // Initialize ``$role`` to an empty string here, before processing.
723
- $role = (!$role && ($level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0) ? "s2member_level" . $level : $role;
724
- $role = (!$role && ($level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0") ? "subscriber" : $role;
725
- $role = (!$role && $current_role) ? $current_role : $role; // Use existing Role?
726
- $role = (!$role) ? get_option ("default_role") : $role; // Otherwise default.
727
-
728
- $level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
729
- $level = (!$level && preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
730
- $level = (!$level && preg_match ("/^s2member_level[1-9][0-9]*$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
731
- $level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
732
- $level = (!$level) ? "0" : $level;
733
-
734
- $ccaps = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
735
-
736
- $email = $user->user_email;
737
- $login = $user->user_login;
738
- $ip = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
739
- $ip = (!$ip) ? $_SERVER["REMOTE_ADDR"] : $ip; // Else use environment variable.
740
- $custom = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
741
- $subscr_id = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
742
- $subscr_baid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_baid"];
743
- $subscr_cid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_cid"];
744
- $subscr_gateway = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
745
- $cv = preg_split ("/\|/", (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
746
-
747
- $auto_eot_time = ($eot = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
748
- $notes = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
749
-
750
- $opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
751
- $opt_in = (!$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"])) ? true : $opt_in;
752
-
753
- if (!($fname = $user->first_name))
754
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"]))
755
- $fname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
756
-
757
- if (!$fname) // Also try BuddyPress.
758
- if (!empty($_pmr["field_1"])) // BuddyPress?
759
- $fname = trim (preg_replace ("/ (.*)$/", "", (string)$_pmr["field_1"]));
760
-
761
- if (!($lname = $user->last_name))
762
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"]))
763
- $lname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
764
-
765
- if (!$lname) // Also try BuddyPress.
766
- if (!empty($_pmr["field_1"]) && preg_match ("/^(.+?) (.+)$/", (string)$_pmr["field_1"]))
767
- $lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", (string)$_pmr["field_1"]));
768
-
769
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login)
770
- { $fname = trim ($login); $lname = ""; } // Username and empty Last Name.
771
-
772
- $name = trim ($fname . " " . $lname); // Both names.
773
-
774
- if (!($pass = $password)) // Try s2Member's generator.
775
- if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"]))
776
- $pass = (string)$GLOBALS["ws_plugin__s2member_generate_password_return"];
777
-
778
- if (!$pass) // Also try BuddyPress Password.
779
- if (!empty($_pmr["signup_password"])) // BuddyPress?
780
- $pass = (string)$_pmr["signup_password"];
781
-
782
- if ($pass) // No Password nag. Update this globally.
783
- {
784
- (!headers_sent ()) ? delete_user_setting ("default_password_nag", $user_id) : null;
785
- update_user_option ($user_id, "default_password_nag", false, true);
786
- }
787
- update_user_option ($user_id, "s2member_registration_ip", $ip);
788
- update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
789
- update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
790
- update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
791
- update_user_option ($user_id, "s2member_subscr_baid", $subscr_baid);
792
- update_user_option ($user_id, "s2member_subscr_cid", $subscr_cid);
793
- update_user_option ($user_id, "s2member_custom", $custom);
794
- update_user_option ($user_id, "s2member_notes", $notes);
795
-
796
- if (!$user->first_name && $fname)
797
- update_user_meta ($user_id, "first_name", $fname);
798
-
799
- if (!$user->last_name && $lname)
800
- update_user_meta ($user_id, "last_name", $lname);
801
-
802
- if (!$user->display_name || $user->display_name === $user->user_login)
803
- {
804
- if ($custom_reg_display_name === "full" && $name)
805
- wp_update_user (array("ID" => $user_id, "display_name" => $name));
806
- else if ($custom_reg_display_name === "first" && $fname)
807
- wp_update_user (array("ID" => $user_id, "display_name" => $fname));
808
- else if ($custom_reg_display_name === "last" && $lname)
809
- wp_update_user (array("ID" => $user_id, "display_name" => $lname));
810
- else if ($custom_reg_display_name === "login" && $login)
811
- wp_update_user (array("ID" => $user_id, "display_name" => $login));
812
- }
813
- if /* Should we handle Main Site permissions and Originating Blog ID#? */(is_multisite ())
814
- {
815
- if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
816
- remove_user_from_blog /* No Main Site Role. */($user_id, $current_site->blog_id);
817
-
818
- if /* Recorded yet? */(!get_user_meta ($user_id, "s2member_originating_blog", true))
819
- update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
820
- }
821
- if ($current_role !== $role) // Only if NOT the current Role.
822
- $user->set_role ($role); // s2Member.
823
-
824
- if ($ccaps && preg_match ("/^-all/", str_replace ("+", "", $ccaps)))
825
- foreach ($user->allcaps as $cap => $cap_enabled)
826
- if (preg_match ("/^access_s2member_ccap_/", $cap))
827
- $user->remove_cap ($ccap = $cap);
828
-
829
- if ($ccaps && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps)))
830
- foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps))) as $ccap)
831
- if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
832
- $user->add_cap ("access_s2member_ccap_" . $ccap);
833
-
834
- if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
835
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
836
- {
837
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
838
- $field_id_class = preg_replace ("/_/", "-", $field_var);
839
-
840
- if (isset ($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]))
841
- $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
842
- }
843
- unset($field, $field_var, $field_id_class); // Housekeeping.
844
-
845
- if (!empty($fields)) // Only if NOT empty.
846
- update_user_option ($user_id, "s2member_custom_fields", $fields);
847
-
848
- if ($level > 0) // We ONLY process this if they are higher than Level#0.
849
- {
850
- $pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
851
- $pr_times["level"] = (empty($pr_times["level"])) ? time () : $pr_times["level"];
852
- $pr_times["level" . $level] = (empty($pr_times["level" . $level])) ? time () : $pr_times["level" . $level];
853
- update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); // Update now.
854
- }
855
- if(!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_register_page ())
856
- {
857
- update_user_option($user_id, "s2member_bp_activation_role", $role);
858
- update_user_option($user_id, "s2member_bp_activation_ccaps", c_ws_plugin__s2member_user_access::user_access_ccaps($user));
859
- }
860
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
861
- do_action("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars ());
862
- do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
863
- unset($__refs, $__v);
864
- }
865
- else if ((is_blog_admin () && $pagenow === "user-new.php") || (c_ws_plugin__s2member_utils_conds::pro_is_installed () && c_ws_plugin__s2member_pro_remote_ops::is_remote_op ("create_user")))
866
- { // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
867
-
868
- $processed = "yes"; // Mark this as yes, to indicate that a routine was processed.
869
-
870
- $current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
871
- $role = ""; // Initialize $role to an empty string here, before processing.
872
- $role = (!$role && ($level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0) ? "s2member_level" . $level : $role;
873
- $role = (!$role && ($level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0") ? "subscriber" : $role;
874
- $role = (!$role && $current_role) ? $current_role : $role; // Use existing Role?
875
- $role = (!$role) ? get_option ("default_role") : $role; // Otherwise default.
876
-
877
- $level = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
878
- $level = (!$level && preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
879
- $level = (!$level && preg_match ("/^s2member_level[1-9][0-9]*$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
880
- $level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
881
- $level = (!$level) ? "0" : $level;
882
-
883
- $ccaps = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
884
-
885
- $email = $user->user_email;
886
- $login = $user->user_login;
887
- $ip = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
888
- $custom = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
889
- $subscr_id = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
890
- $subscr_baid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_baid"];
891
- $subscr_cid = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_cid"];
892
- $subscr_gateway = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
893
- $cv = preg_split ("/\|/", (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
894
-
895
- $auto_eot_time = ($eot = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
896
- $notes = (string)@$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
897
-
898
- $opt_in = (!empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"])) ? true : false;
899
-
900
- if (!($fname = $user->first_name)) // `Users -› Add New`.
901
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"]))
902
- $fname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
903
-
904
- if (!($lname = $user->last_name)) // `Users -› Add New`.
905
- if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"]))
906
- $lname = (string)$_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
907
-
908
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login)
909
- { $fname = trim ($login); $lname = ""; } // Username and empty Last Name.
910
-
911
- $name = trim ($fname . " " . $lname); // Both names.
912
-
913
- if (!($pass = $password)) // Try s2Member's generator.
914
- if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"]))
915
- $pass = (string)$GLOBALS["ws_plugin__s2member_generate_password_return"];
916
-
917
- if (!$pass) // Also try the `Users -› Add New` form.
918
- if (!empty($_pmr["pass1"])) // Field in `/user-new.php`.
919
- $pass = (string)$_pmr["pass1"];
920
-
921
- if ($pass) // No Password nag. Update this globally.
922
- {
923
- (!headers_sent ()) ? delete_user_setting ("default_password_nag", $user_id) : null;
924
- update_user_option ($user_id, "default_password_nag", false, true);
925
- }
926
- update_user_option ($user_id, "s2member_registration_ip", $ip);
927
- update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
928
- update_user_option ($user_id, "s2member_subscr_gateway", $subscr_gateway);
929
- update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
930
- update_user_option ($user_id, "s2member_subscr_baid", $subscr_baid);
931
- update_user_option ($user_id, "s2member_subscr_cid", $subscr_cid);
932
- update_user_option ($user_id, "s2member_custom", $custom);
933
- update_user_option ($user_id, "s2member_notes", $notes);
934
-
935
- if (!$user->first_name && $fname)
936
- update_user_meta ($user_id, "first_name", $fname);
937
-
938
- if (!$user->last_name && $lname)
939
- update_user_meta ($user_id, "last_name", $lname);
940
-
941
- if (!$user->display_name || $user->display_name === $user->user_login)
942
- {
943
- if ($custom_reg_display_name === "full" && $name)
944
- wp_update_user (array("ID" => $user_id, "display_name" => $name));
945
- else if ($custom_reg_display_name === "first" && $fname)
946
- wp_update_user (array("ID" => $user_id, "display_name" => $fname));
947
- else if ($custom_reg_display_name === "last" && $lname)
948
- wp_update_user (array("ID" => $user_id, "display_name" => $lname));
949
- else if ($custom_reg_display_name === "login" && $login)
950
- wp_update_user (array("ID" => $user_id, "display_name" => $login));
951
- }
952
- if (is_multisite ()) // Should we handle Main Site permissions and Originating Blog ID#?
953
- {
954
- if (!is_main_site () && strtotime ($user->user_registered) >= strtotime ("-10 seconds"))
955
- remove_user_from_blog ($user_id, $current_site->blog_id); // No Main Site Role.
956
-
957
- if (!get_user_meta ($user_id, "s2member_originating_blog", true)) // Recorded yet?
958
- update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
959
- }
960
- if ($current_role !== $role) // Only if NOT the current Role.
961
- $user->set_role ($role); // s2Member.
962
-
963
- if ($ccaps && preg_match ("/^-all/", str_replace ("+", "", $ccaps)))
964
- foreach ($user->allcaps as $cap => $cap_enabled)
965
- if (preg_match ("/^access_s2member_ccap_/", $cap))
966
- $user->remove_cap ($ccap = $cap);
967
-
968
- if ($ccaps && preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps)))
969
- foreach (preg_split ("/[\r\n\t\s;,]+/", preg_replace ("/^-all[\r\n\t\s;,]*/", "", str_replace ("+", "", $ccaps))) as $ccap)
970
- if (strlen ($ccap = trim (strtolower (preg_replace ("/[^a-z_0-9]/i", "", $ccap)))))
971
- $user->add_cap ("access_s2member_ccap_" . $ccap);
972
-
973
- if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
974
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
975
- {
976
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
977
- $field_id_class = preg_replace ("/_/", "-", $field_var);
978
-
979
- if (isset ($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]))
980
- $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
981
- }
982
- unset($field, $field_var, $field_id_class); // Housekeeping.
983
-
984
- if (!empty($fields)) // Only if NOT empty.
985
- update_user_option ($user_id, "s2member_custom_fields", $fields);
986
-
987
- if ($level > 0) // We ONLY process this if they are higher than Level#0.
988
- {
989
- $pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
990
- $pr_times["level"] = (empty($pr_times["level"])) ? time () : $pr_times["level"];
991
- $pr_times["level" . $level] = (empty($pr_times["level" . $level])) ? time () : $pr_times["level" . $level];
992
- update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); // Update now.
993
- }
994
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
995
- do_action("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars ());
996
- unset($__refs, $__v);
997
- }
998
- if ($processed === "yes") // If registration was processed by one of the routines above.
999
- {
1000
- if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
1001
-
1002
- foreach (preg_split ("/[\r\n\t]+/", $urls) as $url) // Notify each of the URLs.
1003
-
1004
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)))
1005
- if (($url = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($role)), $url)))
1006
- if (($url = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($level)), $url)))
1007
- if (($url = preg_replace ("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($ccaps)), $url)))
1008
- if (($url = preg_replace ("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($auto_eot_time)), $url)))
1009
- if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($fname)), $url)))
1010
- if (($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($lname)), $url)))
1011
- if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($name)), $url)))
1012
- if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($email)), $url)))
1013
- if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($login)), $url)))
1014
- if (($url = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($pass)), $url)))
1015
- if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($ip)), $url)))
1016
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($user_id)), $url)))
1017
- {
1018
- foreach ($fields as $var => $val) // Custom Fields.
1019
- if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode (maybe_serialize ($val))), $url)))
1020
- break;
1021
-
1022
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1023
- c_ws_plugin__s2member_utils_urls::remote ($url);
1024
- }
1025
- unset($urls, $url, $var, $val); // Housekeeping.
1026
-
1027
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"])
1028
- {
1029
- $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status ();
1030
- c_ws_plugin__s2member_email_configs::email_config_release ();
1031
-
1032
- $msg = $sbj = "(s2Member / API Notification Email) - Registration";
1033
- $msg .= "\n\n"; // Spacing in the message body.
1034
-
1035
- $msg .= "role: %%role%%\n";
1036
- $msg .= "level: %%level%%\n";
1037
- $msg .= "ccaps: %%ccaps%%\n";
1038
- $msg .= "auto_eot_time: %%auto_eot_time%%\n";
1039
- $msg .= "user_first_name: %%user_first_name%%\n";
1040
- $msg .= "user_last_name: %%user_last_name%%\n";
1041
- $msg .= "user_full_name: %%user_full_name%%\n";
1042
- $msg .= "user_email: %%user_email%%\n";
1043
- $msg .= "user_login: %%user_login%%\n";
1044
- $msg .= "user_pass: %%user_pass%%\n";
1045
- $msg .= "user_ip: %%user_ip%%\n";
1046
- $msg .= "user_id: %%user_id%%\n";
1047
-
1048
- foreach ($fields as $var => $val)
1049
- $msg .= $var . ": %%" . $var . "%%\n";
1050
-
1051
- $msg .= "cv0: %%cv0%%\n";
1052
- $msg .= "cv1: %%cv1%%\n";
1053
- $msg .= "cv2: %%cv2%%\n";
1054
- $msg .= "cv3: %%cv3%%\n";
1055
- $msg .= "cv4: %%cv4%%\n";
1056
- $msg .= "cv5: %%cv5%%\n";
1057
- $msg .= "cv6: %%cv6%%\n";
1058
- $msg .= "cv7: %%cv7%%\n";
1059
- $msg .= "cv8: %%cv8%%\n";
1060
- $msg .= "cv9: %%cv9%%";
1061
-
1062
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $msg)))
1063
- if (($msg = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($role), $msg)))
1064
- if (($msg = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($level), $msg)))
1065
- if (($msg = preg_replace ("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($ccaps), $msg)))
1066
- if (($msg = preg_replace ("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($auto_eot_time), $msg)))
1067
- if (($msg = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($fname), $msg)))
1068
- if (($msg = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($lname), $msg)))
1069
- if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($name), $msg)))
1070
- if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($email), $msg)))
1071
- if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($login), $msg)))
1072
- if (($msg = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($pass), $msg)))
1073
- if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($ip), $msg)))
1074
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs ($user_id), $msg)))
1075
- {
1076
- foreach ($fields as $var => $val) // Custom Fields.
1077
- if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (maybe_serialize ($val)), $msg)))
1078
- break;
1079
-
1080
- if ($sbj && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg)))) // Still have a ``$sbj`` and a ``$msg``?
1081
-
1082
- foreach (c_ws_plugin__s2member_utils_strings::parse_emails ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) as $recipient)
1083
- wp_mail ($recipient, apply_filters("ws_plugin__s2member_registration_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters("ws_plugin__s2member_registration_notification_email_msg", $msg, get_defined_vars ()), "Content-Type: text/plain; charset=UTF-8");
1084
- }
1085
- if ($email_configs_were_on) // Back on?
1086
- c_ws_plugin__s2member_email_configs::email_config ();
1087
-
1088
- unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on); // Housekeeping.
1089
- }
1090
-
1091
- if (!empty($GLOBALS["ws_plugin__s2member_registration_return_url"]) && ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"]))
1092
-
1093
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)))
1094
- if (($url = preg_replace ("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($role)), $url)))
1095
- if (($url = preg_replace ("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($level)), $url)))
1096
- if (($url = preg_replace ("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($ccaps)), $url)))
1097
- if (($url = preg_replace ("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($auto_eot_time)), $url)))
1098
- if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($fname)), $url)))
1099
- if (($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($lname)), $url)))
1100
- if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($name)), $url)))
1101
- if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($email)), $url)))
1102
- if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($login)), $url)))
1103
- if (($url = preg_replace ("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($pass)), $url)))
1104
- if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($ip)), $url)))
1105
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode ($user_id)), $url)))
1106
- {
1107
- foreach ($fields as $var => $val) // Custom Fields.
1108
- if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs (urlencode (maybe_serialize ($val))), $url)))
1109
- break;
1110
-
1111
- if (($url = trim ($url))) // Preserve remaining Replacements; because the parent routine may perform replacements too.
1112
- $GLOBALS["ws_plugin__s2member_registration_return_url"] = $url;
1113
- }
1114
- unset($url, $var, $val); // Housekeeping.
1115
-
1116
- c_ws_plugin__s2member_list_servers::process_list_servers ($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, true, $user_id);
1117
- /*
1118
- Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
1119
- @todo It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
1120
- */
1121
- if (!headers_sent ()) // Only if headers are NOT yet sent.
1122
- {
1123
- @setcookie ("s2member_subscr_gateway", "", time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie ("s2member_subscr_gateway", "", time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1124
- @setcookie ("s2member_subscr_id", "", time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie ("s2member_subscr_id", "", time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1125
- @setcookie ("s2member_custom", "", time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie ("s2member_custom", "", time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1126
- @setcookie ("s2member_item_number", "", time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie ("s2member_item_number", "", time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1127
- }
1128
- /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
1129
- Logging now supports Multisite Networking as well. */
1130
-
1131
- $reg_vars = get_defined_vars(); // All defined vars.
1132
- // No need to include these in the logs. Unset before log entry.
1133
- unset($reg_vars["wpdb"], $reg_vars["current_site"], $reg_vars["current_blog"]);
1134
-
1135
- $logt = c_ws_plugin__s2member_utilities::time_details ();
1136
- $logv = c_ws_plugin__s2member_utilities::ver_details ();
1137
- $logm = c_ws_plugin__s2member_utilities::mem_details ();
1138
- $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . @$_SERVER["HTTP_USER_AGENT"];
1139
- $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
1140
- $log2 = (is_multisite () && !is_main_site ()) ? "reg-handler-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "reg-handler.log";
1141
-
1142
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
1143
- if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1144
- if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
1145
- file_put_contents ($logs_dir . "/" . $log2,
1146
- "LOG ENTRY: ".$logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" .
1147
- c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export ($reg_vars, true)) . "\n\n",
1148
- FILE_APPEND);
1149
-
1150
- unset($logt, $logv, $logm, $log4, $_log4, $log2, $logs_dir, $reg_vars); // Housekeeping.
1151
-
1152
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
1153
- do_action("ws_plugin__s2member_during_configure_user_registration", get_defined_vars ());
1154
- unset($__refs, $__v);
1155
- }
1156
- }
1157
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
1158
- do_action("ws_plugin__s2member_after_configure_user_registration", get_defined_vars ());
1159
- unset($__refs, $__v);
1160
- }
1161
- }
1162
- }
1
  <?php
2
  /**
3
+ * Registration handlers.
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\Registrations
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_registrations'))
21
+ {
22
+ /**
23
+ * Registration handlers.
24
+ *
25
+ * @package s2Member\Registrations
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_registrations
29
  {
30
  /**
31
+ * Filters WordPress randomly generated Passwords.
32
+ *
33
+ * Also captures Passwords generated by WordPress
34
+ * *(with a global var)*, for internal use.
35
+ *
36
+ * @package s2Member\Registrations
37
+ * @since 3.5
38
+ *
39
+ * @attaches-to ``add_filter('random_password');``
40
+ *
41
+ * @param string $password Expects a plain text Password passed through by the Filter.
42
+ *
43
+ * @return string Password, possibly assigned through s2Member Custom Registration/Profile Field input.
44
+ */
45
+ public static function generate_password($password = '')
46
+ {
47
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
48
+ do_action('ws_plugin__s2member_before_generate_password', get_defined_vars());
49
+ unset($__refs, $__v);
50
+
51
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password'] || (c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')))
52
  {
53
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password'] && !empty($_POST['ws_plugin__s2member_custom_reg_field_user_pass1']))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  {
55
+ if(($custom = trim(stripslashes((string)$_POST['ws_plugin__s2member_custom_reg_field_user_pass1']))))
56
+ $password = $custom; // Yes, use s2Member custom Password supplied by User.
57
+ }
58
+ else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password'] && !empty($GLOBALS['ws_plugin__s2member_registration_vars']) && !empty($GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1']))
59
+ {
60
+ if(($custom = trim((string)$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'])))
61
+ $password = $custom; // Yes, use s2Member custom Password supplied by User.
62
+ }
63
+ else if(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user') && !empty($GLOBALS['ws_plugin__s2member_generate_password_return']))
64
+ {
65
+ if(($custom = trim(stripslashes((string)$GLOBALS['ws_plugin__s2member_generate_password_return']))))
66
+ $password = $custom; // Yes, use s2Member custom Password supplied by Remote Op.
67
+ }
68
+ }
69
+ return apply_filters('ws_plugin__s2member_generate_password', ($GLOBALS['ws_plugin__s2member_generate_password_return'] = $password), get_defined_vars());
70
+ }
71
 
72
+ /**
73
+ * Intersects with ``register_new_user()`` in the WordPress core.
74
+ *
75
+ * This function Filters registration errors inside `/wp-login.php` via ``register_new_user()``.
76
+ *
77
+ * This can ONLY be fired through `/wp-login.php` on the front-side.
78
+ *
79
+ * @package s2Member\Registrations
80
+ * @since 140518
81
+ *
82
+ * @attaches-to ``add_filter('registration_errors');``
83
+ *
84
+ * @param WP_Error $errors Expects a `WP_Error` object passed in by the Filter.
85
+ * @param string $user_login Expects the User's Username, passed in by the Filter.
86
+ * @param string $user_email Expects the User's Email Address, passed in by the Filter.
87
+ *
88
+ * @return WP_Error A `WP_Error` object instance.
89
+ */
90
+ public static function custom_registration_field_errors($errors = NULL, $user_login = '', $user_email = '')
91
+ {
92
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
93
+ do_action('ws_plugin__s2member_before_custom_registration_field_errors', get_defined_vars());
94
+ unset($__refs, $__v);
95
+
96
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
97
+
98
+ if(!is_admin() && preg_match('/\/wp-login\.php/'.$ci, $_SERVER['REQUEST_URI']))
99
+ if(is_wp_error($errors) && !empty($_POST) && is_array($_POST))
100
+ {
101
+ foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $_key => $_value)
102
+ if(strpos($_key, 'ws_plugin__s2member_custom_reg_field_') === 0)
103
+ $input[str_replace('ws_plugin__s2member_custom_reg_field_', '', $_key)] = $_value;
104
 
105
+ $fields_to_validate = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level('auto-detection', 'registration', TRUE);
106
+ $validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(!empty($input) ? $input : array(), $fields_to_validate);
107
 
108
+ if($validation_errors) foreach($validation_errors as $_field_var => $_error)
109
+ $errors->add('custom_reg_field_'.$_field_var, $_error);
110
+ unset($_field_var, $_error);
 
 
111
  }
112
+ return apply_filters('ws_plugin__s2member_custom_registration_field_errors', $errors, get_defined_vars());
113
+ }
114
+
115
+ /**
116
+ * Intersects with ``bp_core_screen_signup()`` in the BuddyPress core.
117
+ *
118
+ * This can ONLY be fired through `/register` via BuddyPress.
119
+ *
120
+ * @package s2Member\Registrations
121
+ * @since 140518
122
+ *
123
+ * @attaches-to ``add_action('bp_signup_validate');``
124
+ */
125
+ public static function custom_registration_field_errors_4bp()
126
+ {
127
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
128
+ do_action('ws_plugin__s2member_before_custom_registration_field_errors_4bp', get_defined_vars());
129
+ unset($__refs, $__v);
130
+
131
+ if(!is_admin() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())
132
+ if(in_array('registration', $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields_4bp']))
133
+ if(apply_filters('ws_plugin__s2member_custom_registration_fields_4bp_display', TRUE, get_defined_vars()))
134
+ if(!empty($GLOBALS['bp']->signup) && is_object($GLOBALS['bp']->signup) && !empty($_POST) && is_array($_POST))
135
+ {
136
+ foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $_key => $_value)
137
+ if(strpos($_key, 'ws_plugin__s2member_custom_reg_field_') === 0)
138
+ $input[str_replace('ws_plugin__s2member_custom_reg_field_', '', $_key)] = $_value;
139
+
140
+ $fields_to_validate = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level('auto-detection', 'registration', TRUE);
141
+ $validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(!empty($input) ? $input : array(), $fields_to_validate);
142
+
143
+ if($validation_errors) foreach($validation_errors as $_field_var => $_error)
144
+ $GLOBALS['bp']->signup->errors['custom_reg_field_'.$_field_var] = $_error;
145
+ unset($_field_var, $_error);
146
+ }
147
+ }
148
 
149
+ /**
150
+ * Filters Multisite User validation.
151
+ *
152
+ * This can ONLY be fired through `/wp-signup.php` on the front-side.
153
+ * Or through `/register` via BuddyPress.
154
+ *
155
+ * @package s2Member\Registrations
156
+ * @since 3.5
157
+ *
158
+ * @attaches-to ``add_filter('wpmu_validate_user_signup');``
159
+ *
160
+ * @param array $result Expects a ``$result`` array to be passed through by the Filter.
161
+ *
162
+ * @return array The Filtered ``$result`` array. Possibly containing errors introduced by s2Member.
163
+ */
164
+ public static function ms_validate_user_signup($result = array())
165
+ {
166
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
167
+ do_action('ws_plugin__s2member_before_ms_validate_user_signup', get_defined_vars());
168
+ unset($__refs, $__v);
169
+
170
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
171
+
172
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
173
+ if(!is_admin() && isset ($result['user_name'], $result['user_email'], $result['errors']) && ((preg_match('/\/wp-signup\.php/'.$ci, $_SERVER['REQUEST_URI']) && !empty($_POST['stage']) && preg_match('/^validate-(user|blog)-signup$/', (string)$_POST['stage'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())))
174
  {
175
+ $errors =& $result['errors'];
176
+ /** @var $errors WP_Error Reference for IDEs. Needed in the routines below. */
177
+
178
+ if(in_array($errors->get_error_code(), array('user_name', 'user_email', 'user_email_used')))
179
+ if(c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($result['user_name'], $result['user_email']))
180
+ {
181
+ unset($errors->errors['user_name'], $errors->errors['user_email'], $errors->errors['user_email_used']);
182
+ unset($errors->error_data['user_name'], $errors->error_data['user_email'], $errors->error_data['user_email_used']);
183
+ }
184
  foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
185
+ do_action('ws_plugin__s2member_during_ms_validate_user_signup', get_defined_vars());
186
  unset($__refs, $__v);
187
+ }
188
+ return apply_filters('ws_plugin__s2member_ms_validate_user_signup', $result, get_defined_vars());
189
+ }
190
 
191
+ /**
192
+ * Adds hidden fields for ``$_POST`` vars on signup.
193
+ *
194
+ * This can ONLY be fired through `/wp-signup.php` on the front-side.
195
+ * Or through `/register` via BuddyPress.
196
+ *
197
+ * @package s2Member\Registrations
198
+ * @since 3.5
199
+ *
200
+ * @attaches-to ``add_filter('signup_hidden_fields');``
201
+ */
202
+ public static function ms_process_signup_hidden_fields()
203
+ {
204
+ do_action('ws_plugin__s2member_before_ms_process_signup_hidden_fields', get_defined_vars());
205
+
206
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
207
+
208
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
209
+ if(!is_admin() && !empty($_POST) && is_array($_POST) && ((preg_match('/\/wp-signup\.php/'.$ci, $_SERVER['REQUEST_URI']) && !empty($_POST['stage']) && preg_match('/^validate-(user|blog)-signup$/', (string)$_POST['stage'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())))
210
+ {
211
+ foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $key => $value)
212
+ if(preg_match('/^ws_plugin__s2member_(custom_reg_field|user_new)_/', $key))
213
+ if($key = preg_replace('/_user_new_/', '_custom_reg_field_', $key))
214
+ echo '<input type="hidden" name="'.esc_attr($key).'" value="'.esc_attr(maybe_serialize($value)).'" />'."\n";
215
 
216
+ do_action('ws_plugin__s2member_during_ms_process_signup_hidden_fields', get_defined_vars());
217
+ }
218
+ do_action('ws_plugin__s2member_after_ms_process_signup_hidden_fields', get_defined_vars());
219
+ }
220
 
221
+ /**
222
+ * Adds Customs Fields to ``$meta`` on signup.
223
+ *
224
+ * This can ONLY be fired through `/wp-signup.php` on the front-side.
225
+ * Or possibly through `/user-new.php` in the admin.
226
+ * Or through `/register` via BuddyPress.
227
+ *
228
+ * @package s2Member\Registrations
229
+ * @since 3.5
230
+ *
231
+ * @attaches-to ``add_filter('add_signup_meta');``
232
+ * @attaches-to ``add_filter('bp_signup_usermeta');``
233
+ *
234
+ * @param array $meta Expects an array of meta-data to be passed in by the Filter.
235
+ *
236
+ * @return array Full ``$meta`` array with s2Member Custom Fields included.
237
+ */
238
+ public static function ms_process_signup_meta($meta = array())
239
+ {
240
+ global /* Multisite Networking. */
241
+ $current_site, $current_blog;
242
+ global $pagenow; // Need this to detect the current admin page.
243
+
244
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
245
+ do_action('ws_plugin__s2member_before_ms_process_signup_meta', get_defined_vars());
246
+ unset($__refs, $__v);
247
+
248
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
249
+
250
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
251
+ if(!empty($_POST) && is_array($_POST) && ((is_blog_admin() && $pagenow === 'user-new.php') || (!is_admin() && ((preg_match('/\/wp-signup\.php/'.$ci, $_SERVER['REQUEST_URI']) && !empty($_POST['stage']) && preg_match('/^validate-(user|blog)-signup$/', (string)$_POST['stage'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())))))
252
+ {
253
+ c_ws_plugin__s2member_email_configs::email_config(); // Configures `From:` header used in notifications.
254
+
255
+ $meta['add_to_blog'] = (empty($meta['add_to_blog'])) ? $current_blog->blog_id : $meta['add_to_blog'];
256
+ $meta['new_role'] = (empty($meta['new_role'])) ? get_option('default_role') : $meta['new_role'];
257
+
258
+ foreach(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) as $key => $value)
259
+ if(preg_match('/^ws_plugin__s2member_(custom_reg_field|user_new)_/', $key))
260
+ if($key = preg_replace('/_user_new_/', '_custom_reg_field_', $key))
261
+ $meta['s2member_ms_signup_meta'][$key] = maybe_unserialize($value);
262
  }
263
+ return apply_filters('ws_plugin__s2member_ms_process_signup_meta', $meta, get_defined_vars());
264
+ }
265
 
266
+ /**
267
+ * Intersects with ``wpmu_activate_signup()`` through s2Member's Multisite Networking patch.
268
+ *
269
+ * This function should return the same array that `wpmu_activate_signup()` returns; with the assumption that ``$user_already_exists``.
270
+ * Which is exactly where this function intersects inside the `/wp-includes/ms-functions.php`.
271
+ *
272
+ * This can ONLY be fired through `/wp-activate.php` on the front-side.
273
+ * Or through `/activate` via BuddyPress.
274
+ *
275
+ * @package s2Member\Registrations
276
+ * @since 3.5
277
+ *
278
+ * @attaches-to ``add_filter('_wpmu_activate_existing_error_');``
279
+ *
280
+ * @param WP_Error $_error Expects a `WP_Error` object to be passed through by the Filter.
281
+ * @param array $vars Expects the defined variables from the scope of the calling Filter.
282
+ *
283
+ * @return WP_Error|array If unable to add an existing User, the original ``$_error`` obj is returned.
284
+ * Otherwise we return an array of User details for continued processing by the caller.
285
+ */
286
+ public static function ms_activate_existing_user($_error = NULL, $vars = array())
287
+ {
288
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
289
+ do_action('ws_plugin__s2member_before_ms_activate_existing_user', get_defined_vars());
290
+ unset($__refs, $__v);
291
+
292
+ extract($vars); // Extract all variables from ``wpmu_activate_signup()`` function.
293
+
294
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
295
+
296
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
297
+ if(!is_admin() && ((preg_match('/\/wp-activate\.php/'.$ci, $_SERVER['REQUEST_URI'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page())))
298
+ {
299
+ if(!empty($user_id) && !empty($user_login) && !empty($user_email) && !empty($password) && !empty($meta) && !empty($meta['add_to_blog']) && !empty($meta['new_role']))
300
+ if(!empty($user_already_exists) && c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email, $meta['add_to_blog']))
301
+ {
302
+ add_user_to_blog($meta['add_to_blog'], $user_id, $meta['new_role']); // Add this User to the specified Blog.
303
+ wp_update_user(array('ID' => $user_id, 'user_pass' => $password)); // Update Password so it's the same as in the following msg.
304
+ wpmu_welcome_user_notification($user_id, $password, $meta); // Send welcome letter via email just like ``wpmu_activate_signup()`` does.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
+ do_action('wpmu_activate_user', $user_id, $password, $meta); // Process Hook that would have been fired inside ``wpmu_activate_signup()``.
307
 
308
+ return apply_filters('ws_plugin__s2member_ms_activate_existing_user', array('user_id' => $user_id, 'password' => $password, 'meta' => $meta), get_defined_vars());
309
+ }
310
+ }
311
+ return apply_filters('ws_plugin__s2member_ms_activate_existing_user', $_error, get_defined_vars()); // Else, return the standardized error.
312
+ }
 
 
 
 
313
 
314
+ /**
315
+ * Configures new Users on a Multisite Network installation.
316
+ *
317
+ * This can ONLY be fired in the admin via `/user-new.php`.
318
+ * Or also during an actual activation; through `/wp-activate.php`.
319
+ * Or also during an actual activation; through `/activate` via BuddyPress.
320
+ *
321
+ * @package s2Member\Registrations
322
+ * @since 3.5
323
+ *
324
+ * @attaches-to ``add_action('wpmu_activate_user');``
325
+ *
326
+ * @param int|string $user_id A numeric WordPress User ID.
327
+ * @param string $password Plain text Password should be passed through by the Action Hook.
328
+ * @param array $meta Expects an array of ``$meta`` details, passed through by the Action Hook.
329
+ */
330
+ public static function configure_user_on_ms_user_activation($user_id = '', $password = '', $meta = array())
331
+ {
332
+ global $pagenow; // Detect the current admin page.
333
+
334
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
335
+ do_action('ws_plugin__s2member_before_configure_user_on_ms_user_activation', get_defined_vars());
336
+ unset($__refs, $__v);
337
+
338
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
339
+
340
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
341
+ if((is_blog_admin() && $pagenow === 'user-new.php' && isset ($_POST['noconfirmation'])) || (!is_admin() && ((preg_match('/\/wp-activate\.php/'.$ci, $_SERVER['REQUEST_URI'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page()))))
342
+ {
343
+ c_ws_plugin__s2member_registrations::configure_user_registration($user_id, $password, ((isset ($meta['s2member_ms_signup_meta']) && is_array($meta['s2member_ms_signup_meta'])) ? $meta['s2member_ms_signup_meta'] : array()));
344
+ delete_user_meta($user_id, 's2member_ms_signup_meta');
345
+ }
346
+ do_action('ws_plugin__s2member_after_configure_user_on_ms_user_activation', get_defined_vars());
347
+ }
348
 
349
+ /**
350
+ * Configures new Users on a Multisite Network installation.
351
+ *
352
+ * This does NOT fire for a Super Admin managing Network Blogs.
353
+ * Actually it does; BUT it's blocked by the routine below.
354
+ * A Super Admin should NOT trigger this event.
355
+ *
356
+ * This function should ONLY be fired through `/wp-activate.php`.
357
+ * Or also through `/activate` via BuddyPress.
358
+ *
359
+ * @package s2Member\Registrations
360
+ * @since 3.5
361
+ *
362
+ * @attaches-to ``add_action('wpmu_activate_blog');``
363
+ *
364
+ * @param int|string $blog_id A numeric WordPress Blog ID.
365
+ * @param int|string $user_id A numeric WordPress User ID.
366
+ * @param string $password Plain text Password should be passed through by the Action Hook.
367
+ * @param string $title The title that a User chose during signup; for their new Blog on the Network.
368
+ * @param array $meta Expects an array of ``$meta`` details, passed through by the Action Hook.
369
+ */
370
+ public static function configure_user_on_ms_blog_activation($blog_id = '', $user_id = '', $password = '', $title = '', $meta = array())
371
+ {
372
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
373
+ do_action('ws_plugin__s2member_before_configure_user_on_ms_blog_activation', get_defined_vars());
374
+ unset($__refs, $__v);
375
+
376
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
377
+
378
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
379
+ if(!is_admin() && ((preg_match('/\/wp-activate\.php/'.$ci, $_SERVER['REQUEST_URI'])) || (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page())))
380
+ {
381
+ c_ws_plugin__s2member_registrations::configure_user_registration($user_id, $password, ((isset ($meta['s2member_ms_signup_meta']) && is_array($meta['s2member_ms_signup_meta'])) ? $meta['s2member_ms_signup_meta'] : array()));
382
+ delete_user_meta($user_id, 's2member_ms_signup_meta');
383
+ }
384
+ do_action('ws_plugin__s2member_after_configure_user_on_ms_blog_activation', get_defined_vars());
385
+ }
386
+
387
+ /**
388
+ * Assigns the proper role/ccaps on BP user activation.
389
+ *
390
+ * @attaches-to `bp_core_activated_user`
391
+ *
392
+ * @param string|integer $user_id Passed in by hook.
393
+ */
394
+ public static function bp_user_activation($user_id)
395
+ {
396
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
397
+ do_action('ws_plugin__s2member_before_bp_user_activation', get_defined_vars());
398
+ unset($__refs, $__v);
399
+
400
+ if(is_multisite() || !$user_id) return; // Nothing to do.
401
+
402
+ $role = get_user_option('s2member_bp_activation_role', $user_id);
403
+ $ccaps = get_user_option('s2member_bp_activation_ccaps', $user_id);
404
+
405
+ delete_user_option($user_id, 's2member_bp_activation_role');
406
+ delete_user_option($user_id, 's2member_bp_activation_ccaps');
407
+
408
+ if($role && ($user = new WP_User($user_id)) && $user->ID)
409
+ {
410
+ $user->set_role($role);
411
+ if($ccaps && is_array($ccaps)) foreach($ccaps as $_ccap)
412
+ $user->add_cap('access_s2member_ccap_'.$_ccap);
413
+ unset($_ccap); // Housekeeping.
414
+ }
415
+ }
416
+
417
+ /**
418
+ * Intersects with ``register_new_user()`` through s2Member's Multisite Networking patch.
419
+ *
420
+ * This function Filters registration errors inside `/wp-login.php` via ``register_new_user()``.
421
+ * When an existing Multisite User is registering, this takes over registration processing.
422
+ *
423
+ * This can ONLY be fired through `/wp-login.php` on the front-side.
424
+ *
425
+ * @package s2Member\Registrations
426
+ * @since 3.5
427
+ *
428
+ * @attaches-to ``add_filter('registration_errors');``
429
+ *
430
+ * @param WP_Error $errors Expects a `WP_Error` object passed in by the Filter.
431
+ * @param string $user_login Expects the User's Username, passed in by the Filter.
432
+ * @param string $user_email Expects the User's Email Address, passed in by the Filter.
433
+ *
434
+ * @return WP_Error A `WP_Error` object, or exits script execution after handling registration redirection.
435
+ */
436
+ public static function ms_register_existing_user($errors = NULL, $user_login = '', $user_email = '')
437
+ {
438
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
439
+ do_action('ws_plugin__s2member_before_ms_register_existing_user', get_defined_vars());
440
+ unset($__refs, $__v);
441
+
442
+ /** @var $ms_errors WP_Error Reference for IDEs. This is needed below. */
443
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
444
+
445
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
446
+ if(!is_admin() && preg_match('/\/wp-login\.php/'.$ci, $_SERVER['REQUEST_URI']))
447
+ if(is_wp_error($errors) && $errors->get_error_codes()) // Errors?
448
  {
449
+ if(($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email)))
450
+ {
451
+ foreach($errors->get_error_codes() as $error_code)
452
+ if(!in_array($error_code, array('username_exists', 'email_exists')))
453
+ $other_important_errors_exist[] = $error_code;
454
 
455
+ if(empty($other_important_errors_exist)) // Only if/when NO other important errors exist already.
456
+ {
457
+ $user_pass = wp_generate_password(); // A new Password for this User/Member will be generated now.
458
+ c_ws_plugin__s2member_registrations::ms_create_existing_user($user_login, $user_email, $user_pass, $user_id);
459
+ update_user_option($user_id, 'default_password_nag', TRUE, TRUE); // Setup Password-change nag screen.
460
+ wp_new_user_notification($user_id, $user_pass); // Welcome email, just like ``register_new_user()``.
461
 
462
+ $redirect_to = (!empty($_REQUEST['redirect_to'])) ? trim(stripslashes($_REQUEST['redirect_to'])) : FALSE;
463
+ $redirect_to = ($redirect_to) ? $redirect_to : add_query_arg('checkemail', urlencode('registered'), wp_login_url());
 
 
 
 
464
 
465
+ do_action('ws_plugin__s2member_during_ms_register_existing_user', get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
+ wp_safe_redirect($redirect_to).exit (); // Safe, like: ``register_new_user()``.
468
+ }
469
+ }
470
+ }
471
+ else if(($ms = wpmu_validate_user_signup($user_login, $user_email)) && isset ($ms['errors']) && is_wp_error($ms_errors = $ms['errors']) && $ms_errors->get_error_code())
472
+ $errors->add($ms_errors->get_error_code(), $ms_errors->get_error_message());
 
 
 
 
 
 
473
 
474
+ return apply_filters('ws_plugin__s2member_ms_register_existing_user', $errors, get_defined_vars());
475
+ }
476
 
477
+ /**
478
+ * For Multisite Networks, this function is used to add a User to an existing Blog; and to simulate ``wp_create_user()`` behavior.
479
+ *
480
+ * The ``$user_id`` value will be returned by this function, just like ``wp_create_user()`` does.
481
+ * This function will fire the Hook `user_register`.
482
+ *
483
+ * @package s2Member\Registrations
484
+ * @since 3.5
485
+ *
486
+ * @param string $user_login Expects the User's Username.
487
+ * @param string $user_email Expects the User's Email Address.
488
+ * @param string $user_pass Expects the User's plain text Password.
489
+ * @param int|string $user_id Optional. A numeric WordPress User ID.
490
+ * If unspecified, a lookup is performed with ``$user_login`` and ``$user_email``.
491
+ *
492
+ * @return int|false Returns numeric ``$user_id`` on success, else false on failure.
493
+ */
494
+ public static function ms_create_existing_user($user_login = '', $user_email = '', $user_pass = '', $user_id = '')
495
+ {
496
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
497
+ do_action('ws_plugin__s2member_before_ms_create_existing_user', get_defined_vars());
498
+ unset($__refs, $__v);
499
+
500
+ if(is_multisite()) // This event should ONLY be processed with Multisite Networking.
501
+ {
502
+ if(($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email))) && $user_pass)
503
+ {
504
+ $role = get_option('default_role'); // Use default Role.
505
+ add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $role)); // Add User.
506
+ wp_update_user(array('ID' => $user_id, 'user_pass' => $user_pass)); // Update to ``$user_pass``.
507
 
508
+ do_action('ws_plugin__s2member_during_ms_create_existing_user', get_defined_vars());
509
+ do_action('user_register', $user_id); // So s2Member knows a User is registering.
510
 
511
+ return apply_filters('ws_plugin__s2member_ms_create_existing_user', $user_id, get_defined_vars());
 
 
 
 
 
 
512
  }
513
+ }
514
+ return apply_filters('ws_plugin__s2member_ms_create_existing_user', FALSE, get_defined_vars());
515
+ }
516
 
517
+ /**
518
+ * Configures all new Users.
519
+ *
520
+ * The Hook `user_register` is also fired by calling:
521
+ * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
522
+ *
523
+ * This function also receives hand-offs from s2Member's handlers for these two Hooks:
524
+ * `wpmu_activate_user` and `wpmu_activate_blog`.
525
+ *
526
+ * @package s2Member\Registrations
527
+ * @since 3.5
528
+ *
529
+ * @attaches-to ``add_action('user_register');``
530
+ *
531
+ * @param int|string $user_id A numeric WordPress User ID.
532
+ * @param string $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
533
+ * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
534
+ *
535
+ * @TODO Impossible to delete cookies when fired inside: `/wp-activate.php`?
536
+ */
537
+ public static function configure_user_registration($user_id = '', $password = '', $meta = array())
538
+ {
539
+ global $wpdb; // Global database object reference.
540
+ global $pagenow; // We need this to detect the current administration page.
541
+ global $current_site, $current_blog; // Adds support for Multisite Networking.
542
+ static $email_config, $processed; // Static vars prevent duplicate processing.
543
+
544
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
545
+ do_action('ws_plugin__s2member_before_configure_user_registration', get_defined_vars());
546
+ unset($__refs, $__v);
547
+
548
+ // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
549
+ if(!isset ($email_config) && ($email_config = TRUE)) // Anytime this routine is fired; we configure email.
550
+ c_ws_plugin__s2member_email_configs::email_config(); // Configures `From:` email header.
551
+
552
+ $_p = (isset ($_POST)) ? $_POST : NULL; // Grab global ``$_POST`` array here, if it's possible to do so.
553
+ $rvs = (isset ($GLOBALS['ws_plugin__s2member_registration_vars'])) ? $GLOBALS['ws_plugin__s2member_registration_vars'] : NULL;
554
+
555
+ if(!$processed /* Process only once. Safeguard this routine against duplicate processing via plugins (or even WordPress itself). */)
556
+
557
+ if(is_array($_p) || is_array($meta) || is_array($rvs) /* We MUST have at least ONE of these three arrays. Any of these will do in most cases. */)
558
+
559
+ if(!(is_multisite() && is_blog_admin() && $pagenow === 'user-new.php' && isset ($_p['noconfirmation']) && is_super_admin() && !is_array($meta)))
560
+ if(!(preg_match('/\/wp-activate\.php/', $_SERVER['REQUEST_URI']) && !is_array($meta)) /* If activating; we absolutely MUST have a ``$meta`` array. */)
561
+ if(!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta)) /* If activating; MUST have ``$meta``. */)
562
+ if(!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user') && !is_array($rvs)))
563
+
564
+ if($user_id && is_object($user = new WP_User ($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = TRUE))
565
  {
566
+ settype($_p, 'array').settype($meta, 'array').settype($rvs, 'array'); // Force arrays here.
 
 
 
 
567
 
568
+ $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p));
569
+ $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta));
570
+ $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs /* Do NOT strip. */);
 
 
 
571
 
572
+ foreach($_p as $_key => $_value) // Scan ``$_p`` vars; adding `custom_reg_field` keys.
573
+ if(preg_match('/^ws_plugin__s2member_user_new_/', $_key)) // Look for keys.
574
+ if($_key = str_replace('_user_new_', '_custom_reg_field_', $_key))
575
+ $_p[$_key] = $_value; // Add each of these key conversions.
576
+ unset ($_key, $_value /* Just a little housekeeping here. */);
577
 
578
+ if(!is_admin() && (isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_custom']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_ccaps']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) || isset ($_p['ws_plugin__s2member_custom_reg_field_s2member_notes'])))
579
+ exit (_x('s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!', 's2member-front', 's2member'));
580
 
581
+ $_pmr = array_merge($_p, $meta, $rvs); // Merge all of these arrays together now, in this specific order.
582
+ unset($_p, $meta, $rvs); // These variables can all be unset now; we have them all in the ``$_pmr`` array.
 
 
 
 
583
 
584
+ $custom_reg_display_name = $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_display_name']; // Can be configured by the site owner.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
 
586
+ if(!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies))
587
+ { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
588
+ This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
589
+ If processed through `/wp-activate.php`, it could've originated inside the admin — via `/user-new.php`. */
590
+ /**
591
+ * @var $subscr_gateway string Reference for IDEs.
592
+ * @var $subscr_id string Reference for IDEs.
593
+ * @var $custom string Reference for IDEs.
594
+ * @var $item_number string Reference for IDEs.
595
+ */
596
+ $processed = 'yes'; // Mark this as yes.
597
+
598
+ $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
599
+ @list ($level, $ccaps, $eotper) = preg_split('/\:/', $item_number, 3);
600
+ $role = 's2member_level'.$level; // Membership Level.
601
+
602
+ $email = $user->user_email;
603
+ $login = $user->user_login;
604
+ $ip = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
605
+ $ip = (!$ip) ? $_SERVER['REMOTE_ADDR'] : $ip; // Else use environment variable.
606
+ $subscr_baid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
607
+ $subscr_cid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
608
+ $cv = preg_split('/\|/', $custom);
609
+
610
+ if(!($auto_eot_time = '') && $eotper) // If a specific EOT Period is included.
611
+ $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper);
612
+
613
+ $notes = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
614
+
615
+ $opt_in = (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in']) ? TRUE : FALSE;
616
+ $opt_in = (!$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in'])) ? TRUE : $opt_in;
617
+
618
+ if(!($fname = $user->first_name))
619
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name']))
620
+ $fname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
621
+
622
+ if(!$fname) // Also try BuddyPress.
623
+ if(!empty($_pmr['field_1'])) // BuddyPress?
624
+ $fname = trim(preg_replace('/ (.*)$/', '', (string)$_pmr['field_1']));
625
+
626
+ if(!($lname = $user->last_name))
627
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name']))
628
+ $lname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
629
+
630
+ if(!$lname) // Also try BuddyPress.
631
+ if(!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string)$_pmr['field_1']))
632
+ $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string)$_pmr['field_1']));
633
+
634
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login)
635
+ {
636
+ $fname = trim($login);
637
+ $lname = ''; // Username and empty Last Name.
638
+ }
639
+ $name = trim($fname.' '.$lname); // Both names.
640
 
641
+ if(!($pass = $password)) // Try s2Member's generator.
642
+ if(!empty($GLOBALS['ws_plugin__s2member_generate_password_return']))
643
+ $pass = (string)$GLOBALS['ws_plugin__s2member_generate_password_return'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
 
645
+ if(!$pass) // Also try BuddyPress Password.
646
+ if(!empty($_pmr['signup_password'])) // BuddyPress?
647
+ $pass = (string)$_pmr['signup_password'];
648
 
649
+ if($pass) // No Password nag. Update this globally.
650
+ {
651
+ (!headers_sent()) ? delete_user_setting('default_password_nag', $user_id) : NULL;
652
+ update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
653
+ }
654
+ update_user_option($user_id, 's2member_registration_ip', $ip);
655
+ update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
656
+ update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
657
+ update_user_option($user_id, 's2member_subscr_id', $subscr_id);
658
+ update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
659
+ update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
660
+ update_user_option($user_id, 's2member_custom', $custom);
661
+ update_user_option($user_id, 's2member_notes', $notes);
662
+
663
+ if(!$user->first_name && $fname)
664
+ update_user_meta($user_id, 'first_name', $fname);
665
+
666
+ if(!$user->last_name && $lname)
667
+ update_user_meta($user_id, 'last_name', $lname);
668
+
669
+ if(!$user->display_name || $user->display_name === $user->user_login)
670
+ {
671
+ if($custom_reg_display_name === 'full' && $name)
672
+ wp_update_user(array('ID' => $user_id, 'display_name' => $name));
673
+ else if($custom_reg_display_name === 'first' && $fname)
674
+ wp_update_user(array('ID' => $user_id, 'display_name' => $fname));
675
+ else if($custom_reg_display_name === 'last' && $lname)
676
+ wp_update_user(array('ID' => $user_id, 'display_name' => $lname));
677
+ else if($custom_reg_display_name === 'login' && $login)
678
+ wp_update_user(array('ID' => $user_id, 'display_name' => $login));
679
+ }
680
+ if(is_multisite()) // Should we handle Main Site permissions and Originating Blog ID#?
681
+ {
682
+ if(!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds'))
683
+ remove_user_from_blog($user_id, $current_site->blog_id); // No Main Site Role.
684
 
685
+ if(!get_user_meta($user_id, 's2member_originating_blog', TRUE)) // Recorded yet?
686
+ update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
687
+ }
688
+ if($current_role !== $role) // Only if NOT the current Role.
689
+ $user->set_role($role); // s2Member.
690
+
691
+ if($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps)))
692
+ foreach($user->allcaps as $cap => $cap_enabled)
693
+ if(preg_match('/^access_s2member_ccap_/', $cap))
694
+ $user->remove_cap($ccap = $cap);
695
+
696
+ if($ccaps && preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps)))
697
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap)
698
+ if(strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap)))))
699
+ $user->add_cap('access_s2member_ccap_'.$ccap);
700
+
701
+ if(!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'])
702
+ foreach(json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field)
703
+ {
704
+ $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
705
+ $field_id_class = preg_replace('/_/', '-', $field_var);
706
+
707
+ if(isset ($_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var]))
708
+ $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var];
709
+ }
710
+ unset($field, $field_var, $field_id_class); // Housekeeping.
711
+
712
+ if(!empty($fields)) // Only if NOT empty.
713
+ update_user_option($user_id, 's2member_custom_fields', $fields);
714
+
715
+ if($level > 0) // We ONLY process this if they are higher than Level #0.
716
+ {
717
+ $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
718
+ $pr_times['level'] = (empty($pr_times['level'])) ? time() : $pr_times['level'];
719
+ $pr_times['level'.$level] = (empty($pr_times['level'.$level])) ? time() : $pr_times['level'.$level];
720
+ update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now.
721
+ }
722
+ if(!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())
723
+ {
724
+ update_user_option($user_id, 's2member_bp_activation_role', $role);
725
+ update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
726
+ }
727
+ if(($transient = 's2m_'.md5('s2member_transient_ipn_signup_vars_'.$subscr_id)) && is_array($ipn_signup_vars = get_transient($transient)))
728
+ {
729
+ update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars); // For future reference.
730
+ delete_transient($transient); // This can be deleted now.
731
+ }
732
+ if(($transient = 's2m_'.md5('s2member_transient_ipn_subscr_payment_'.$subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment['subscr_gateway']))
733
+ {
734
+ $proxy = array('s2member_paypal_proxy' => stripslashes((string)$subscr_payment['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
735
+ c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_payment), $proxy), array('timeout' => 20));
736
+ delete_transient($transient); // This can be deleted now.
737
+ }
738
+ if(($transient = 's2m_'.md5('s2member_transient_ipn_subscr_eot_'.$subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot['subscr_gateway']))
739
+ {
740
+ $proxy = array('s2member_paypal_proxy' => stripslashes((string)$subscr_eot['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
741
+ c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_eot), $proxy), array('timeout' => 20));
742
+ delete_transient($transient); // This can be deleted now.
743
+ }
744
+ if(!headers_sent()) // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
745
+ @setcookie('s2member_tracking', ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id)), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).
746
+ @setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).
747
+ ($_COOKIE['s2member_tracking'] = $s2member_tracking);
748
+
749
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
750
+ do_action('ws_plugin__s2member_during_configure_user_registration_front_side_paid', get_defined_vars());
751
+ do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
752
+ unset($__refs, $__v);
753
+ }
754
+ else if(!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')))
755
+ { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
756
+ This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
757
+ If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
758
 
759
+ $processed = 'yes'; // Mark this as yes.
760
+
761
+ $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
762
+ $role = ''; // Initialize ``$role`` to an empty string here, before processing.
763
+ $role = (!$role && ($level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0) ? 's2member_level'.$level : $role;
764
+ $role = (!$role && ($level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0') ? 'subscriber' : $role;
765
+ $role = (!$role && $current_role) ? $current_role : $role; // Use existing Role?
766
+ $role = (!$role) ? get_option('default_role') : $role; // Otherwise default.
767
+
768
+ $level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
769
+ $level = (!$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role)) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
770
+ $level = (!$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role)) ? preg_replace('/^s2member_level/', '', $role) : $level;
771
+ $level = (!$level && preg_match('/^subscriber$/i', $role)) ? '0' : $level;
772
+ $level = (!$level) ? '0' : $level;
773
+
774
+ $ccaps = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
775
+
776
+ $email = $user->user_email;
777
+ $login = $user->user_login;
778
+ $ip = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
779
+ $ip = (!$ip) ? $_SERVER['REMOTE_ADDR'] : $ip; // Else use environment variable.
780
+ $custom = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
781
+ $subscr_id = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
782
+ $subscr_baid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
783
+ $subscr_cid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
784
+ $subscr_gateway = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
785
+ $cv = preg_split('/\|/', (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
786
+
787
+ $auto_eot_time = ($eot = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
788
+ $notes = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
789
+
790
+ $opt_in = (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in']) ? TRUE : FALSE;
791
+ $opt_in = (!$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in'])) ? TRUE : $opt_in;
792
+
793
+ if(!($fname = $user->first_name))
794
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name']))
795
+ $fname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
796
+
797
+ if(!$fname) // Also try BuddyPress.
798
+ if(!empty($_pmr['field_1'])) // BuddyPress?
799
+ $fname = trim(preg_replace('/ (.*)$/', '', (string)$_pmr['field_1']));
800
+
801
+ if(!($lname = $user->last_name))
802
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name']))
803
+ $lname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
804
+
805
+ if(!$lname) // Also try BuddyPress.
806
+ if(!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string)$_pmr['field_1']))
807
+ $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string)$_pmr['field_1']));
808
+
809
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login)
810
+ {
811
+ $fname = trim($login);
812
+ $lname = ''; // Username and empty Last Name.
813
+ }
814
+ $name = trim($fname.' '.$lname); // Both names.
815
 
816
+ if(!($pass = $password)) // Try s2Member's generator.
817
+ if(!empty($GLOBALS['ws_plugin__s2member_generate_password_return']))
818
+ $pass = (string)$GLOBALS['ws_plugin__s2member_generate_password_return'];
819
 
820
+ if(!$pass) // Also try BuddyPress Password.
821
+ if(!empty($_pmr['signup_password'])) // BuddyPress?
822
+ $pass = (string)$_pmr['signup_password'];
 
823
 
824
+ if($pass) // No Password nag. Update this globally.
825
+ {
826
+ (!headers_sent()) ? delete_user_setting('default_password_nag', $user_id) : NULL;
827
+ update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
828
+ }
829
+ update_user_option($user_id, 's2member_registration_ip', $ip);
830
+ update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
831
+ update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
832
+ update_user_option($user_id, 's2member_subscr_id', $subscr_id);
833
+ update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
834
+ update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
835
+ update_user_option($user_id, 's2member_custom', $custom);
836
+ update_user_option($user_id, 's2member_notes', $notes);
837
+
838
+ if(!$user->first_name && $fname)
839
+ update_user_meta($user_id, 'first_name', $fname);
840
+
841
+ if(!$user->last_name && $lname)
842
+ update_user_meta($user_id, 'last_name', $lname);
843
+
844
+ if(!$user->display_name || $user->display_name === $user->user_login)
845
+ {
846
+ if($custom_reg_display_name === 'full' && $name)
847
+ wp_update_user(array('ID' => $user_id, 'display_name' => $name));
848
+ else if($custom_reg_display_name === 'first' && $fname)
849
+ wp_update_user(array('ID' => $user_id, 'display_name' => $fname));
850
+ else if($custom_reg_display_name === 'last' && $lname)
851
+ wp_update_user(array('ID' => $user_id, 'display_name' => $lname));
852
+ else if($custom_reg_display_name === 'login' && $login)
853
+ wp_update_user(array('ID' => $user_id, 'display_name' => $login));
854
+ }
855
+ if(is_multisite( /* Should we handle Main Site permissions and Originating Blog ID#? */))
856
+ {
857
+ if(!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds'))
858
+ remove_user_from_blog($user_id, $current_site->blog_id); // No Main Site Role.
859
 
860
+ if(!get_user_meta($user_id, 's2member_originating_blog', TRUE)) // Recorded yet?
861
+ update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
862
+ }
863
+ if($current_role !== $role) // Only if NOT the current Role.
864
+ $user->set_role($role); // s2Member.
865
+
866
+ if($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps)))
867
+ foreach($user->allcaps as $cap => $cap_enabled)
868
+ if(preg_match('/^access_s2member_ccap_/', $cap))
869
+ $user->remove_cap($ccap = $cap);
870
+
871
+ if($ccaps && preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps)))
872
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap)
873
+ if(strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap)))))
874
+ $user->add_cap('access_s2member_ccap_'.$ccap);
875
+
876
+ if(!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'])
877
+ foreach(json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field)
878
+ {
879
+ $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
880
+ $field_id_class = preg_replace('/_/', '-', $field_var);
881
+
882
+ if(isset ($_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var]))
883
+ $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var];
884
+ }
885
+ unset($field, $field_var, $field_id_class); // Housekeeping.
886
+
887
+ if(!empty($fields)) // Only if NOT empty.
888
+ update_user_option($user_id, 's2member_custom_fields', $fields);
889
+
890
+ if($level > 0) // We ONLY process this if they are higher than Level#0.
891
+ {
892
+ $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
893
+ $pr_times['level'] = (empty($pr_times['level'])) ? time() : $pr_times['level'];
894
+ $pr_times['level'.$level] = (empty($pr_times['level'.$level])) ? time() : $pr_times['level'.$level];
895
+ update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now.
896
+ }
897
+ if(!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page())
898
+ {
899
+ update_user_option($user_id, 's2member_bp_activation_role', $role);
900
+ update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
901
+ }
902
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
903
+ do_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', get_defined_vars());
904
+ do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
905
+ unset($__refs, $__v);
906
+ }
907
+ else if((is_blog_admin() && $pagenow === 'user-new.php') || (c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')))
908
+ { // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
909
+
910
+ $processed = 'yes'; // Mark this as yes, to indicate that a routine was processed.
911
+
912
+ $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
913
+ $role = ''; // Initialize $role to an empty string here, before processing.
914
+ $role = (!$role && ($level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0) ? 's2member_level'.$level : $role;
915
+ $role = (!$role && ($level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0') ? 'subscriber' : $role;
916
+ $role = (!$role && $current_role) ? $current_role : $role; // Use existing Role?
917
+ $role = (!$role) ? get_option('default_role') : $role; // Otherwise default.
918
+
919
+ $level = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
920
+ $level = (!$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role)) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
921
+ $level = (!$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role)) ? preg_replace('/^s2member_level/', '', $role) : $level;
922
+ $level = (!$level && preg_match('/^subscriber$/i', $role)) ? '0' : $level;
923
+ $level = (!$level) ? '0' : $level;
924
+
925
+ $ccaps = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
926
+
927
+ $email = $user->user_email;
928
+ $login = $user->user_login;
929
+ $ip = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
930
+ $custom = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
931
+ $subscr_id = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
932
+ $subscr_baid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
933
+ $subscr_cid = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
934
+ $subscr_gateway = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
935
+ $cv = preg_split('/\|/', (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
936
+
937
+ $auto_eot_time = ($eot = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
938
+ $notes = (string)@$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
939
+
940
+ $opt_in = (!empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in'])) ? TRUE : FALSE;
941
+
942
+ if(!($fname = $user->first_name)) // `Users -› Add New`.
943
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name']))
944
+ $fname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
945
+
946
+ if(!($lname = $user->last_name)) // `Users -› Add New`.
947
+ if(!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name']))
948
+ $lname = (string)$_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
949
+
950
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login)
951
+ {
952
+ $fname = trim($login);
953
+ $lname = ''; // Username and empty Last Name.
954
+ }
955
+ $name = trim($fname.' '.$lname); // Both names.
956
 
957
+ if(!($pass = $password)) // Try s2Member's generator.
958
+ if(!empty($GLOBALS['ws_plugin__s2member_generate_password_return']))
959
+ $pass = (string)$GLOBALS['ws_plugin__s2member_generate_password_return'];
 
 
960
 
961
+ if(!$pass) // Also try the `Users -› Add New` form.
962
+ if(!empty($_pmr['pass1'])) // Field in `/user-new.php`.
963
+ $pass = (string)$_pmr['pass1'];
964
 
965
+ if($pass) // No Password nag. Update this globally.
966
+ {
967
+ (!headers_sent()) ? delete_user_setting('default_password_nag', $user_id) : NULL;
968
+ update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
969
+ }
970
+ update_user_option($user_id, 's2member_registration_ip', $ip);
971
+ update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
972
+ update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
973
+ update_user_option($user_id, 's2member_subscr_id', $subscr_id);
974
+ update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
975
+ update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
976
+ update_user_option($user_id, 's2member_custom', $custom);
977
+ update_user_option($user_id, 's2member_notes', $notes);
978
+
979
+ if(!$user->first_name && $fname)
980
+ update_user_meta($user_id, 'first_name', $fname);
981
+
982
+ if(!$user->last_name && $lname)
983
+ update_user_meta($user_id, 'last_name', $lname);
984
+
985
+ if(!$user->display_name || $user->display_name === $user->user_login)
986
+ {
987
+ if($custom_reg_display_name === 'full' && $name)
988
+ wp_update_user(array('ID' => $user_id, 'display_name' => $name));
989
+ else if($custom_reg_display_name === 'first' && $fname)
990
+ wp_update_user(array('ID' => $user_id, 'display_name' => $fname));
991
+ else if($custom_reg_display_name === 'last' && $lname)
992
+ wp_update_user(array('ID' => $user_id, 'display_name' => $lname));
993
+ else if($custom_reg_display_name === 'login' && $login)
994
+ wp_update_user(array('ID' => $user_id, 'display_name' => $login));
995
+ }
996
+ if(is_multisite()) // Should we handle Main Site permissions and Originating Blog ID#?
997
+ {
998
+ if(!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds'))
999
+ remove_user_from_blog($user_id, $current_site->blog_id); // No Main Site Role.
1000
 
1001
+ if(!get_user_meta($user_id, 's2member_originating_blog', TRUE)) // Recorded yet?
1002
+ update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
1003
+ }
1004
+ if($current_role !== $role) // Only if NOT the current Role.
1005
+ $user->set_role($role); // s2Member.
1006
+
1007
+ if($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps)))
1008
+ foreach($user->allcaps as $cap => $cap_enabled)
1009
+ if(preg_match('/^access_s2member_ccap_/', $cap))
1010
+ $user->remove_cap($ccap = $cap);
1011
+
1012
+ if($ccaps && preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps)))
1013
+ foreach(preg_split('/['."\r\n\t".'\s;,]+/', preg_replace('/^-all['."\r\n\t".'\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap)
1014
+ if(strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap)))))
1015
+ $user->add_cap('access_s2member_ccap_'.$ccap);
1016
+
1017
+ if(!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'])
1018
+ foreach(json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field)
1019
+ {
1020
+ $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
1021
+ $field_id_class = preg_replace('/_/', '-', $field_var);
1022
+
1023
+ if(isset ($_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var]))
1024
+ $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_'.$field_var];
1025
+ }
1026
+ unset($field, $field_var, $field_id_class); // Housekeeping.
1027
+
1028
+ if(!empty($fields)) // Only if NOT empty.
1029
+ update_user_option($user_id, 's2member_custom_fields', $fields);
1030
+
1031
+ if($level > 0) // We ONLY process this if they are higher than Level#0.
1032
+ {
1033
+ $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
1034
+ $pr_times['level'] = (empty($pr_times['level'])) ? time() : $pr_times['level'];
1035
+ $pr_times['level'.$level] = (empty($pr_times['level'.$level])) ? time() : $pr_times['level'.$level];
1036
+ update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now.
1037
+ }
1038
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
1039
+ do_action('ws_plugin__s2member_during_configure_user_registration_admin_side', get_defined_vars());
1040
+ unset($__refs, $__v);
1041
+ }
1042
+ if($processed === 'yes') // If registration was processed by one of the routines above.
1043
+ {
1044
+ /**
1045
+ * If processed, all of these will have been defined by now.
1046
+ *
1047
+ * @var $role string Reference for IDEs.
1048
+ * @var $level string Reference for IDEs.
1049
+ * @var $ccaps string Reference for IDEs.
1050
+ * @var $auto_eot_time string|integer Reference for IDEs.
1051
+ * @var $fname string Reference for IDEs.
1052
+ * @var $lname string Reference for IDEs.
1053
+ * @var $name string Reference for IDEs.
1054
+ * @var $email string Reference for IDEs.
1055
+ * @var $login string Reference for IDEs.
1056
+ * @var $pass string Reference for IDEs.
1057
+ * @var $ip string Reference for IDEs.
1058
+ * @var $opt_in boolean Reference for IDEs.
1059
+ * @var $fields array Reference for IDEs.
1060
+ */
1061
+ if($urls = $GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_urls'])
1062
+
1063
+ foreach(preg_split('/['."\r\n\t".']+/', $urls) as $url) // Notify each of the URLs.
1064
+
1065
+ if(($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)))
1066
+ if(($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)))
1067
+ if(($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)))
1068
+ if(($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)))
1069
+ if(($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)))
1070
+ if(($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)))
1071
+ if(($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)))
1072
+ if(($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)))
1073
+ if(($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)))
1074
+ if(($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)))
1075
+ if(($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)))
1076
+ if(($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)))
1077
+ if(($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)))
1078
+ {
1079
+ foreach($fields as $var => $val) // Custom Fields.
1080
+ if(!($url = preg_replace('/%%'.preg_quote($var, '/').'%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url)))
1081
+ break;
1082
+
1083
+ if(($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))))
1084
+ c_ws_plugin__s2member_utils_urls::remote($url);
1085
+ }
1086
+ unset($urls, $url, $var, $val); // Housekeeping.
1087
+
1088
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients'])
1089
+ {
1090
+ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
1091
+ c_ws_plugin__s2member_email_configs::email_config_release();
1092
+
1093
+ $msg = $sbj = '(s2Member / API Notification Email) - Registration';
1094
+ $msg .= "\n\n"; // Spacing in the message body.
1095
+
1096
+ $msg .= 'role: %%role%%'."\n";
1097
+ $msg .= 'level: %%level%%'."\n";
1098
+ $msg .= 'ccaps: %%ccaps%%'."\n";
1099
+ $msg .= 'auto_eot_time: %%auto_eot_time%%'."\n";
1100
+ $msg .= 'user_first_name: %%user_first_name%%'."\n";
1101
+ $msg .= 'user_last_name: %%user_last_name%%'."\n";
1102
+ $msg .= 'user_full_name: %%user_full_name%%'."\n";
1103
+ $msg .= 'user_email: %%user_email%%'."\n";
1104
+ $msg .= 'user_login: %%user_login%%'."\n";
1105
+ $msg .= 'user_pass: %%user_pass%%'."\n";
1106
+ $msg .= 'user_ip: %%user_ip%%'."\n";
1107
+ $msg .= 'user_id: %%user_id%%'."\n";
1108
+
1109
+ foreach($fields as $var => $val)
1110
+ $msg .= $var.': %%'.$var.'%%'."\n";
1111
+
1112
+ $msg .= 'cv0: %%cv0%%'."\n";
1113
+ $msg .= 'cv1: %%cv1%%'."\n";
1114
+ $msg .= 'cv2: %%cv2%%'."\n";
1115
+ $msg .= 'cv3: %%cv3%%'."\n";
1116
+ $msg .= 'cv4: %%cv4%%'."\n";
1117
+ $msg .= 'cv5: %%cv5%%'."\n";
1118
+ $msg .= 'cv6: %%cv6%%'."\n";
1119
+ $msg .= 'cv7: %%cv7%%'."\n";
1120
+ $msg .= 'cv8: %%cv8%%'."\n";
1121
+ $msg .= 'cv9: %%cv9%%';
1122
+
1123
+ if(($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)))
1124
+ if(($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)))
1125
+ if(($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)))
1126
+ if(($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)))
1127
+ if(($msg = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($auto_eot_time), $msg)))
1128
+ if(($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($fname), $msg)))
1129
+ if(($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($lname), $msg)))
1130
+ if(($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($name), $msg)))
1131
+ if(($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($email), $msg)))
1132
+ if(($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($login), $msg)))
1133
+ if(($msg = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($pass), $msg)))
1134
+ if(($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ip), $msg)))
1135
+ if(($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)))
1136
+ {
1137
+ foreach($fields as $var => $val) // Custom Fields.
1138
+ if(!($msg = preg_replace('/%%'.preg_quote($var, '/').'%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg)))
1139
+ break;
1140
+
1141
+ if($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) // Still have a ``$sbj`` and a ``$msg``?
1142
+
1143
+ foreach(c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) as $recipient)
1144
+ wp_mail($recipient, apply_filters('ws_plugin__s2member_registration_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_registration_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8');
1145
+ }
1146
+ if($email_configs_were_on) // Back on?
1147
+ c_ws_plugin__s2member_email_configs::email_config();
1148
+
1149
+ unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on); // Housekeeping.
1150
+ }
1151
 
1152
+ if(!empty($GLOBALS['ws_plugin__s2member_registration_return_url']) && ($url = $GLOBALS['ws_plugin__s2member_registration_return_url']))
1153
+
1154
+ if(($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)))
1155
+ if(($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)))
1156
+ if(($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)))
1157
+ if(($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)))
1158
+ if(($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)))
1159
+ if(($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)))
1160
+ if(($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)))
1161
+ if(($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)))
1162
+ if(($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)))
1163
+ if(($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)))
1164
+ if(($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)))
1165
+ if(($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)))
1166
+ if(($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)))
1167
+ {
1168
+ foreach($fields as $var => $val) // Custom Fields.
1169
+ if(!($url = preg_replace('/%%'.preg_quote($var, '/').'%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url)))
1170
+ break;
1171
+
1172
+ if(($url = trim($url))) // Preserve remaining Replacements; because the parent routine may perform replacements too.
1173
+ $GLOBALS['ws_plugin__s2member_registration_return_url'] = $url;
1174
+ }
1175
+ unset($url, $var, $val); // Housekeeping.
1176
+
1177
+ c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, TRUE, $user_id);
1178
+ /*
1179
+ Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
1180
+ @TODO It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
1181
+ */
1182
+ if(!headers_sent()) // Only if headers are NOT yet sent.
1183
+ {
1184
+ @setcookie('s2member_subscr_gateway', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).@setcookie('s2member_subscr_gateway', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1185
+ @setcookie('s2member_subscr_id', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).@setcookie('s2member_subscr_id', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1186
+ @setcookie('s2member_custom', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).@setcookie('s2member_custom', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1187
+ @setcookie('s2member_item_number', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).@setcookie('s2member_item_number', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
1188
+ }
1189
+ /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
1190
+ Logging now supports Multisite Networking as well. */
1191
 
1192
+ $reg_vars = get_defined_vars(); // All defined vars.
1193
+ // No need to include these in the logs. Unset before log entry.
1194
+ unset($reg_vars['wpdb'], $reg_vars['current_site'], $reg_vars['current_blog']);
1195
+ c_ws_plugin__s2member_utils_logs::log_entry('reg-handler', $reg_vars);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1196
 
1197
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
1198
+ do_action('ws_plugin__s2member_during_configure_user_registration', get_defined_vars());
1199
+ unset($__refs, $__v);
1200
+ }
1201
+ }
1202
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
1203
+ do_action('ws_plugin__s2member_after_configure_user_registration', get_defined_vars());
1204
+ unset($__refs, $__v);
1205
+ }
1206
+ }
1207
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/ruris-sp.inc.php CHANGED
@@ -1,77 +1,75 @@
1
  <?php
2
  /**
3
- * s2Member's URI protection routines *(for specific URIs)*.
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\URIs
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_ruris_sp"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * s2Member's URI protection routines *(for specific URIs)*.
24
- *
25
- * @package s2Member\URIs
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_ruris_sp
29
- {
30
- /**
31
- * Handles URI Level Access *(for specific URIs)*.
32
- *
33
- * @package s2Member\URIs
34
- * @since 3.5
35
- *
36
- * @param string $uri A URI, or a full URL is also fine.
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_ruri_level_access ($uri = FALSE, $check_user = TRUE)
41
- {
42
- do_action("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars ());
43
-
44
- $uri = ($uri && is_string ($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri ($uri))) ? $uri : false;
45
-
46
- $excluded = apply_filters("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars ());
47
 
48
- if (!$excluded && !empty($uri) && is_string ($uri) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
49
- {
50
- if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page (null, $uri)) // Do NOT touch WordPress Systematics.
51
- {
52
- $user = (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty($user->ID)) ? $user : false; // Current User's object.
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, "/") . "$/", $uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level0")))
55
- return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => 0), get_defined_vars ());
56
-
57
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $uri)) // Never restrict Systematics. However, there is 1 exception above.
58
- {
59
- for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) // URIs. Go through each Level.
60
- {
61
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) // URIs configured at this Level?
62
 
63
- 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)
64
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $uri) && (!$check_user || !$user || !$user->has_cap ("access_s2member_level" . $n)))
65
- return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => $n), get_defined_vars ());
66
- }
67
- }
68
 
69
- do_action("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars ());
70
- }
71
- }
 
 
72
 
73
- return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars ());
 
 
 
74
  }
 
 
75
  }
 
 
76
  }
77
- ?>
1
  <?php
2
  /**
3
+ * s2Member's URI protection routines *(for specific URIs)*.
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\URIs
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_ruris_sp'))
21
+ {
22
+ /**
23
+ * s2Member's URI protection routines *(for specific URIs)*.
24
+ *
25
+ * @package s2Member\URIs
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_ruris_sp
29
  {
30
  /**
31
+ * Handles URI Level Access *(for specific URIs)*.
32
+ *
33
+ * @package s2Member\URIs
34
+ * @since 3.5
35
+ *
36
+ * @param string $uri A URI, or a full URL is also fine.
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_ruri_level_access($uri = '', $check_user = TRUE)
42
+ {
43
+ do_action('ws_plugin__s2member_before_check_specific_ruri_level_access', get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
46
+ $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
47
+ $excluded = apply_filters('ws_plugin__s2member_check_specific_ruri_level_access_excluded', FALSE, get_defined_vars());
 
 
48
 
49
+ if(!$excluded && !empty($uri) && is_string($uri) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
50
+ {
51
+ if(!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $uri)) // Do NOT touch WordPress Systematics.
52
+ {
53
+ $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
 
 
 
54
 
55
+ 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, '/').'$/'.$ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
56
+ return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => 0), get_defined_vars());
 
 
 
57
 
58
+ else if(!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $uri)) // Never restrict Systematics. However, there is 1 exception above.
59
+ {
60
+ for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. Go through each Level.
61
+ {
62
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
63
 
64
+ 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)
65
+ if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
66
+ return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => $n), get_defined_vars());
67
+ }
68
  }
69
+ do_action('ws_plugin__s2member_during_check_specific_ruri_level_access', get_defined_vars());
70
+ }
71
  }
72
+ return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', NULL, get_defined_vars());
73
+ }
74
  }
75
+ }
includes/classes/ruris.inc.php CHANGED
@@ -39,6 +39,7 @@ if(!class_exists('c_ws_plugin__s2member_ruris'))
39
  {
40
  do_action('ws_plugin__s2member_before_check_ruri_level_access', get_defined_vars());
41
 
 
42
  $excluded = apply_filters('ws_plugin__s2member_check_ruri_level_access_excluded', FALSE, get_defined_vars());
43
 
44
  if(!$excluded && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) // Has it been excluded?
@@ -47,7 +48,7 @@ if(!class_exists('c_ws_plugin__s2member_ruris'))
47
  {
48
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
49
 
50
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
51
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
52
 
53
  else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // Do NOT protect Systematics. However, there is 1 exception above ^.
@@ -55,9 +56,8 @@ if(!class_exists('c_ws_plugin__s2member_ruris'))
55
  for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. Go through each Level.
56
  {
57
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
58
-
59
  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)
60
- 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)))
61
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', $n, $_SERVER['REQUEST_URI']).exit ();
62
  }
63
  }
@@ -87,7 +87,8 @@ if(!class_exists('c_ws_plugin__s2member_ruris'))
87
  $uris = (string)$uris; // Force ``$uris`` to a string value.
88
  $orig_uris = $uris; // Record the original URIs that were passed in; collectively.
89
 
90
- $user = ((is_object($user) || is_object($user = (is_user_logged_in()) ? wp_get_current_user() : FALSE)) && !empty($user->ID)) ? $user : FALSE;
 
91
 
92
  $user_id = ($user) ? (string)$user->ID : '';
93
  $user_login = ($user) ? (string)strtolower($user->user_login) : '';
39
  {
40
  do_action('ws_plugin__s2member_before_check_ruri_level_access', get_defined_vars());
41
 
42
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
43
  $excluded = apply_filters('ws_plugin__s2member_check_ruri_level_access_excluded', FALSE, get_defined_vars());
44
 
45
  if(!$excluded && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) // Has it been excluded?
48
  {
49
  $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.
50
 
51
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
52
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();
53
 
54
  else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // Do NOT protect Systematics. However, there is 1 exception above ^.
56
  for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. Go through each Level.
57
  {
58
  if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
 
59
  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)
60
+ 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)))
61
  c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', $n, $_SERVER['REQUEST_URI']).exit ();
62
  }
63
  }
87
  $uris = (string)$uris; // Force ``$uris`` to a string value.
88
  $orig_uris = $uris; // Record the original URIs that were passed in; collectively.
89
 
90
+ $user = (is_object($user) || is_object($user = wp_get_current_user()))
91
+ && !empty($user->ID) ? $user : NULL;
92
 
93
  $user_id = ($user) ? (string)$user->ID : '';
94
  $user_login = ($user) ? (string)strtolower($user->user_login) : '';
includes/classes/sc-gets-in.inc.php CHANGED
@@ -1,74 +1,89 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2Get /]` (inner processing routines).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\s2Get
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_sc_gets_in"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2Get /]` (inner processing routines).
24
- *
25
- * @package s2Member\s2Get
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_sc_gets_in
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2Get /]`.
32
- *
33
- * @package s2Member\s2Get
34
- * @since 3.5
35
- *
36
- * @attaches-to ``add_shortcode("s2Get");``
37
- *
38
- * @param array $attr An array of Attributes.
39
- * @param string $content Content inside the Shortcode.
40
- * @param string $shortcode The actual Shortcode name itself.
41
- * @return mixed Value of the requested data, or null on failure.
42
- *
43
- * @todo Prevent this routine from potentially returning objects/arrays?
44
- */
45
- public static function sc_get_details ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
46
- {
47
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
48
- do_action("ws_plugin__s2member_before_sc_get_details", get_defined_vars ());
49
- unset($__refs, $__v);
50
 
51
- $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep ((array)$attr); // Force array; trim quote entities.
 
 
52
 
53
- $attr = shortcode_atts (array("constant" => "", "user_field" => "", "user_option" => "", "user_id" => ""), $attr);
 
 
 
 
 
 
54
 
55
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
56
- do_action("ws_plugin__s2member_before_sc_get_details_after_shortcode_atts", get_defined_vars ());
57
- unset($__refs, $__v);
58
 
59
- if ($attr["constant"] && defined ($attr["constant"])) // Security check here. It must start with S2MEMBER_ on a Blog Farm.
60
- {
61
- if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || preg_match ("/^S2MEMBER_/i", $attr["constant"]))
62
- $get = constant ($attr["constant"]);
63
- }
64
- else if ($attr["user_field"] && (is_user_logged_in () || $attr["user_id"]))
65
- $get = c_ws_plugin__s2member_utils_users::get_user_field ($attr["user_field"], (int)$attr["user_id"]);
66
 
67
- else if ($attr["user_option"] && (is_user_logged_in () || $attr["user_id"]))
68
- $get = get_user_option ($attr["user_option"], (int)$attr["user_id"]);
 
 
 
 
69
 
70
- return apply_filters("ws_plugin__s2member_sc_get_details", ((isset ($get)) ? $get : null), get_defined_vars ());
71
- }
72
  }
 
 
 
 
 
 
73
  }
74
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2Get /]` (inner processing routines).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\s2Get
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_sc_gets_in'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2Get /]` (inner processing routines).
24
+ *
25
+ * @package s2Member\s2Get
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_sc_gets_in
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2Get /]`.
32
+ *
33
+ * @package s2Member\s2Get
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_shortcode('s2Get');``
37
+ *
38
+ * @param array $attr An array of Attributes.
39
+ * @param string $content Content inside the Shortcode.
40
+ * @param string $shortcode The actual Shortcode name itself.
41
+ *
42
+ * @return mixed Value of the requested data, or null on failure.
43
+ */
44
+ public static function sc_get_details($attr = array(), $content = '', $shortcode = '')
45
+ {
46
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
47
+ do_action('ws_plugin__s2member_before_sc_get_details', get_defined_vars());
48
+ unset($__refs, $__v); // Allow variables to be modified by reference.
49
+
50
+ $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array)$attr); // Force array; trim quote entities.
51
+ $attr = shortcode_atts(array('constant' => '', 'user_field' => '', 'user_option' => '', 'user_id' => ''), $attr);
 
 
 
 
 
 
52
 
53
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
54
+ do_action('ws_plugin__s2member_before_sc_get_details_after_shortcode_atts', get_defined_vars());
55
+ unset($__refs, $__v); // Allow variables to be modified by reference.
56
 
57
+ if($attr['constant'] && defined($attr['constant'])) // Security check here. It must start with S2MEMBER_ on a Blog Farm.
58
+ {
59
+ if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || preg_match('/^S2MEMBER_/i', $attr['constant']))
60
+ $get = constant($attr['constant']);
61
+ }
62
+ else if($attr['user_field'] && (is_user_logged_in() || $attr['user_id']))
63
+ $get = c_ws_plugin__s2member_utils_users::get_user_field($attr['user_field'], (int)$attr['user_id']);
64
 
65
+ else if($attr['user_option'] && (is_user_logged_in() || $attr['user_id']))
66
+ $get = get_user_option($attr['user_option'], (int)$attr['user_id']);
 
67
 
68
+ if(isset($get) && (is_array($get) || is_object($get)))
69
+ {
70
+ $_get_array = $get; // Temporary variable.
71
+ $get = array(); // New empty array.
 
 
 
72
 
73
+ foreach($_get_array as $_key_prop => $_value)
74
+ {
75
+ if(is_scalar($_value)) // One dimension only.
76
+ $get[$_key_prop] = (string)$_value;
77
+ }
78
+ unset($_get_array, $_key_prop, $_value); // Housekeeping.
79
 
80
+ $get = implode(', ', $get); // Convert to a string now.
 
81
  }
82
+ if(isset($get) && !is_scalar($get))
83
+ $get = ''; // Do not allow non-scalar values to be returned by a shortcode.
84
+ else if(isset($get)) $get = (string)$get; // Convert to a string.
85
+
86
+ return apply_filters('ws_plugin__s2member_sc_get_details', isset($get) ? $get : '', get_defined_vars());
87
+ }
88
  }
89
+ }
includes/classes/sc-gets.inc.php CHANGED
@@ -1,49 +1,49 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2Get /]`.
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\s2Get
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_sc_gets"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2Get /]`.
24
- *
25
- * @package s2Member\s2Get
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_sc_gets
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2Get /]`.
32
- *
33
- * @package s2Member\s2Get
34
- * @since 3.5
35
- *
36
- * @attaches-to ``add_shortcode("s2Get");``
37
- *
38
- * @param array $attr An array of Attributes.
39
- * @param string $content Content inside the Shortcode.
40
- * @param string $shortcode The actual Shortcode name itself.
41
- * @return inner Return-value of inner routine.
42
- */
43
- public static function sc_get_details ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
44
- {
45
- return c_ws_plugin__s2member_sc_gets_in::sc_get_details ($attr, $content, $shortcode);
46
- }
47
- }
48
  }
49
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2Get /]`.
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\s2Get
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_sc_gets'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2Get /]`.
24
+ *
25
+ * @package s2Member\s2Get
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_sc_gets
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2Get /]`.
32
+ *
33
+ * @package s2Member\s2Get
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_shortcode('s2Get');``
37
+ *
38
+ * @param array $attr An array of Attributes.
39
+ * @param string $content Content inside the Shortcode.
40
+ * @param string $shortcode The actual Shortcode name itself.
41
+ *
42
+ * @return string Return-value of inner routine.
43
+ */
44
+ public static function sc_get_details($attr = array(), $content = '', $shortcode = '')
45
+ {
46
+ return c_ws_plugin__s2member_sc_gets_in::sc_get_details($attr, $content, $shortcode);
47
+ }
 
 
 
 
 
 
 
 
48
  }
49
+ }
includes/classes/sc-if-conds-in.inc.php CHANGED
@@ -1,320 +1,320 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2If /]` (inner processing routines).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\s2If
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_sc_if_conds_in"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2If /]` (inner processing routines).
24
- *
25
- * @package s2Member\s2If
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_sc_if_conds_in
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2If /]`.
32
- *
33
- * These Shortcodes are also safe to use on a Multisite Blog Farm.
34
- *
35
- * Is Multisite Networking enabled? Please keep the following in mind.
36
- * ``current_user_can()``, will ALWAYS return true for a Super Admin!
37
- * *(this can be confusing when testing conditionals)*.
38
- *
39
- * If you're running a Multisite Blog Farm, you can Filter this array:
40
- * `ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
41
- * ``$blog_farm_safe``
42
- *
43
- * @package s2Member\s2If
44
- * @since 3.5
45
- *
46
- * @attaches-to ``add_shortcode("s2If")`` + _s2If, __s2If, ___s2If for nesting.
47
- *
48
- * @param array $attr An array of Attributes.
49
- * @param string $content Content inside the Shortcode.
50
- * @param string $shortcode The actual Shortcode name itself.
51
- * @return string The ``$content`` if true, else an empty string.
52
- *
53
- * @todo Add support for nested AND/OR conditionals inside the ONE Shortcode.
54
- * @todo Address possible security issue on sites with multiple editors, some of which should not have access to this feature.
55
- */
56
- public static function sc_if_conditionals ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
57
- {
58
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
59
- do_action("ws_plugin__s2member_before_sc_if_conditionals", get_defined_vars ());
60
- unset($__refs, $__v);
61
 
62
- $blog_farm_safe = apply_filters("ws_plugin__s2member_sc_if_conditionals_blog_farm_safe",
63
- array("is_user_logged_in", "is_user_not_logged_in",
64
- "user_is", "user_is_not", "user_can", "user_cannot",
65
- "current_user_is", "current_user_is_not", "current_user_can", "current_user_cannot",
66
- "is_admin", "is_blog_admin", "is_user_admin", "is_network_admin",
67
- "is_404", "is_home", "is_front_page", "is_singular", "is_single", "is_page",
68
- "is_page_template", "is_attachment", "is_feed", "is_archive", "is_search",
69
- "is_category", "is_tax", "is_tag", "has_tag", "is_author", "is_date",
70
- "is_day", "is_month", "is_time", "is_year", "is_sticky", "is_paged",
71
- "is_preview", "is_comments_popup", "in_the_loop", "comments_open",
72
- "pings_open", "has_excerpt", "has_post_thumbnail"), get_defined_vars ());
73
 
74
- $pro_is_installed = c_ws_plugin__s2member_utils_conds::pro_is_installed(); // Has pro version?
75
 
76
- $sc_conds_allow_arbitrary_php = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"];
77
- if(!$pro_is_installed || (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()))
78
- $sc_conds_allow_arbitrary_php = FALSE; // Always disallow on child blogs of a blog farm.
79
 
80
- $attr = // Trim quote entities to prevent issues in messy editors.
81
- c_ws_plugin__s2member_utils_strings::trim_qts_deep ((array)$attr);
82
 
83
- $content_if = $content_else = NULL; // Initialize.
84
- $shortcode_depth = strspn($shortcode, '_'); // Based on a zero index.
85
- $else_tag = "[".str_repeat("_", $shortcode_depth)."else]"; // e.g. [else], [_else], [__else]
86
 
87
- if(strpos($content, $else_tag) !== FALSE && $pro_is_installed)
88
- list($content_if, $content_else) = explode($else_tag, $content, 2);
89
 
90
- # Arbitrary PHP code via the `php` attribute...
91
 
92
- if($sc_conds_allow_arbitrary_php && isset($attr["php"]))
93
- {
94
- if(($condition_succeeded = c_ws_plugin__s2member_sc_if_conds_in::evl($attr["php"])))
95
- $condition_content = isset($content_if) ? $content_if : $content;
96
- else $condition_content = isset($content_else) ? $content_else : "";
97
 
98
- if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
99
 
100
- return do_shortcode (apply_filters("ws_plugin__s2member_sc_if_conditionals", $condition_content, get_defined_vars ()));
101
- }
102
- else if(isset($attr["php"])) // Site owner is trying to use `php`, but it's NOT allowed on this installation.
103
- {
104
- trigger_error ("s2If syntax error. Simple Conditionals are not currently configured to allow arbitrary PHP code evaluation.", E_USER_ERROR);
105
- return ""; // Return now; empty string in this case.
106
- }
 
107
 
108
- # Default behavior otherwise...
 
 
 
 
109
 
110
- foreach ($attr as $attr_key => $attr_value) // Detects and removes logical attributes.
111
- // It's NOT possible to mix logic. You MUST stick to one type of logic or another.
112
- // If both types of logic are needed, you MUST use two different Shortcodes.
113
- if (preg_match ("/^(&&|&amp;&amp;|&#038;&#038;|AND|\|\||OR|[\!\=\<\>]+)$/i", $attr_value))
114
- { // Stick with AND/OR. Ampersands are corrupted by the Visual Editor.
115
 
116
- $logicals[] = strtolower ($attr_value); // Place all logicals into an array here.
117
- unset($attr[$attr_key]); // ^ Detect logic here. We'll use the first key #0.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- if (preg_match ("/^[\!\=\<\>]+$/i", $attr_value)) // Error on these operators.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  {
121
- trigger_error ("s2If, invalid operator [ " . $attr_value . " ]. Simple Conditionals cannot process operators like ( == != <> ). Please use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
122
- return ""; // Return now; empty string in this case.
123
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
- if (!empty($logicals) && is_array($logicals) && count (array_unique ($logicals)) > 1)
 
 
 
 
 
 
126
  {
127
- trigger_error ("s2If, AND/OR malformed conditional logic. It's NOT possible to mix logic using AND/OR combinations. You MUST stick to one type of logic or another. If both types of logic are needed, you MUST use two different Shortcode expressions. Or, use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
128
- return ""; // Return now; empty string in this case.
129
  }
130
- $conditional_logic = (!empty($logicals) && is_array($logicals) && preg_match ("/^(\|\||OR)$/i", $logicals[0])) ? "OR" : "AND";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
133
- do_action("ws_plugin__s2member_before_sc_if_conditionals_after_conditional_logic", get_defined_vars ());
134
- unset($__refs, $__v);
135
 
136
- if ($conditional_logic === "AND") // This is the AND variation. This routine analyzes conditionals using AND logic (the default behavior).
 
 
 
 
 
 
 
 
 
 
137
  {
138
- foreach ($attr as $attr_value) // This is the AND variation. This routine analyzes conditionals using AND logic (the default behavior).
139
- {
140
- if (preg_match ("/^(\!?)(.+?)(\()(.*?)(\))$/", $attr_value, $m) && ($exclamation = $m[1]) !== "nill" && ($conditional = $m[2]) && ($attr_args = preg_replace ("/[\r\n\t\s ]/", "", $m[4])) !== "nill")
141
- {
142
- if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || !(preg_match ("/[\$\(\)]/", $attr_args) || preg_match ("/new[\r\n\t\s]/i", $attr_args)))
143
- {
144
- if (is_array($args = preg_split ("/[;,]+/", $attr_args, 0, PREG_SPLIT_NO_EMPTY))) // Convert all arguments into an array. And take note; possibly into an empty array.
145
- {
146
- if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || in_array(strtolower ($conditional), $blog_farm_safe))
147
- {
148
- $test = ($exclamation) ? false : true; // If !exclamation (false) otherwise this defaults to true.
149
 
150
- if (preg_match ("/^\{(.*?)\}$/", $attr_args)) // Single argument passed as an array.
151
- {
152
- if ($test === true && !call_user_func ($conditional, $args))
153
- {
154
- $condition_failed = true;
155
- break;
156
- }
157
- else if ($test === false && call_user_func ($conditional, $args))
158
- {
159
- $condition_failed = true;
160
- break;
161
- }
162
- }
163
- else if (empty($args)) // No arguments at all.
164
- {
165
- if ($test === true && !call_user_func ($conditional))
166
- {
167
- $condition_failed = true;
168
- break;
169
- }
170
- else if ($test === false && call_user_func ($conditional))
171
- {
172
- $condition_failed = true;
173
- break;
174
- }
175
- }
176
- else if ($test === true && !call_user_func_array($conditional, $args))
177
- {
178
- $condition_failed = true;
179
- break;
180
- }
181
- else if ($test === false && call_user_func_array($conditional, $args))
182
- {
183
- $condition_failed = true;
184
- break;
185
- }
186
- }
187
- else
188
- {
189
- trigger_error ("s2If, unsafe conditional function [ " . $attr_value . " ]", E_USER_ERROR);
190
- return ""; // Return now; empty string in this case.
191
- }
192
- }
193
- else
194
- {
195
- trigger_error ("s2If, conditional args are NOT an array [ " . $attr_value . " ]", E_USER_ERROR);
196
- return ""; // Return now; empty string in this case.
197
- }
198
- }
199
- else
200
- {
201
- trigger_error ("s2If, unsafe conditional args [ " . $attr_value . " ]", E_USER_ERROR);
202
- return ""; // Return now; empty string in this case.
203
- }
204
- }
205
- else
206
- {
207
- trigger_error ("s2If, malformed conditional [ " . $attr_value . " ]", E_USER_ERROR);
208
- return ""; // Return now; empty string in this case.
209
- }
210
  }
211
- if(!empty($condition_failed))
212
- $condition_content = isset($content_else) ? $content_else : "";
213
- else $condition_content = isset($content_if) ? $content_if : $content;
214
-
215
- if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
216
-
217
- return do_shortcode (apply_filters("ws_plugin__s2member_sc_if_conditionals", $condition_content, get_defined_vars ()));
218
- }
219
-
220
- else if ($conditional_logic === "OR") // This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic.
221
- {
222
- foreach ($attr as $attr_value) // This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic.
223
  {
224
- if (preg_match ("/^(\!?)(.+?)(\()(.*?)(\))$/", $attr_value, $m) && ($exclamation = $m[1]) !== "nill" && ($conditional = $m[2]) && ($attr_args = preg_replace ("/[\r\n\t\s ]/", "", $m[4])) !== "nill")
225
- {
226
- if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || !(preg_match ("/[\$\(\)]/", $attr_args) || preg_match ("/new[\r\n\t\s]/i", $attr_args)))
227
- {
228
- if (is_array($args = preg_split ("/[;,]+/", $attr_args, 0, PREG_SPLIT_NO_EMPTY))) // Convert all arguments into an array. And take note; possibly into an empty array.
229
- {
230
- if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || in_array(strtolower ($conditional), $blog_farm_safe))
231
- {
232
- $test = ($exclamation) ? false : true; // If !exclamation (false) otherwise this defaults to true.
233
-
234
- if (preg_match ("/^\{(.*?)\}$/", $attr_args)) // Single argument passed as an array.
235
- {
236
- if ($test === true && call_user_func ($conditional, $args))
237
- {
238
- $condition_succeeded = true;
239
- break;
240
- }
241
- else if ($test === false && !call_user_func ($conditional, $args))
242
- {
243
- $condition_succeeded = true;
244
- break;
245
- }
246
- }
247
- else if (empty($args)) // No arguments at all.
248
- {
249
- if ($test === true && call_user_func ($conditional))
250
- {
251
- $condition_succeeded = true;
252
- break;
253
- }
254
- else if ($test === false && !call_user_func ($conditional))
255
- {
256
- $condition_succeeded = true;
257
- break;
258
- }
259
- }
260
- else if ($test === true && call_user_func_array($conditional, $args))
261
- {
262
- $condition_succeeded = true;
263
- break;
264
- }
265
- else if ($test === false && !call_user_func_array($conditional, $args))
266
- {
267
- $condition_succeeded = true;
268
- break;
269
- }
270
- }
271
- else
272
- {
273
- trigger_error ("s2If, unsafe conditional function [ " . $attr_value . " ]", E_USER_ERROR);
274
- return ""; // Return now; empty string in this case.
275
- }
276
- }
277
- else
278
- {
279
- trigger_error ("s2If, conditional args are NOT an array [ " . $attr_value . " ]", E_USER_ERROR);
280
- return ""; // Return now; empty string in this case.
281
- }
282
- }
283
- else
284
- {
285
- trigger_error ("s2If, unsafe conditional args [ " . $attr_value . " ]", E_USER_ERROR);
286
- return ""; // Return now; empty string in this case.
287
- }
288
- }
289
- else
290
- {
291
- trigger_error ("s2If, malformed conditional [ " . $attr_value . " ]", E_USER_ERROR);
292
- return ""; // Return now; empty string in this case.
293
- }
294
  }
295
- if(!empty($condition_succeeded))
296
- $condition_content = isset($content_if) ? $content_if : $content;
297
- else $condition_content = isset($content_else) ? $content_else : "";
298
-
299
- if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
300
-
301
- return do_shortcode (apply_filters("ws_plugin__s2member_sc_if_conditionals", $condition_content, get_defined_vars ()));
 
 
 
 
 
 
 
 
 
302
  }
303
- return ""; // Default return value.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  }
305
- /**
306
- * Sandbox for arbitrary PHP code evaluation in `[s2If/]` shortcodes.
307
- *
308
- * @package s2Member\s2If
309
- * @since 140326
310
- *
311
- * @param string $expression PHP expression.
312
- * @return bool TRUE if condition succeed; else FALSE.
313
- */
314
- public static function evl($expression)
315
- {
316
- return eval("return (".(string)$expression.");");
317
  }
 
 
 
 
 
 
 
318
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  }
320
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2If /]` (inner processing routines).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\s2If
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_sc_if_conds_in'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2If /]` (inner processing routines).
24
+ *
25
+ * @package s2Member\s2If
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_sc_if_conds_in
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2If /]`.
32
+ *
33
+ * These Shortcodes are also safe to use on a Multisite Blog Farm.
34
+ *
35
+ * Is Multisite Networking enabled? Please keep the following in mind.
36
+ * ``current_user_can()``, will ALWAYS return true for a Super Admin!
37
+ * *(this can be confusing when testing conditionals)*.
38
+ *
39
+ * If you're running a Multisite Blog Farm, you can Filter this array:
40
+ * `ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
41
+ * ``$blog_farm_safe``
42
+ *
43
+ * @package s2Member\s2If
44
+ * @since 3.5
45
+ *
46
+ * @attaches-to ``add_shortcode('s2If')`` + _s2If, __s2If, ___s2If for nesting.
47
+ *
48
+ * @param array $attr An array of Attributes.
49
+ * @param string $content Content inside the Shortcode.
50
+ * @param string $shortcode The actual Shortcode name itself.
51
+ *
52
+ * @return string The ``$content`` if true, else an empty string.
53
+ *
54
+ * @todo Add support for nested AND/OR conditionals inside the ONE Shortcode.
55
+ * @todo Address possible security issue on sites with multiple editors, some of which should not have access to this feature.
56
+ */
57
+ public static function sc_if_conditionals($attr = array(), $content = '', $shortcode = '')
58
+ {
59
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
60
+ do_action('ws_plugin__s2member_before_sc_if_conditionals', get_defined_vars());
61
+ unset($__refs, $__v); // Allows variables to be modified by reference.
 
 
 
 
 
 
 
62
 
63
+ $blog_farm_safe = apply_filters('ws_plugin__s2member_sc_if_conditionals_blog_farm_safe',
64
+ array('is_user_logged_in', 'is_user_not_logged_in',
65
+ 'user_is', 'user_is_not', 'user_can', 'user_cannot',
66
+ 'current_user_is', 'current_user_is_not', 'current_user_can', 'current_user_cannot',
67
+ 'is_admin', 'is_blog_admin', 'is_user_admin', 'is_network_admin',
68
+ 'is_404', 'is_home', 'is_front_page', 'is_singular', 'is_single', 'is_page',
69
+ 'is_page_template', 'is_attachment', 'is_feed', 'is_archive', 'is_search',
70
+ 'is_category', 'is_tax', 'is_tag', 'has_tag', 'is_author', 'is_date',
71
+ 'is_day', 'is_month', 'is_time', 'is_year', 'is_sticky', 'is_paged',
72
+ 'is_preview', 'is_comments_popup', 'in_the_loop', 'comments_open',
73
+ 'pings_open', 'has_excerpt', 'has_post_thumbnail'), get_defined_vars());
74
 
75
+ $pro_is_installed = c_ws_plugin__s2member_utils_conds::pro_is_installed(); // Has pro version?
76
 
77
+ $sc_conds_allow_arbitrary_php = $GLOBALS['WS_PLUGIN__']['s2member']['o']['sc_conds_allow_arbitrary_php'];
78
+ if(!$pro_is_installed || (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()))
79
+ $sc_conds_allow_arbitrary_php = FALSE; // Always disallow on child blogs of a blog farm.
80
 
81
+ $attr = // Trim quote entities to prevent issues in messy editors.
82
+ c_ws_plugin__s2member_utils_strings::trim_qts_deep((array)$attr);
83
 
84
+ $content_if = $content_else = NULL; // Initialize.
85
+ $shortcode_depth = strspn($shortcode, '_'); // Based on a zero index.
86
+ $else_tag = '['.str_repeat('_', $shortcode_depth).'else]'; // e.g. [else], [_else], [__else]
87
 
88
+ if(strpos($content, $else_tag) !== FALSE && $pro_is_installed)
89
+ list($content_if, $content_else) = explode($else_tag, $content, 2);
90
 
91
+ # Arbitrary PHP code via the `php` attribute...
92
 
93
+ if($sc_conds_allow_arbitrary_php && isset($attr['php']))
94
+ {
95
+ if(($condition_succeeded = c_ws_plugin__s2member_sc_if_conds_in::evl($attr['php'])))
96
+ $condition_content = isset($content_if) ? $content_if : $content;
97
+ else $condition_content = isset($content_else) ? $content_else : '';
98
 
99
+ if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
100
 
101
+ return do_shortcode(apply_filters('ws_plugin__s2member_sc_if_conditionals', $condition_content, get_defined_vars()));
102
+ }
103
+ else if(isset($attr['php'])) // Site owner is trying to use `php`, but it's NOT allowed on this installation.
104
+ {
105
+ trigger_error('s2If syntax error. Simple Conditionals are not currently configured to allow arbitrary PHP code evaluation.', E_USER_ERROR);
106
+ return ''; // Return now; empty string in this case.
107
+ }
108
+ # Default behavior otherwise...
109
 
110
+ foreach($attr as $attr_key => $attr_value) // Detects and removes logical attributes.
111
+ // It's NOT possible to mix logic. You MUST stick to one type of logic or another.
112
+ // If both types of logic are needed, you MUST use two different Shortcodes.
113
+ if(preg_match('/^(&&|&amp;&amp;|&#038;&#038;|AND|\|\||OR|[\!\=\<\>]+)$/i', $attr_value))
114
+ { // Stick with AND/OR. Ampersands are corrupted by the Visual Editor.
115
 
116
+ $logicals[] = strtolower($attr_value); // Place all logicals into an array here.
117
+ unset($attr[$attr_key]); // ^ Detect logic here. We'll use the first key #0.
 
 
 
118
 
119
+ if(preg_match('/^[\!\=\<\>]+$/i', $attr_value)) // Error on these operators.
120
+ {
121
+ trigger_error('s2If, invalid operator [ '.$attr_value.' ]. Simple Conditionals cannot process operators like ( == != <> ). Please use Advanced (PHP) Conditionals instead.', E_USER_ERROR);
122
+ return ''; // Return now; empty string in this case.
123
+ }
124
+ }
125
+ if(!empty($logicals) && is_array($logicals) && count(array_unique($logicals)) > 1)
126
+ {
127
+ trigger_error('s2If, AND/OR malformed conditional logic. It\'s NOT possible to mix logic using AND/OR combinations. You MUST stick to one type of logic or another. If both types of logic are needed, you MUST use two different Shortcode expressions. Or, use Advanced (PHP) Conditionals instead.', E_USER_ERROR);
128
+ return ''; // Return now; empty string in this case.
129
+ }
130
+ $conditional_logic = (!empty($logicals) && is_array($logicals) && preg_match('/^(\|\||OR)$/i', $logicals[0])) ? 'OR' : 'AND';
131
+
132
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
133
+ do_action('ws_plugin__s2member_before_sc_if_conditionals_after_conditional_logic', get_defined_vars());
134
+ unset($__refs, $__v); // Allows variables to be modified by reference.
135
 
136
+ if($conditional_logic === 'AND') // This is the AND variation. This routine analyzes conditionals using AND logic (the default behavior).
137
+ {
138
+ foreach($attr as $attr_value) // This is the AND variation. This routine analyzes conditionals using AND logic (the default behavior).
139
+ {
140
+ if(preg_match('/^(\!?)(.+?)(\()(.*?)(\))$/', $attr_value, $m) && ($exclamation = $m[1]) !== 'nill' && ($conditional = $m[2]) && ($attr_args = preg_replace('/['."\r\n\t".'\s]/', '', $m[4])) !== 'nill')
141
+ {
142
+ if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || !(preg_match('/[\$\(\)]/', $attr_args) || preg_match('/new['."\r\n\t".'\s]/i', $attr_args)))
143
+ {
144
+ if(is_array($args = preg_split('/[;,]+/', $attr_args, 0, PREG_SPLIT_NO_EMPTY))) // Convert all arguments into an array. And take note; possibly into an empty array.
145
+ {
146
+ if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || in_array(strtolower($conditional), $blog_farm_safe))
147
+ {
148
+ $test = ($exclamation) ? FALSE : TRUE; // If !exclamation (false) otherwise this defaults to true.
149
+
150
+ if(preg_match('/^\{(.*?)\}$/', $attr_args)) // Single argument passed as an array.
151
+ {
152
+ if($test === TRUE && !call_user_func($conditional, $args))
153
  {
154
+ $condition_failed = TRUE;
155
+ break;
156
  }
157
+ else if($test === FALSE && call_user_func($conditional, $args))
158
+ {
159
+ $condition_failed = TRUE;
160
+ break;
161
+ }
162
+ }
163
+ else if(empty($args)) // No arguments at all.
164
+ {
165
+ if($test === TRUE && !call_user_func($conditional))
166
+ {
167
+ $condition_failed = TRUE;
168
+ break;
169
+ }
170
+ else if($test === FALSE && call_user_func($conditional))
171
+ {
172
+ $condition_failed = TRUE;
173
+ break;
174
+ }
175
+ }
176
+ else if($test === TRUE && !call_user_func_array($conditional, $args))
177
+ {
178
+ $condition_failed = TRUE;
179
+ break;
180
+ }
181
+ else if($test === FALSE && call_user_func_array($conditional, $args))
182
+ {
183
+ $condition_failed = TRUE;
184
+ break;
185
+ }
186
  }
187
+ else
188
+ {
189
+ trigger_error('s2If, unsafe conditional function [ '.$attr_value.' ]', E_USER_ERROR);
190
+ return ''; // Return now; empty string in this case.
191
+ }
192
+ }
193
+ else
194
  {
195
+ trigger_error('s2If, conditional args are NOT an array [ '.$attr_value.' ]', E_USER_ERROR);
196
+ return ''; // Return now; empty string in this case.
197
  }
198
+ }
199
+ else
200
+ {
201
+ trigger_error('s2If, unsafe conditional args [ '.$attr_value.' ]', E_USER_ERROR);
202
+ return ''; // Return now; empty string in this case.
203
+ }
204
+ }
205
+ else
206
+ {
207
+ trigger_error('s2If, malformed conditional [ '.$attr_value.' ]', E_USER_ERROR);
208
+ return ''; // Return now; empty string in this case.
209
+ }
210
+ }
211
+ if(!empty($condition_failed))
212
+ $condition_content = isset($content_else) ? $content_else : '';
213
+ else $condition_content = isset($content_if) ? $content_if : $content;
214
 
215
+ if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
 
 
216
 
217
+ return do_shortcode(apply_filters('ws_plugin__s2member_sc_if_conditionals', $condition_content, get_defined_vars()));
218
+ }
219
+ else if($conditional_logic === 'OR') // This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic.
220
+ {
221
+ foreach($attr as $attr_value) // This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND logic.
222
+ {
223
+ if(preg_match('/^(\!?)(.+?)(\()(.*?)(\))$/', $attr_value, $m) && ($exclamation = $m[1]) !== 'nill' && ($conditional = $m[2]) && ($attr_args = preg_replace('/['."\r\n\t".'\s]/', '', $m[4])) !== 'nill')
224
+ {
225
+ if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || !(preg_match('/[\$\(\)]/', $attr_args) || preg_match('/new['."\r\n\t".'\s]/i', $attr_args)))
226
+ {
227
+ if(is_array($args = preg_split('/[;,]+/', $attr_args, 0, PREG_SPLIT_NO_EMPTY))) // Convert all arguments into an array. And take note; possibly into an empty array.
228
  {
229
+ if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || in_array(strtolower($conditional), $blog_farm_safe))
230
+ {
231
+ $test = ($exclamation) ? FALSE : TRUE; // If !exclamation (false) otherwise this defaults to true.
 
 
 
 
 
 
 
 
232
 
233
+ if(preg_match('/^\{(.*?)\}$/', $attr_args)) // Single argument passed as an array.
234
+ {
235
+ if($test === TRUE && call_user_func($conditional, $args))
236
+ {
237
+ $condition_succeeded = TRUE;
238
+ break;
239
+ }
240
+ else if($test === FALSE && !call_user_func($conditional, $args))
241
+ {
242
+ $condition_succeeded = TRUE;
243
+ break;
244
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
+ else if(empty($args)) // No arguments at all.
 
 
 
 
 
 
 
 
 
 
 
247
  {
248
+ if($test === TRUE && call_user_func($conditional))
249
+ {
250
+ $condition_succeeded = TRUE;
251
+ break;
252
+ }
253
+ else if($test === FALSE && !call_user_func($conditional))
254
+ {
255
+ $condition_succeeded = TRUE;
256
+ break;
257
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
+ else if($test === TRUE && call_user_func_array($conditional, $args))
260
+ {
261
+ $condition_succeeded = TRUE;
262
+ break;
263
+ }
264
+ else if($test === FALSE && !call_user_func_array($conditional, $args))
265
+ {
266
+ $condition_succeeded = TRUE;
267
+ break;
268
+ }
269
+ }
270
+ else
271
+ {
272
+ trigger_error('s2If, unsafe conditional function [ '.$attr_value.' ]', E_USER_ERROR);
273
+ return ''; // Return now; empty string in this case.
274
+ }
275
  }
276
+ else
277
+ {
278
+ trigger_error('s2If, conditional args are NOT an array [ '.$attr_value.' ]', E_USER_ERROR);
279
+ return ''; // Return now; empty string in this case.
280
+ }
281
+ }
282
+ else
283
+ {
284
+ trigger_error('s2If, unsafe conditional args [ '.$attr_value.' ]', E_USER_ERROR);
285
+ return ''; // Return now; empty string in this case.
286
+ }
287
+ }
288
+ else
289
+ {
290
+ trigger_error('s2If, malformed conditional [ '.$attr_value.' ]', E_USER_ERROR);
291
+ return ''; // Return now; empty string in this case.
292
  }
 
 
 
 
 
 
 
 
 
 
 
 
293
  }
294
+ if(!empty($condition_succeeded))
295
+ $condition_content = isset($content_if) ? $content_if : $content;
296
+ else $condition_content = isset($content_else) ? $content_else : '';
297
+
298
+ if($condition_content) $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
299
+
300
+ return do_shortcode(apply_filters('ws_plugin__s2member_sc_if_conditionals', $condition_content, get_defined_vars()));
301
  }
302
+ return ''; // Default return value.
303
+ }
304
+
305
+ /**
306
+ * Sandbox for arbitrary PHP code evaluation in `[s2If/]` shortcodes.
307
+ *
308
+ * @package s2Member\s2If
309
+ * @since 140326
310
+ *
311
+ * @param string $expression PHP expression.
312
+ *
313
+ * @return bool TRUE if condition succeed; else FALSE.
314
+ */
315
+ public static function evl($expression)
316
+ {
317
+ return eval('return ('.(string)$expression.');');
318
+ }
319
  }
320
+ }
includes/classes/sc-if-conds.inc.php CHANGED
@@ -1,59 +1,59 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2If /]`.
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\s2If
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_sc_if_conds"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2If /]`.
24
- *
25
- * @package s2Member\s2If
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_sc_if_conds
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2If /]`.
32
- *
33
- * These Shortcodes are also safe to use on a Multisite Blog Farm.
34
- *
35
- * Is Multisite Networking enabled? Please keep the following in mind.
36
- * ``current_user_can()``, will ALWAYS return true for a Super Admin!
37
- * *(this can be confusing when testing conditionals)*.
38
- *
39
- * If you're running a Multisite Blog Farm, you can Filter this array:
40
- * `ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
41
- * ``$blog_farm_safe``
42
- *
43
- * @package s2Member\s2If
44
- * @since 3.5
45
- *
46
- * @attaches-to ``add_shortcode("s2If")`` + _s2If, __s2If, ___s2If for nesting.
47
- *
48
- * @param array $attr An array of Attributes.
49
- * @param string $content Content inside the Shortcode.
50
- * @param string $shortcode The actual Shortcode name itself.
51
- * @return inner Return-value of inner routine.
52
- */
53
- public static function sc_if_conditionals ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
54
- {
55
- return c_ws_plugin__s2member_sc_if_conds_in::sc_if_conditionals ($attr, $content, $shortcode);
56
- }
57
- }
58
  }
59
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2If /]`.
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\s2If
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_sc_if_conds'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2If /]`.
24
+ *
25
+ * @package s2Member\s2If
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_sc_if_conds
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2If /]`.
32
+ *
33
+ * These Shortcodes are also safe to use on a Multisite Blog Farm.
34
+ *
35
+ * Is Multisite Networking enabled? Please keep the following in mind.
36
+ * ``current_user_can()``, will ALWAYS return true for a Super Admin!
37
+ * *(this can be confusing when testing conditionals)*.
38
+ *
39
+ * If you're running a Multisite Blog Farm, you can Filter this array:
40
+ * `ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
41
+ * ``$blog_farm_safe``
42
+ *
43
+ * @package s2Member\s2If
44
+ * @since 3.5
45
+ *
46
+ * @attaches-to ``add_shortcode('s2If')`` + _s2If, __s2If, ___s2If for nesting.
47
+ *
48
+ * @param array $attr An array of Attributes.
49
+ * @param string $content Content inside the Shortcode.
50
+ * @param string $shortcode The actual Shortcode name itself.
51
+ *
52
+ * @return string Return-value of inner routine.
53
+ */
54
+ public static function sc_if_conditionals($attr = array(), $content = '', $shortcode = '')
55
+ {
56
+ return c_ws_plugin__s2member_sc_if_conds_in::sc_if_conditionals($attr, $content, $shortcode);
57
+ }
 
 
 
 
 
 
 
 
58
  }
59
+ }
includes/classes/sc-keys-in.inc.php CHANGED
@@ -1,64 +1,63 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2Key /]` (inner processing routines).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\s2Key
15
- * @since 110912
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_sc_keys_in"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2Key /]` (inner processing routines).
24
- *
25
- * @package s2Member\s2Key
26
- * @since 110912
27
- */
28
- class c_ws_plugin__s2member_sc_keys_in
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2Key /]`.
32
- *
33
- * @package s2Member\s2Key
34
- * @since 110912
35
- *
36
- * @attaches-to ``add_shortcode("s2Key");``
37
- *
38
- * @param array $attr An array of Attributes.
39
- * @param string $content Content inside the Shortcode.
40
- * @param string $shortcode The actual Shortcode name itself.
41
- * @return string Value of the requested key, or null on failure.
42
- */
43
- public static function sc_get_key ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
44
- {
45
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
46
- do_action("ws_plugin__s2member_before_sc_get_key", get_defined_vars ());
47
- unset($__refs, $__v);
48
 
49
- $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep ((array)$attr);
 
50
 
51
- $attr = shortcode_atts (array("file_download" => "", "directive" => ""), $attr);
 
 
52
 
53
- foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
54
- do_action("ws_plugin__s2member_before_sc_get_key_after_shortcode_atts", get_defined_vars ());
55
- unset($__refs, $__v);
56
 
57
- if ($attr["file_download"]) // Requesting a File Download Key?
58
- $get = c_ws_plugin__s2member_files::file_download_key ($attr["file_download"], $attr["directive"]);
59
-
60
- return apply_filters("ws_plugin__s2member_sc_get_key", ((isset ($get)) ? $get : null), get_defined_vars ());
61
- }
62
- }
63
  }
64
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2Key /]` (inner processing routines).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\s2Key
15
+ * @since 110912
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_sc_keys_in'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2Key /]` (inner processing routines).
24
+ *
25
+ * @package s2Member\s2Key
26
+ * @since 110912
27
+ */
28
+ class c_ws_plugin__s2member_sc_keys_in
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2Key /]`.
32
+ *
33
+ * @package s2Member\s2Key
34
+ * @since 110912
35
+ *
36
+ * @attaches-to ``add_shortcode('s2Key');``
37
+ *
38
+ * @param array $attr An array of Attributes.
39
+ * @param string $content Content inside the Shortcode.
40
+ * @param string $shortcode The actual Shortcode name itself.
41
+ *
42
+ * @return string Value of the requested key, or null on failure.
43
+ */
44
+ public static function sc_get_key($attr = array(), $content = '', $shortcode = '')
45
+ {
46
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
47
+ do_action('ws_plugin__s2member_before_sc_get_key', get_defined_vars());
48
+ unset($__refs, $__v); // Allow variables to be modified by reference.
 
 
 
 
 
 
 
49
 
50
+ $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array)$attr);
51
+ $attr = shortcode_atts(array('file_download' => '', 'directive' => ''), $attr);
52
 
53
+ foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v;
54
+ do_action('ws_plugin__s2member_before_sc_get_key_after_shortcode_atts', get_defined_vars());
55
+ unset($__refs, $__v); // Allow variables to be modified by reference.
56
 
57
+ if($attr['file_download']) // Requesting a File Download Key?
58
+ $get = c_ws_plugin__s2member_files::file_download_key($attr['file_download'], $attr['directive']);
 
59
 
60
+ return apply_filters('ws_plugin__s2member_sc_get_key', isset($get) ? $get : '', get_defined_vars());
61
+ }
 
 
 
 
62
  }
63
+ }
includes/classes/sc-keys.inc.php CHANGED
@@ -1,49 +1,49 @@
1
  <?php
2
  /**
3
- * Shortcode `[s2Key /]`.
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\s2Key
15
- * @since 110912
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_sc_keys"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Shortcode `[s2Key /]`.
24
- *
25
- * @package s2Member\s2Key
26
- * @since 110912
27
- */
28
- class c_ws_plugin__s2member_sc_keys
29
- {
30
- /**
31
- * Handles the Shortcode for: `[s2Key /]`.
32
- *
33
- * @package s2Member\s2Key
34
- * @since 110912
35
- *
36
- * @attaches-to ``add_shortcode("s2Key");``
37
- *
38
- * @param array $attr An array of Attributes.
39
- * @param string $content Content inside the Shortcode.
40
- * @param string $shortcode The actual Shortcode name itself.
41
- * @return inner Return-value of inner routine.
42
- */
43
- public static function sc_get_key ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
44
- {
45
- return c_ws_plugin__s2member_sc_keys_in::sc_get_key ($attr, $content, $shortcode);
46
- }
47
- }
48
  }
49
- ?>
1
  <?php
2
  /**
3
+ * Shortcode `[s2Key /]`.
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\s2Key
15
+ * @since 110912
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_sc_keys'))
21
+ {
22
+ /**
23
+ * Shortcode `[s2Key /]`.
24
+ *
25
+ * @package s2Member\s2Key
26
+ * @since 110912
27
+ */
28
+ class c_ws_plugin__s2member_sc_keys
29
  {
30
  /**
31
+ * Handles the Shortcode for: `[s2Key /]`.
32
+ *
33
+ * @package s2Member\s2Key
34
+ * @since 110912
35
+ *
36
+ * @attaches-to ``add_shortcode('s2Key');``
37
+ *
38
+ * @param array $attr An array of Attributes.
39
+ * @param string $content Content inside the Shortcode.
40
+ * @param string $shortcode The actual Shortcode name itself.
41
+ *
42
+ * @return string Return-value of inner routine.
43
+ */
44
+ public static function sc_get_key($attr = array(), $content = '', $shortcode = '')
45
+ {
46
+ return c_ws_plugin__s2member_sc_keys_in::sc_get_key($attr, $content, $shortcode);
47
+ }
 
 
 
 
 
 
 
 
48
  }
49
+ }
includes/classes/ssl-in.inc.php CHANGED
@@ -1,171 +1,167 @@
1
  <?php
2
  /**
3
- * SSL routines (inner processing routines).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\SSL
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_ssl_in"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * SSL routines (inner processing routines).
24
- *
25
- * @package s2Member\SSL
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_ssl_in
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  {
30
- /**
31
- * Forces SSL on specific Posts/Pages, or any page for that matter.
32
- *
33
- * Triggered by Custom Field: `s2member_force_ssl = yes|port#`
34
- *
35
- * Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`.
36
- *
37
- * @package s2Member\SSL
38
- * @since 3.5
39
- *
40
- * @attaches-to ``add_action("init");``
41
- * @also-attaches-to ``add_action("wp");``
42
- *
43
- * @return null Possibly exiting script execution after redirection to SSL variation.
44
- *
45
- * @todo Add `form` to the array ``$non_ssl_attr_only_tags``?
46
- * @todo Cleanup this routine and convert callback functions to static class methods?
47
- */
48
- public static function force_ssl($vars = array()) // Phase 2 of ``c_ws_plugin__s2member_ssl::check_force_ssl()``.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  {
50
- extract /* Extract all vars passed in from: ``c_ws_plugin__s2member_ssl::check_force_ssl()``. */($vars);
51
-
52
- $force_ssl = (!is_string($force_ssl)) ? /* Force string. */ (string)(int)$force_ssl : $force_ssl;
53
- $force_ssl = (is_numeric($force_ssl) && $force_ssl > 1) ? $force_ssl : /* Use `yes`. */ "yes";
54
-
55
- $ssl_host = /* Remove port here. */ preg_replace("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
56
- $ssl_port = /* Port? */ (is_numeric($force_ssl) && $force_ssl > 1) ? $force_ssl : false;
57
- $ssl_host_port = /* Use port #? */ $ssl_host.(($ssl_port) ? ":".$ssl_port : "");
58
-
59
- if(!is_ssl() || !isset($_GET[$s2_ssl_gv]) /* SSL must be enabled. */)
60
- {
61
- $https = "https://".$ssl_host_port.$_SERVER["REQUEST_URI"];
62
- $https_with_s2_ssl_gv = add_query_arg($s2_ssl_gv, urlencode($force_ssl), $https);
63
- wp_redirect($https_with_s2_ssl_gv).exit();
64
- }
65
- else // Otherwise, we buffer all output, and switch all content over to `https`.
66
- // Assume here that other links on the site should NOT be converted to `https`.
67
- {
68
- add_filter("redirect_canonical", "__return_false");
69
-
70
- define("_ws_plugin__s2member_force_ssl_host", $ssl_host);
71
- define("_ws_plugin__s2member_force_ssl_port", $ssl_port);
72
- define("_ws_plugin__s2member_force_ssl_host_port", $ssl_host_port);
73
-
74
- // Filter these. Do NOT create a sitewide conversion to `https`.
75
- add_filter("home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
76
- add_filter("network_home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
77
-
78
- // Filter these. Do NOT create a sitewide conversion to `https`.
79
- add_filter("site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
80
- add_filter("network_site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
81
- /*
82
- These additional URLs are NOT Filtered by default; but can be if needed. Use these Filters. */
83
- if(apply_filters("_ws_plugin__s2member_force_non_ssl_scheme_plugins_url", false, get_defined_vars()))
84
- add_filter("plugins_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 2);
85
- /*
86
- These additional URLs are NOT Filtered by default; but can be if needed. Use these Filters. */
87
- if(apply_filters("_ws_plugin__s2member_force_non_ssl_scheme_content_url", false, get_defined_vars()))
88
- add_filter("content_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 2);
89
- /*
90
- Now we create various callback functions associated with SSL and non-SSL buffering.
91
- */
92
- if(!function_exists("_ws_plugin__s2member_force_ssl_buffer_callback"))
93
- {
94
- function _ws_plugin__s2member_force_ssl_buffer_callback($m = FALSE)
95
- {
96
- $s = /* Conversion to SSL mode via `https`. */ preg_replace("/http\:\/\//i", "https://", $m[0]);
97
-
98
- if(_ws_plugin__s2member_force_ssl_host && /* Convert port? */ _ws_plugin__s2member_force_ssl_port && _ws_plugin__s2member_force_ssl_host_port)
99
- $s = preg_replace("/(?:https?\:)?\/\/".preg_quote(_ws_plugin__s2member_force_ssl_host, "/")."(?:\:[0-9]+)?/i", "https://"._ws_plugin__s2member_force_ssl_host_port, $s);
100
-
101
- $s = (strtolower($m[1]) === "link" && preg_match /* These are fine to leave like they are. */("/['\"](?:alternate|profile|pingback|EditURI|wlwmanifest|prev|next)['\"]/i", $m[0])) ? $m[0] : $s;
102
-
103
- return /* Return string with conversions. */ $s;
104
- }
105
- }
106
-
107
- if(!function_exists("_ws_plugin__s2member_force_non_ssl_buffer_callback"))
108
- {
109
- function _ws_plugin__s2member_force_non_ssl_buffer_callback($m = FALSE)
110
- {
111
- $s = preg_replace("/(?:https?\:)?\/\/".preg_quote(_ws_plugin__s2member_force_ssl_host_port, "/")."/i", "http://"._ws_plugin__s2member_force_ssl_host, $m[0]);
112
-
113
- $s = preg_replace("/(?:https?\:)?\/\/".preg_quote(_ws_plugin__s2member_force_ssl_host, "/")."/i", "http://"._ws_plugin__s2member_force_ssl_host, $s);
114
-
115
- return /* Return string with conversions. */ $s;
116
- }
117
- }
118
-
119
- if(!function_exists("_ws_plugin__s2member_force_non_ssl_scheme"))
120
- {
121
- function _ws_plugin__s2member_force_non_ssl_scheme($url = FALSE, $path = FALSE, $scheme = FALSE)
122
- {
123
- if($scheme === "relative") return $url; // Nothing to do in this case.
124
-
125
- if(!in_array /* If NOT explicitly passed through. */($scheme, array("http", "https"), true))
126
- {
127
- if(($scheme === "login_post" || $scheme === "rpc") && (force_ssl_login() || force_ssl_admin()))
128
- $scheme = "https";
129
-
130
- else if(($scheme === "login" || $scheme === "admin") && force_ssl_admin())
131
- $scheme = "https";
132
-
133
- else // Default to non-SSL: `http`.
134
- $scheme = "http";
135
- }
136
- return preg_replace("/^(?:https?\:)?\/\//i", $scheme."://", $url);
137
- }
138
- }
139
-
140
- if(!function_exists("_ws_plugin__s2member_force_ssl_buffer"))
141
- {
142
- function _ws_plugin__s2member_force_ssl_buffer($buffer = FALSE)
143
- {
144
- $o_pcre = /* Record existing PCRE backtrack limit. */ @ini_get("pcre.backtrack_limit");
145
- @ini_set /* Increase PCRE backtrack limit for this routine. */("pcre.backtrack_limit", 10000000);
146
-
147
- $ssl_entire_tags = array_unique(array_map("strtolower", apply_filters("_ws_plugin__s2member_force_ssl_buffer_entire_tags", array("script", "style", "iframe", "object", "embed", "video"), get_defined_vars())));
148
- $non_ssl_entire_tags = array_unique(array_map("strtolower", apply_filters("_ws_plugin__s2member_force_non_ssl_buffer_entire_tags", array(), get_defined_vars())));
149
-
150
- $ssl_attr_only_tags = array_unique( /* Diff here. No need to re-run entire tags. */array_diff(array_map("strtolower", apply_filters("_ws_plugin__s2member_force_ssl_buffer_attr_only_tags", array("link", "img", "input"), get_defined_vars())), $ssl_entire_tags));
151
- $non_ssl_attr_only_tags = array_unique( /* No need to re-run entire tags. */array_diff(array_map("strtolower", apply_filters("_ws_plugin__s2member_force_non_ssl_buffer_attr_only_tags", array("a"), get_defined_vars())), $non_ssl_entire_tags));
152
-
153
- $buffer = ($ssl_entire_tags) ? preg_replace_callback("/\<(".implode("|", c_ws_plugin__s2member_utils_strings::preg_quote_deep($ssl_entire_tags, "/")).")(?![a-z_0-9\-])[^\>]*?\>.*?\<\/\\1\>/is", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer) : $buffer;
154
- $buffer = ($ssl_attr_only_tags) ? preg_replace_callback("/\<(".implode("|", c_ws_plugin__s2member_utils_strings::preg_quote_deep($ssl_attr_only_tags, "/")).")(?![a-z_0-9\-])[^\>]+?\>/i", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer) : $buffer;
155
-
156
- $buffer = ($non_ssl_entire_tags) ? preg_replace_callback("/\<(".implode("|", c_ws_plugin__s2member_utils_strings::preg_quote_deep($non_ssl_entire_tags, "/")).")(?![a-z_0-9\-])[^\>]*?\>.*?\<\/\\1\>/is", "_ws_plugin__s2member_force_non_ssl_buffer_callback", $buffer) : $buffer;
157
- $buffer = ($non_ssl_attr_only_tags) ? preg_replace_callback("/\<(".implode("|", c_ws_plugin__s2member_utils_strings::preg_quote_deep($non_ssl_attr_only_tags, "/")).")(?![a-z_0-9\-])[^\>]+?\>/i", "_ws_plugin__s2member_force_non_ssl_buffer_callback", $buffer) : $buffer;
158
-
159
- @ini_set /* Restore original PCRE backtrack limit. This just keeps things tidy; probably NOT necessary. */("pcre.backtrack_limit", $o_pcre);
160
-
161
- return apply_filters("_ws_plugin__s2member_force_ssl_buffer", $buffer, get_defined_vars());
162
- }
163
- }
164
-
165
- ob_start("_ws_plugin__s2member_force_ssl_buffer");
166
- }
167
- return /* Return for uniformity. */;
168
  }
 
 
169
  }
 
170
  }
171
- ?>
1
  <?php
2
  /**
3
+ * SSL routines (inner processing routines).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\SSL
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_ssl_in'))
21
+ {
22
+ /**
23
+ * SSL routines (inner processing routines).
24
+ *
25
+ * @package s2Member\SSL
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_ssl_in
29
  {
30
  /**
31
+ * Forces SSL on specific Posts/Pages, or any page for that matter.
32
+ *
33
+ * Triggered by Custom Field: `s2member_force_ssl = yes|port#`
34
+ *
35
+ * Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`.
36
+ *
37
+ * @package s2Member\SSL
38
+ * @since 3.5
39
+ *
40
+ * @attaches-to ``add_action('init');``
41
+ * @also-attaches-to ``add_action('wp');``
42
+ *
43
+ * @param array $vars From: ``c_ws_plugin__s2member_ssl::check_force_ssl()``.
44
+ *
45
+ * @return null Possibly exiting script execution after redirection to SSL variation.
46
+ *
47
+ * @todo Add `form` to the array ``$non_ssl_attr_only_tags``?
48
+ * @todo Cleanup this routine and convert callback functions to static class methods?
49
+ */
50
+ public static function force_ssl($vars = array()) // Phase 2 of ``c_ws_plugin__s2member_ssl::check_force_ssl()``.
51
+ {
52
+ /**
53
+ * @var string $s2_ssl_gv Extracted variable.
54
+ * @var string|integer|mixed $force_ssl Extracted variable.
55
+ */
56
+ extract($vars); // From: ``c_ws_plugin__s2member_ssl::check_force_ssl()``.
57
+
58
+ $force_ssl = !is_string($force_ssl) ? (string)(int)$force_ssl : $force_ssl;
59
+ $force_ssl = is_numeric($force_ssl) && $force_ssl > 1 ? $force_ssl : 'yes';
60
+
61
+ $ssl_host = preg_replace('/\:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
62
+ $ssl_port = (is_numeric($force_ssl) && $force_ssl > 1) ? $force_ssl : FALSE;
63
+ $ssl_host_port = $ssl_host.(($ssl_port) ? ':'.$ssl_port : '');
64
+
65
+ if(!is_ssl() || !isset($_GET[$s2_ssl_gv]))
66
  {
67
+ $https = 'https://'.$ssl_host_port.$_SERVER['REQUEST_URI'];
68
+ $https_with_s2_ssl_gv = add_query_arg($s2_ssl_gv, urlencode($force_ssl), $https);
69
+ wp_redirect($https_with_s2_ssl_gv).exit();
70
+ }
71
+ else // Otherwise, we buffer all output, and switch all content over to `https`.
72
+ // Assume here that other links on the site should NOT be converted to `https`.
73
+ {
74
+ add_filter('redirect_canonical', '__return_false');
75
+
76
+ define('_ws_plugin__s2member_force_ssl_host', $ssl_host);
77
+ define('_ws_plugin__s2member_force_ssl_port', $ssl_port);
78
+ define('_ws_plugin__s2member_force_ssl_host_port', $ssl_host_port);
79
+
80
+ // Filter these. Do NOT create a sitewide conversion to `https`.
81
+ add_filter('home_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 3);
82
+ add_filter('network_home_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 3);
83
+
84
+ // Filter these. Do NOT create a sitewide conversion to `https`.
85
+ add_filter('site_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 3);
86
+ add_filter('network_site_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 3);
87
+
88
+ // These additional URLs are NOT Filtered by default; but can be if needed. Use these Filters.
89
+ if(apply_filters('_ws_plugin__s2member_force_non_ssl_scheme_plugins_url', FALSE, get_defined_vars()))
90
+ add_filter('plugins_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 2);
91
+
92
+ // These additional URLs are NOT Filtered by default; but can be if needed. Use these Filters.
93
+ if(apply_filters('_ws_plugin__s2member_force_non_ssl_scheme_content_url', FALSE, get_defined_vars()))
94
+ add_filter('content_url', '_ws_plugin__s2member_force_non_ssl_scheme', 10, 2);
95
+
96
+ // Now we create various callback functions associated with SSL and non-SSL buffering.
97
+ if(!function_exists('_ws_plugin__s2member_force_ssl_buffer_callback'))
98
+ {
99
+ function _ws_plugin__s2member_force_ssl_buffer_callback($m = FALSE)
100
+ {
101
+ $s = preg_replace('/http\:\/\//i', 'https://', $m[0]);
102
+ if(_ws_plugin__s2member_force_ssl_host && _ws_plugin__s2member_force_ssl_port && _ws_plugin__s2member_force_ssl_host_port)
103
+ $s = preg_replace('/(?:https?\:)?\/\/'.preg_quote(_ws_plugin__s2member_force_ssl_host, '/').'(?:\:[0-9]+)?/i', 'https://'._ws_plugin__s2member_force_ssl_host_port, $s);
104
+ $s = (strtolower($m[1]) === 'link' && preg_match('/(["\'])(?:alternate|profile|pingback|EditURI|wlwmanifest|prev|next)\\1/i', $m[0])) ? $m[0] : $s;
105
+
106
+ return $s; // Return string with conversions.
107
+ }
108
+ }
109
+ if(!function_exists('_ws_plugin__s2member_force_non_ssl_buffer_callback'))
110
+ {
111
+ function _ws_plugin__s2member_force_non_ssl_buffer_callback($m = FALSE)
112
  {
113
+ $s = preg_replace('/(?:https?\:)?\/\/'.preg_quote(_ws_plugin__s2member_force_ssl_host_port, '/').'/i', 'http://'._ws_plugin__s2member_force_ssl_host, $m[0]);
114
+ $s = preg_replace('/(?:https?\:)?\/\/'.preg_quote(_ws_plugin__s2member_force_ssl_host, '/').'/i', 'http://'._ws_plugin__s2member_force_ssl_host, $s);
115
+
116
+ return $s; // Return string with conversions.
117
+ }
118
+ }
119
+ if(!function_exists('_ws_plugin__s2member_force_non_ssl_scheme'))
120
+ {
121
+ function _ws_plugin__s2member_force_non_ssl_scheme($url = FALSE, $path = FALSE, $scheme = FALSE)
122
+ {
123
+ if($scheme === 'relative')
124
+ return $url; // Nothing to do in this case.
125
+
126
+ if(!in_array($scheme, array('http', 'https'), TRUE)) // If NOT explicitly passed through.
127
+ {
128
+ if(($scheme === 'login_post' || $scheme === 'rpc') && (force_ssl_login() || force_ssl_admin()))
129
+ $scheme = 'https';
130
+
131
+ else if(($scheme === 'login' || $scheme === 'admin') && force_ssl_admin())
132
+ $scheme = 'https';
133
+
134
+ else $scheme = 'http'; // Default to non-SSL: `http`.
135
+ }
136
+ return preg_replace('/^(?:https?\:)?\/\//i', $scheme.'://', $url);
137
+ }
138
+ }
139
+ if(!function_exists('_ws_plugin__s2member_force_ssl_buffer'))
140
+ {
141
+ function _ws_plugin__s2member_force_ssl_buffer($buffer = FALSE)
142
+ {
143
+ $o_pcre = @ini_get('pcre.backtrack_limit'); // Record existing backtrack limit.
144
+ @ini_set('pcre.backtrack_limit', 10000000); // Increase PCRE backtrack limit for this routine.
145
+
146
+ $ssl_entire_tags = array_unique(array_map('strtolower', apply_filters('_ws_plugin__s2member_force_ssl_buffer_entire_tags', array('script', 'style', 'iframe', 'object', 'embed', 'video'), get_defined_vars())));
147
+ $non_ssl_entire_tags = array_unique(array_map('strtolower', apply_filters('_ws_plugin__s2member_force_non_ssl_buffer_entire_tags', array(), get_defined_vars())));
148
+
149
+ $ssl_attr_only_tags = array_unique(array_diff(array_map('strtolower', apply_filters('_ws_plugin__s2member_force_ssl_buffer_attr_only_tags', array('link', 'img', 'input'), get_defined_vars())), $ssl_entire_tags));
150
+ $non_ssl_attr_only_tags = array_unique(array_diff(array_map('strtolower', apply_filters('_ws_plugin__s2member_force_non_ssl_buffer_attr_only_tags', array('a'), get_defined_vars())), $non_ssl_entire_tags));
151
+
152
+ $buffer = ($ssl_entire_tags) ? preg_replace_callback('/\<('.implode('|', c_ws_plugin__s2member_utils_strings::preg_quote_deep($ssl_entire_tags, '/')).')(?![a-z_0-9\-])[^\>]*?\>.*?\<\/\\1\>/is', '_ws_plugin__s2member_force_ssl_buffer_callback', $buffer) : $buffer;
153
+ $buffer = ($ssl_attr_only_tags) ? preg_replace_callback('/\<('.implode('|', c_ws_plugin__s2member_utils_strings::preg_quote_deep($ssl_attr_only_tags, '/')).')(?![a-z_0-9\-])[^\>]+?\>/i', '_ws_plugin__s2member_force_ssl_buffer_callback', $buffer) : $buffer;
154
+
155
+ $buffer = ($non_ssl_entire_tags) ? preg_replace_callback('/\<('.implode('|', c_ws_plugin__s2member_utils_strings::preg_quote_deep($non_ssl_entire_tags, '/')).')(?![a-z_0-9\-])[^\>]*?\>.*?\<\/\\1\>/is', '_ws_plugin__s2member_force_non_ssl_buffer_callback', $buffer) : $buffer;
156
+ $buffer = ($non_ssl_attr_only_tags) ? preg_replace_callback('/\<('.implode('|', c_ws_plugin__s2member_utils_strings::preg_quote_deep($non_ssl_attr_only_tags, '/')).')(?![a-z_0-9\-])[^\>]+?\>/i', '_ws_plugin__s2member_force_non_ssl_buffer_callback', $buffer) : $buffer;
157
+
158
+ @ini_set('pcre.backtrack_limit', $o_pcre); // Restore original PCRE backtrack limit. This just keeps things tidy; probably NOT necessary.
159
+
160
+ return apply_filters('_ws_plugin__s2member_force_ssl_buffer', $buffer, get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
+ }
163
+ ob_start('_ws_plugin__s2member_force_ssl_buffer');
164
  }
165
+ }
166
  }
167
+ }
includes/classes/ssl.inc.php CHANGED
@@ -1,70 +1,66 @@
1
  <?php
2
  /**
3
- * SSL routines.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\SSL
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_ssl"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * SSL routines.
24
- *
25
- * @package s2Member\SSL
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_ssl
29
- {
30
- /**
31
- * Forces SSL on specific Posts/Pages, or any page for that matter.
32
- *
33
- * Triggered by Custom Field: `s2member_force_ssl = yes|port#`
34
- *
35
- * Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`.
36
- *
37
- * @package s2Member\SSL
38
- * @since 3.5
39
- *
40
- * @attaches-to ``add_action("init");``
41
- * @also-attaches-to ``add_action("wp");``
42
- *
43
- * @return null Possibly exiting script execution after redirection to SSL variation.
44
- */
45
- public static function check_force_ssl ()
46
- {
47
- static $forced = false; // Only force SSL once.
48
- global $post; // We need this global reference to ``$post``.
49
-
50
- do_action("ws_plugin__s2member_before_check_force_ssl", get_defined_vars ());
51
 
52
- if (!$forced) // Only force SSL here once. We definitely do NOT need to run this particular routine more than ONE time.
53
- if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page () /* NOT on WordPress Systematics. */)
54
- {
55
- $s2_ssl_gv = apply_filters("ws_plugin__s2member_check_force_ssl_get_var_name", "s2-ssl", get_defined_vars ());
56
- $_g_s2_ssl = (isset ($_GET[$s2_ssl_gv]) && (!strlen ($_GET[$s2_ssl_gv]) || !preg_match ("/^(0|no|off|false)$/i", $_GET[$s2_ssl_gv]))) ? ((!strlen ($_GET[$s2_ssl_gv])) ? true : $_GET[$s2_ssl_gv]) : false;
57
- $force_ssl = apply_filters("ws_plugin__s2member_check_force_ssl", $_g_s2_ssl, get_defined_vars ());
58
 
59
- if ($force_ssl || ( /* Conditionals will work? */did_action ("wp") && is_singular () && is_object ($post) && ($force_ssl = get_post_meta ($post->ID, "s2member_force_ssl", true))))
60
- if (!preg_match ("/^(0|no|off|false)$/i", (string)$force_ssl) && ($forced = true)) // Make sure it's NOT a negative variation.
61
- c_ws_plugin__s2member_ssl_in::force_ssl (get_defined_vars ()); // Call inner routine now.
62
- }
63
-
64
- do_action("ws_plugin__s2member_after_check_force_ssl", get_defined_vars ());
65
 
66
- return /* Return for uniformity. */;
67
- }
 
68
  }
 
 
69
  }
70
- ?>
1
  <?php
2
  /**
3
+ * SSL routines.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\SSL
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_ssl'))
21
+ {
22
+ /**
23
+ * SSL routines.
24
+ *
25
+ * @package s2Member\SSL
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_ssl
29
  {
30
  /**
31
+ * Forces SSL on specific Posts/Pages, or any page for that matter.
32
+ *
33
+ * Triggered by Custom Field: `s2member_force_ssl = yes|port#`
34
+ *
35
+ * Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`.
36
+ *
37
+ * @package s2Member\SSL
38
+ * @since 3.5
39
+ *
40
+ * @attaches-to ``add_action('init');``
41
+ * @also-attaches-to ``add_action('wp');``
42
+ *
43
+ * @return null Possibly exiting script execution after redirection to SSL variation.
44
+ */
45
+ public static function check_force_ssl()
46
+ {
47
+ static $forced = FALSE; // Only force SSL once.
48
+ global $post; // We need this global reference to ``$post``.
 
 
 
 
 
 
 
 
 
 
49
 
50
+ do_action('ws_plugin__s2member_before_check_force_ssl', get_defined_vars());
 
 
 
 
 
51
 
52
+ if(!$forced && !c_ws_plugin__s2member_systematics::is_wp_systematic_use_page())
53
+ {
54
+ $s2_ssl_gv = apply_filters('ws_plugin__s2member_check_force_ssl_get_var_name', 's2-ssl', get_defined_vars());
55
+ $_g_s2_ssl = isset($_GET[$s2_ssl_gv]) && (!strlen($_GET[$s2_ssl_gv]) || !preg_match('/^(0|no|off|false)$/i', $_GET[$s2_ssl_gv]))
56
+ ? (!strlen($_GET[$s2_ssl_gv]) ? TRUE : $_GET[$s2_ssl_gv]) : FALSE;
57
+ $force_ssl = apply_filters('ws_plugin__s2member_check_force_ssl', $_g_s2_ssl, get_defined_vars());
58
 
59
+ if($force_ssl || (did_action('wp') && is_singular() && is_object($post) && ($force_ssl = get_post_meta($post->ID, 's2member_force_ssl', TRUE))))
60
+ if(!preg_match('/^(0|no|off|false)$/i', (string)$force_ssl) && ($forced = TRUE)) // Make sure it's NOT a negative variation.
61
+ c_ws_plugin__s2member_ssl_in::force_ssl(get_defined_vars()); // Call inner routine now.
62
  }
63
+ do_action('ws_plugin__s2member_after_check_force_ssl', get_defined_vars());
64
+ }
65
  }
66
+ }
includes/classes/systematics-sp.inc.php CHANGED
@@ -1,135 +1,128 @@
1
  <?php
2
  /**
3
- * Systematics *(for a specific 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\Systematics
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_systematics_sp"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Systematics *(for a specific page)*.
24
- *
25
- * @package s2Member\Systematics
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_systematics_sp
29
- {
30
- /**
31
- * Determines if a specific Post/Page ID, or URI, is s2Member Systematic.
32
- *
33
- * @package s2Member\Systematics
34
- * @since 111115
35
- *
36
- * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
37
- * @param string $uri Optional. A request URI to test against.
38
- * @return bool True if s2Member Systematic, else false.
39
- */
40
- public static function is_s2_systematic_use_specific_page ($singular_id = FALSE, $uri = FALSE)
41
- {
42
- $singular_id = ($singular_id && is_numeric ($singular_id)) ? (int)$singular_id : false; // Force types.
43
- $uri = ($uri && is_string ($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri ($uri))) ? $uri : false;
44
-
45
- if ($uri && ($_q = c_ws_plugin__s2member_utils_urls::parse_url ($uri, PHP_URL_QUERY)) && preg_match ("/[\?&]s2member/", $_q) && c_ws_plugin__s2member_utils_conds::is_site_root ($uri))
46
- {
47
- return ($is_s2_systematic = apply_filters("ws_plugin__s2member_is_s2_systematic_use_specific_page", true, get_defined_vars ()));
48
- }
49
- else // Otherwise, we return false (i.e. it's NOT an s2Member Systematic Use Page).
50
- return ($is_s2_systematic = apply_filters("ws_plugin__s2member_is_s2_systematic_use_specific_page", false, get_defined_vars ()));
51
- }
52
- /**
53
- * Determines if a specific Post/Page ID, or URI, is WordPress Systematic.
54
- *
55
- * @package s2Member\Systematics
56
- * @since 111002
57
- *
58
- * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
59
- * @param string $uri Optional. A request URI to test against.
60
- * @return bool True if WordPress Systematic, else false.
61
- */
62
- public static function is_wp_systematic_use_specific_page ($singular_id = FALSE, $uri = FALSE)
63
- {
64
- $singular_id = ($singular_id && is_numeric ($singular_id)) ? (int)$singular_id : false; // Force types.
65
- $uri = ($uri && is_string ($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri ($uri))) ? $uri : false;
66
-
67
- if ($uri && preg_match ("/\/wp-admin(?:\/|\?|$)/", $uri)) // Inside a WordPress administrative area?
68
- {
69
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", true, get_defined_vars ()));
70
- }
71
- else if ($uri && preg_match ("/^\/(?:wp-.+?|xmlrpc)\.php$/", c_ws_plugin__s2member_utils_urls::parse_url ($uri, PHP_URL_PATH)))
72
- {
73
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", true, get_defined_vars ()));
74
- }
75
- else // Otherwise, we return false (i.e. it's NOT a WordPress Systematic Use Page).
76
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_specific_page", false, get_defined_vars ()));
77
- }
78
- /**
79
- * Determines if a specific Post/Page ID, or URI, is Systematic in any way.
80
- *
81
- * @package s2Member\Systematics
82
- * @since 3.5
83
- *
84
- * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
85
- * @param string $uri Optional. A request URI to test against.
86
- * @return bool True if Systematic, else false.
87
- *
88
- * @todo Test URIs against formulated links for Systematic Pages like the Membership Options Page?
89
- * Don't think this is required though; as it's already handled in other areas, correct?
90
- */
91
- public static function is_systematic_use_specific_page ($singular_id = FALSE, $uri = FALSE)
92
- {
93
- global $bp; // If BuddyPress is installed, we'll need this global reference.
94
-
95
- $singular_id = ($singular_id && is_numeric ($singular_id)) ? (int)$singular_id : false; // Force types.
96
- $uri = ($uri && is_string ($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri ($uri))) ? $uri : false;
97
-
98
- if (c_ws_plugin__s2member_systematics_sp::is_s2_systematic_use_specific_page /* An s2Member Systematic Use Page? */ ($singular_id, $uri))
99
- {
100
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
101
- }
102
- else if (c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page /* A WordPress Systematic Use Page? */ ($singular_id, $uri))
103
- {
104
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
105
- }
106
- else if ($uri && c_ws_plugin__s2member_utils_conds::bp_is_installed () && preg_match ("/\/(?:" . preg_quote (trim (((function_exists ("bp_get_signup_slug")) ? bp_get_signup_slug () : BP_REGISTER_SLUG), "/"), "/") . "|" . preg_quote (trim (((function_exists ("bp_get_activate_slug")) ? bp_get_activate_slug () : BP_ACTIVATION_SLUG), "/"), "/") . ")(?:\/|\?|$)/", $uri))
107
- {
108
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
109
- }
110
- else if ($singular_id && c_ws_plugin__s2member_utils_conds::bp_is_installed () && ((!empty($bp->pages->register->id) && $singular_id === (int)$bp->pages->register->id) || (!empty($bp->pages->activate->id) && $singular_id === (int)$bp->pages->activate->id)))
111
- {
112
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
113
- }
114
- else if ($singular_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $singular_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
115
- {
116
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
117
- }
118
- else if ($singular_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && $singular_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
119
- {
120
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
121
- }
122
- else if ($singular_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $singular_id === (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
123
- {
124
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
125
- }
126
- else if ($uri && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri (false, "root-returns-false")) && preg_match ("/^" . preg_quote ($_lro, "/") . "$/", $uri))
127
- {
128
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
129
- }
130
- else // Otherwise, we return false (i.e. it's NOT a Systematic Use Page in any way).
131
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_specific_page", false, get_defined_vars ()));
132
- }
133
- }
134
  }
135
- ?>
1
  <?php
2
  /**
3
+ * Systematics *(for a specific 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\Systematics
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_systematics_sp'))
21
+ {
22
+ /**
23
+ * Systematics *(for a specific page)*.
24
+ *
25
+ * @package s2Member\Systematics
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_systematics_sp
29
  {
30
  /**
31
+ * Determines if a specific Post/Page ID, or URI, is s2Member Systematic.
32
+ *
33
+ * @package s2Member\Systematics
34
+ * @since 111115
35
+ *
36
+ * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
37
+ * @param string $uri Optional. A request URI to test against.
38
+ *
39
+ * @return bool True if s2Member Systematic, else false.
40
+ */
41
+ public static function is_s2_systematic_use_specific_page($singular_id = '', $uri = '')
42
+ {
43
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
44
+ $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
45
+ $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
46
+
47
+ if($uri && ($_q = c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_QUERY)) && preg_match('/[\?&]s2member/'.$ci, $_q) && c_ws_plugin__s2member_utils_conds::is_site_root($uri))
48
+ return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_specific_page', TRUE, get_defined_vars()));
49
+
50
+ return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_specific_page', FALSE, get_defined_vars()));
51
+ }
52
+
53
+ /**
54
+ * Determines if a specific Post/Page ID, or URI, is WordPress Systematic.
55
+ *
56
+ * @package s2Member\Systematics
57
+ * @since 111002
58
+ *
59
+ * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
60
+ * @param string $uri Optional. A request URI to test against.
61
+ *
62
+ * @return bool True if WordPress Systematic, else false.
63
+ */
64
+ public static function is_wp_systematic_use_specific_page($singular_id = '', $uri = '')
65
+ {
66
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
67
+ $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
68
+ $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
69
+
70
+ if($uri && preg_match('/\/wp-admin(?:\/|\?|$)/'.$ci, $uri)) // Inside a WordPress administrative area?
71
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars()));
72
+
73
+ if($uri && preg_match('/^\/(?:wp-.+?|xmlrpc)\.php$/'.$ci, c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_PATH)))
74
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars()));
75
+
76
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', FALSE, get_defined_vars()));
77
+ }
78
+
79
+ /**
80
+ * Determines if a specific Post/Page ID, or URI, is Systematic in any way.
81
+ *
82
+ * @package s2Member\Systematics
83
+ * @since 3.5
84
+ *
85
+ * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
86
+ * @param string $uri Optional. A request URI to test against.
87
+ *
88
+ * @return bool True if Systematic, else false.
89
+ *
90
+ * @todo Test URIs against formulated links for Systematic Pages like the Membership Options Page?
91
+ * Don't think this is required though; as it's already handled in other areas, correct?
92
+ */
93
+ public static function is_systematic_use_specific_page($singular_id = '', $uri = '')
94
+ {
95
+ global $bp; // If BuddyPress is installed, we'll need this global reference.
96
+
97
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
98
+ $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
99
+ $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
100
+
101
+ if(c_ws_plugin__s2member_systematics_sp::is_s2_systematic_use_specific_page($singular_id, $uri))
102
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
103
+
104
+ if(c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($singular_id, $uri))
105
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
106
+
107
+ if($uri && c_ws_plugin__s2member_utils_conds::bp_is_installed() && preg_match('/\/(?:'.preg_quote(trim(((function_exists('bp_get_signup_slug')) ? bp_get_signup_slug() : BP_REGISTER_SLUG), '/'), '/').'|'.preg_quote(trim(((function_exists('bp_get_activate_slug')) ? bp_get_activate_slug() : BP_ACTIVATION_SLUG), '/'), '/').')(?:\/|\?|$)/'.$ci, $uri))
108
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
109
+
110
+ if($singular_id && c_ws_plugin__s2member_utils_conds::bp_is_installed() && ((!empty($bp->pages->register->id) && $singular_id === (int)$bp->pages->register->id) || (!empty($bp->pages->activate->id) && $singular_id === (int)$bp->pages->activate->id)))
111
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
112
+
113
+ if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'])
114
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
115
+
116
+ if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
117
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
118
+
119
+ if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'])
120
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
121
+
122
+ if($uri && $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri(NULL, 'root-returns-false')) && preg_match('/^'.preg_quote($_lro, '/').'$/'.$ci, $uri))
123
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
124
+
125
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', FALSE, get_defined_vars()));
126
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
+ }
includes/classes/systematics.inc.php CHANGED
@@ -1,154 +1,141 @@
1
  <?php
2
  /**
3
- * Systematics *(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\Systematics
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_systematics"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Systematics *(for current page)*.
24
- *
25
- * @package s2Member\Systematics
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_systematics
29
- {
30
- /**
31
- * Determines if the current page is s2Member Systematic.
32
- *
33
- * @package s2Member\Systematics
34
- * @since 111115
35
- *
36
- * @return bool True if s2Member Systematic, else false.
37
- *
38
- * @note The results of this function are cached staticially.
39
- * Do NOT call upon this until the `init` Hook is fired.
40
- */
41
- public static function is_s2_systematic_use_page ()
42
- {
43
- static $is_s2_systematic; // For optimization.
44
-
45
- if (isset ($is_s2_systematic)) // Already cached statically? Saves time.
46
- {
47
- return $is_s2_systematic; // Filters will have already been applied here.
48
- }
49
- else if (!empty($_SERVER["QUERY_STRING"]) && preg_match ("/[\?&]s2member/", $_SERVER["QUERY_STRING"]) && c_ws_plugin__s2member_utils_conds::is_site_root ($_SERVER["REQUEST_URI"]))
50
- {
51
- return ($is_s2_systematic = apply_filters("ws_plugin__s2member_is_s2_systematic_use_page", true, get_defined_vars ()));
52
- }
53
- else // Otherwise, we return false (it's NOT an s2Member Systematic Use Page).
54
- return ($is_s2_systematic = apply_filters("ws_plugin__s2member_is_s2_systematic_use_page", false, get_defined_vars ()));
55
- }
56
- /**
57
- * Determines if the current page is WordPress Systematic.
58
- *
59
- * @package s2Member\Systematics
60
- * @since 111002
61
- *
62
- * @return bool True if WordPress Systematic, else false.
63
- *
64
- * @note The results of this function are cached staticially.
65
- * Do NOT call upon this until the `init` Hook is fired.
66
- */
67
- public static function is_wp_systematic_use_page ()
68
- {
69
- static $is_wp_systematic; // For optimization.
70
-
71
- if (isset ($is_wp_systematic)) // Already cached statically? Saves time.
72
- {
73
- return $is_wp_systematic; // Filters will have already been applied here.
74
- }
75
- else if (is_admin ()) // In the admin area? All administrational pages are considered Systematic.
76
- {
77
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
78
- }
79
- else if (defined ("WP_INSTALLING") && WP_INSTALLING) // Installing? All WordPress installs are considered Systematic.
80
- {
81
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
82
- }
83
- else if (defined ("APP_REQUEST") && APP_REQUEST) // App request? All WordPress app requests are considered Systematic.
84
- {
85
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
86
- }
87
- else if (defined ("XMLRPC_REQUEST") && XMLRPC_REQUEST) // An XML-RPC request? All of these are considered Systematic too.
88
- {
89
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
90
- }
91
- else if ((defined ("DOING_CRON") && DOING_CRON) || strcasecmp (PHP_SAPI, "CLI") === 0) // CLI or CRON job.
92
- {
93
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
94
- }
95
- else if (preg_match ("/^\/(?:wp-.+?|xmlrpc)\.php$/", c_ws_plugin__s2member_utils_urls::parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH)))
96
- {
97
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
98
- }
99
- else // Otherwise, we return false (it's NOT a WordPress Systematic Use Page).
100
- return ($is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", false, get_defined_vars ()));
101
- }
102
- /**
103
- * Determines if the current page is Systematic in any way.
104
- *
105
- * @package s2Member\Systematics
106
- * @since 3.5
107
- *
108
- * @return bool True if Systematic, else false.
109
- *
110
- * @note The results of this function are cached staticially.
111
- * Do NOT call upon this until the `wp` Hook is fired.
112
- */
113
- public static function is_systematic_use_page ()
114
- {
115
- static $is_systematic; // For optimization.
116
-
117
- if (isset ($is_systematic)) // Already cached statically? Saves time.
118
- {
119
- return $is_systematic; // Filters will have already been applied here.
120
- }
121
- else if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page /* An s2Member Systematic Use Page? */ ())
122
- {
123
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
124
- }
125
- else if (c_ws_plugin__s2member_systematics::is_wp_systematic_use_page /* A WordPress Systematic Use Page? */ ())
126
- {
127
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
128
- }
129
- else if (c_ws_plugin__s2member_utils_conds::bp_is_installed () && (bp_is_register_page () || bp_is_activation_page ()))
130
- {
131
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
132
- }
133
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]))
134
- {
135
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
136
- }
137
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
138
- {
139
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
140
- }
141
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))
142
- {
143
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
144
- }
145
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri (false, "root-returns-false")) && preg_match ("/^" . preg_quote ($_lro, "/") . "$/", $_SERVER["REQUEST_URI"]))
146
- {
147
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
148
- }
149
- else // Otherwise, we return false (it's NOT a Systematic Use Page in any way).
150
- return ($is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", false, get_defined_vars ()));
151
- }
152
- }
153
  }
154
- ?>
1
  <?php
2
  /**
3
+ * Systematics *(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\Systematics
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_systematics'))
21
+ {
22
+ /**
23
+ * Systematics *(for current page)*.
24
+ *
25
+ * @package s2Member\Systematics
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_systematics
29
  {
30
  /**
31
+ * Determines if the current page is s2Member Systematic.
32
+ *
33
+ * @package s2Member\Systematics
34
+ * @since 111115
35
+ *
36
+ * @return bool True if s2Member Systematic, else false.
37
+ *
38
+ * @note The results of this function are cached staticially.
39
+ * Do NOT call upon this until the `init` Hook is fired.
40
+ */
41
+ public static function is_s2_systematic_use_page()
42
+ {
43
+ static $is_s2_systematic; // For optimization.
44
+
45
+ if(isset($is_s2_systematic)) // Already cached statically? Saves time.
46
+ return $is_s2_systematic; // Filters will have already been applied here.
47
+
48
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
49
+
50
+ if(!empty($_SERVER['QUERY_STRING']) && preg_match('/[\?&]s2member/'.$ci, $_SERVER['QUERY_STRING']) && c_ws_plugin__s2member_utils_conds::is_site_root($_SERVER['REQUEST_URI']))
51
+ return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_page', TRUE, get_defined_vars()));
52
+
53
+ return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_page', FALSE, get_defined_vars()));
54
+ }
55
+
56
+ /**
57
+ * Determines if the current page is WordPress Systematic.
58
+ *
59
+ * @package s2Member\Systematics
60
+ * @since 111002
61
+ *
62
+ * @return bool True if WordPress Systematic, else false.
63
+ *
64
+ * @note The results of this function are cached staticially.
65
+ * Do NOT call upon this until the `init` Hook is fired.
66
+ */
67
+ public static function is_wp_systematic_use_page()
68
+ {
69
+ static $is_wp_systematic; // For optimization.
70
+
71
+ if(isset($is_wp_systematic)) // Already cached statically? Saves time.
72
+ return $is_wp_systematic; // Filters will have already been applied here.
73
+
74
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
75
+
76
+ if(is_admin()) // In the admin area? All administrational pages are considered Systematic.
77
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
78
+
79
+ if(defined('WP_INSTALLING') && WP_INSTALLING) // Installing? All WordPress installs are considered Systematic.
80
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
81
+
82
+ if(defined('APP_REQUEST') && APP_REQUEST) // App request? All WordPress app requests are considered Systematic.
83
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
84
+
85
+ if(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) // An XML-RPC request? All of these are considered Systematic too.
86
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
87
+
88
+ if((defined('DOING_CRON') && DOING_CRON) || strcasecmp(PHP_SAPI, 'CLI') === 0) // CLI or CRON job.
89
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
90
+
91
+ if(preg_match('/^\/(?:wp-.+?|xmlrpc)\.php$/'.$ci, c_ws_plugin__s2member_utils_urls::parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)))
92
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
93
+
94
+ return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', FALSE, get_defined_vars()));
95
+ }
96
+
97
+ /**
98
+ * Determines if the current page is Systematic in any way.
99
+ *
100
+ * @package s2Member\Systematics
101
+ * @since 3.5
102
+ *
103
+ * @return bool True if Systematic, else false.
104
+ *
105
+ * @note The results of this function are cached staticially.
106
+ * Do NOT call upon this until the `wp` Hook is fired.
107
+ */
108
+ public static function is_systematic_use_page()
109
+ {
110
+ static $is_systematic; // For optimization.
111
+
112
+ if(isset($is_systematic)) // Already cached statically? Saves time.
113
+ return $is_systematic; // Filters will have already been applied here.
114
+
115
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
116
+
117
+ if(c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) // An s2Member Systematic Use Page?
118
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
119
+
120
+ if(c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) //* A WordPress Systematic Use Page?
121
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
122
+
123
+ if(c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page()))
124
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
125
+
126
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']))
127
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
128
+
129
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']))
130
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
131
+
132
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page']))
133
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
134
+
135
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri(NULL, 'root-returns-false')) && preg_match('/^'.preg_quote($_lro, '/').'$/'.$ci, $_SERVER['REQUEST_URI']))
136
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
137
+
138
+ return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', FALSE, get_defined_vars()));
139
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
+ }
includes/classes/utils-conds.inc.php CHANGED
@@ -1,223 +1,244 @@
1
  <?php
2
  /**
3
- * Conditional utilities.
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Utilities
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_utils_conds"))
 
 
 
 
 
 
 
 
21
  {
22
  /**
23
- * Conditional utilities.
24
- *
25
- * @package s2Member\Utilities
26
- * @since 3.5
27
- */
28
- class c_ws_plugin__s2member_utils_conds
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  {
30
- /**
31
- * Determines whether or not s2Member Pro is installed.
32
- *
33
- * @package s2Member\Utilities
34
- * @since 110720
35
- *
36
- * @return bool True if s2Member Pro is installed, else false.
37
- */
38
- public static function pro_is_installed()
39
- {
40
- return (defined("WS_PLUGIN__S2MEMBER_PRO_VERSION") && did_action("ws_plugin__s2member_pro_loaded"));
41
- }
42
- /**
43
- * Determines whether or not bbPress is installed.
44
- *
45
- * @package s2Member\Utilities
46
- * @since 140807
47
- *
48
- * @param bool $query_active_plugins Optional. If true, this conditional will query active plugins too. Defaults to true if {@link s2Member\WS_PLUGIN__S2MEMBER_ONLY} is true, else false.
49
- * @return bool True if bbPress is installed, else false.
50
- */
51
- public static function bbp_is_installed($query_active_plugins = NULL)
52
- {
53
- if(function_exists('bbpress'))
54
- return true; // Quickest/easiest way to determine.
55
-
56
- $s2o = (defined("WS_PLUGIN__S2MEMBER_ONLY") && WS_PLUGIN__S2MEMBER_ONLY) ? true : false;
57
-
58
- if(($query_active_plugins = (!isset($query_active_plugins) && $s2o) ? true : $query_active_plugins))
59
- {
60
- $bbpress = "bbpress/bbpress.php"; // bbPress.
61
-
62
- $active_plugins = (is_multisite()) ? wp_get_active_network_plugins() : array();
63
- $active_plugins = array_unique(array_merge($active_plugins, wp_get_active_and_valid_plugins()));
64
-
65
- foreach($active_plugins as $active_plugin) // Search.
66
- if(plugin_basename($active_plugin) === $bbpress)
67
- return true; // bbPress active.
68
- }
69
- return false; // Default return false.
70
- }
71
- /**
72
- * Determines whether or not BuddyPress is installed.
73
- *
74
- * @package s2Member\Utilities
75
- * @since 110720
76
- *
77
- * @param bool $query_active_plugins Optional. If true, this conditional will query active plugins too. Defaults to true if {@link s2Member\WS_PLUGIN__S2MEMBER_ONLY} is true, else false.
78
- * @return bool True if BuddyPress is installed, else false.
79
- */
80
- public static function bp_is_installed($query_active_plugins = NULL)
81
- {
82
- if(defined("BP_VERSION") && did_action("bp_core_loaded"))
83
- return true; // Quickest/easiest way to determine.
84
-
85
- $s2o = (defined("WS_PLUGIN__S2MEMBER_ONLY") && WS_PLUGIN__S2MEMBER_ONLY) ? true : false;
86
-
87
- if(($query_active_plugins = (!isset($query_active_plugins) && $s2o) ? true : $query_active_plugins))
88
- {
89
- $buddypress = "buddypress/bp-loader.php"; // BuddyPress.
90
-
91
- $active_plugins = (is_multisite()) ? wp_get_active_network_plugins() : array();
92
- $active_plugins = array_unique(array_merge($active_plugins, wp_get_active_and_valid_plugins()));
93
-
94
- foreach($active_plugins as $active_plugin) // Search.
95
- if(plugin_basename($active_plugin) === $buddypress)
96
- return true; // BuddyPress active.
97
- }
98
- return false; // Default return false.
99
- }
100
- /**
101
- * Determines whether or not this is a Multisite Farm;
102
- * *( i.e. if ``MULTISITE_FARM == true`` inside `/wp-config.php` )*.
103
- *
104
- * With s2Member, this option may also indicate a Multisite Blog Farm.
105
- * ``$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup"``.
106
- *
107
- * @package s2Member\Utilities
108
- * @since 3.5
109
- *
110
- * @return bool True if this is a Multisite Farm, else false.
111
- */
112
- public static function is_multisite_farm()
113
- {
114
- return (is_multisite() && ((is_main_site() && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup") || (defined("MULTISITE_FARM") && MULTISITE_FARM)));
115
- }
116
- /**
117
- * Checks if a Post is in a child Category.
118
- *
119
- * @package s2Member\Utilities
120
- * @since 3.5
121
- *
122
- * @param array $cats An array of Category IDs.
123
- * @param int|string $post_id A numeric WordPress Post ID.
124
- * @return bool True if the Post is inside a desendant of at least one of the specified Categories; else false.
125
- */
126
- public static function in_descendant_category($cats = FALSE, $post_id = FALSE)
127
- {
128
- foreach((array)$cats as $cat)
129
- {
130
- $descendants = get_term_children((int)$cat, "category");
131
- if($descendants && in_category($descendants, $post_id))
132
- return true;
133
- }
134
- return false; // Default return false.
135
- }
136
- /**
137
- * Checks to see if a URL/URI leads to the site root.
138
- *
139
- * @package s2Member\Utilities
140
- * @since 3.5
141
- *
142
- * @param string $url_uri Either a full URL, or a partial URI to test.
143
- * @return bool True if the URL or URI leads to the site root, else false.
144
- */
145
- public static function is_site_root($url_uri = FALSE)
146
- {
147
- if(is_array($parse = c_ws_plugin__s2member_utils_urls::parse_url($url_uri)))
148
- {
149
- $parse["path"] = (!empty($parse["path"])) ? ((strpos($parse["path"], "/") === 0) ? $parse["path"] : "/".$parse["path"]) : "/";
150
-
151
- if(empty($parse["host"]) || strcasecmp($parse["host"], c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_HOST)) === 0)
152
- if($parse["path"] === "/" || rtrim($parse["path"], "/") === rtrim(c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_PATH), "/"))
153
- if(get_option("permalink_structure") || (empty($_GET["post_id"]) && empty($_GET["page_id"]) && empty($_GET["p"])))
154
- return true;
155
-
156
- if(empty($parse["host"]) || strcasecmp($parse["host"], c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) === 0)
157
- if($parse["path"] === "/" || rtrim($parse["path"], "/") === rtrim(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_PATH), "/"))
158
- if(get_option("permalink_structure") || (empty($_GET["post_id"]) && empty($_GET["page_id"]) && empty($_GET["p"])))
159
- return true;
160
- }
161
- return false; // Default return false.
162
- }
163
- /**
164
- * Checks to see if we're in a localhost environment.
165
- *
166
- * @package s2Member\Utilities
167
- * @since 111101
168
- *
169
- * @return bool True if we're in a localhost environment, else false.
170
- */
171
- public static function is_localhost()
172
- {
173
- if((defined("LOCALHOST") && LOCALHOST) || stripos($_SERVER["HTTP_HOST"], "localhost") !== false || strpos($_SERVER["HTTP_HOST"], "127.0.0.1") !== false)
174
- return true;
175
-
176
- return /* Default return false. */ false;
177
- }
178
- /**
179
- * Checks to see if we're using Amazon S3.
180
- *
181
- * @package s2Member\Utilities
182
- * @since 110926
183
- *
184
- * @return bool True if using Amazon S3, else false.
185
- */
186
- public static function using_amazon_s3_storage()
187
- {
188
- foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
189
- if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
190
- $s3c[$option] = $option_value;
191
-
192
- if(!empty($s3c["bucket"]) && !empty($s3c["access_key"]) && !empty($s3c["secret_key"]))
193
- return true;
194
-
195
- return /* Default return false. */ false;
196
- }
197
- /**
198
- * Checks to see if we're using Amazon CloudFront.
199
- *
200
- * @package s2Member\Utilities
201
- * @since 110926
202
- *
203
- * @return bool True if using Amazon CloudFront, else false.
204
- */
205
- public static function using_amazon_cf_storage()
206
- {
207
- foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
208
- if(preg_match("/^amazon_s3_files_/", $option) && ($option = preg_replace("/^amazon_s3_files_/", "", $option)))
209
- $s3c[$option] = $option_value;
210
-
211
- foreach($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
212
- if(preg_match("/^amazon_cf_files_/", $option) && ($option = preg_replace("/^amazon_cf_files_/", "", $option)))
213
- $cfc[$option] = $option_value;
214
-
215
- if(!empty($s3c["bucket"]) && !empty($s3c["access_key"]) && !empty($s3c["secret_key"]))
216
- if(!empty($cfc["private_key"]) && !empty($cfc["private_key_id"]) && !empty($cfc["distros_access_id"]) && !empty($cfc["distros_s3_access_id"]) && !empty($cfc["distro_downloads_id"]) && !empty($cfc["distro_downloads_dname"]) && !empty($cfc["distro_streaming_id"]) && !empty($cfc["distro_streaming_dname"]))
217
- return true;
218
-
219
- return /* Default return false. */ false;
220
- }
221
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  }
223
- ?>
1
  <?php
2
  /**
3
+ * Conditional utilities.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Utilities
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_utils_conds'))
21
+ {
22
+ /**
23
+ * Conditional utilities.
24
+ *
25
+ * @package s2Member\Utilities
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_utils_conds
29
  {
30
  /**
31
+ * Determines whether or not s2Member Pro is installed.
32
+ *
33
+ * @package s2Member\Utilities
34
+ * @since 110720
35
+ *
36
+ * @return bool True if s2Member Pro is installed, else false.
37
+ */
38
+ public static function pro_is_installed()
39
+ {
40
+ return (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION') && did_action('ws_plugin__s2member_pro_loaded'));
41
+ }
42
+
43
+ /**
44
+ * Determines whether or not bbPress is installed.
45
+ *
46
+ * @package s2Member\Utilities
47
+ * @since 140807
48
+ *
49
+ * @param bool $query_active_plugins Optional. If true, this conditional will query active plugins too.
50
+ * Defaults to true if {@link s2Member\WS_PLUGIN__S2MEMBER_ONLY} is true, else false.
51
+ *
52
+ * @return bool True if bbPress is installed, else false.
53
+ */
54
+ public static function bbp_is_installed($query_active_plugins = NULL)
55
+ {
56
+ if(function_exists('bbpress'))
57
+ return TRUE; // Quickest/easiest way to determine.
58
+
59
+ $s2o = (defined('WS_PLUGIN__S2MEMBER_ONLY') && WS_PLUGIN__S2MEMBER_ONLY) ? TRUE : FALSE;
60
+
61
+ if(($query_active_plugins = (!isset($query_active_plugins) && $s2o) ? TRUE : $query_active_plugins))
62
+ {
63
+ $bbpress = 'bbpress/bbpress.php'; // bbPress.
64
+
65
+ $active_plugins = (is_multisite()) ? wp_get_active_network_plugins() : array();
66
+ $active_plugins = array_unique(array_merge($active_plugins, wp_get_active_and_valid_plugins()));
67
+
68
+ foreach($active_plugins as $active_plugin) // Search.
69
+ if(plugin_basename($active_plugin) === $bbpress)
70
+ return TRUE; // bbPress active.
71
+ }
72
+ return FALSE; // Default return false.
73
+ }
74
+
75
+ /**
76
+ * Determines whether or not BuddyPress is installed.
77
+ *
78
+ * @package s2Member\Utilities
79
+ * @since 110720
80
+ *
81
+ * @param bool $query_active_plugins Optional. If true, this conditional will query active plugins too.
82
+ * Defaults to true if {@link s2Member\WS_PLUGIN__S2MEMBER_ONLY} is true, else false.
83
+ *
84
+ * @return bool True if BuddyPress is installed, else false.
85
+ */
86
+ public static function bp_is_installed($query_active_plugins = NULL)
87
+ {
88
+ if(defined('BP_VERSION') && did_action('bp_core_loaded'))
89
+ return TRUE; // Quickest/easiest way to determine.
90
+
91
+ $s2o = (defined('WS_PLUGIN__S2MEMBER_ONLY') && WS_PLUGIN__S2MEMBER_ONLY) ? TRUE : FALSE;
92
+
93
+ if(($query_active_plugins = (!isset($query_active_plugins) && $s2o) ? TRUE : $query_active_plugins))
94
+ {
95
+ $buddypress = 'buddypress/bp-loader.php'; // BuddyPress.
96
+
97
+ $active_plugins = (is_multisite()) ? wp_get_active_network_plugins() : array();
98
+ $active_plugins = array_unique(array_merge($active_plugins, wp_get_active_and_valid_plugins()));
99
+
100
+ foreach($active_plugins as $active_plugin) // Search.
101
+ if(plugin_basename($active_plugin) === $buddypress)
102
+ return TRUE; // BuddyPress active.
103
+ }
104
+ return FALSE; // Default return false.
105
+ }
106
+
107
+ /**
108
+ * Determines whether or not this is a Multisite Farm;
109
+ * *( i.e. if ``MULTISITE_FARM == true`` inside `/wp-config.php` )*.
110
+ *
111
+ * With s2Member, this option may also indicate a Multisite Blog Farm.
112
+ * ``$GLOBALS['WS_PLUGIN__']['s2member']['o']['mms_registration_file'] === 'wp-signup'``.
113
+ *
114
+ * @package s2Member\Utilities
115
+ * @since 3.5
116
+ *
117
+ * @return bool True if this is a Multisite Farm, else false.
118
+ */
119
+ public static function is_multisite_farm()
120
+ {
121
+ return is_multisite()
122
+ && ((is_main_site() && $GLOBALS['WS_PLUGIN__']['s2member']['o']['mms_registration_file'] === 'wp-signup')
123
+ || (defined('MULTISITE_FARM') && MULTISITE_FARM));
124
+ }
125
+
126
+ /**
127
+ * Checks if a Post is in a child Category.
128
+ *
129
+ * @package s2Member\Utilities
130
+ * @since 3.5
131
+ *
132
+ * @param array $cats An array of Category IDs.
133
+ * @param int|string $post_id A numeric WordPress Post ID.
134
+ *
135
+ * @return bool True if the Post is inside a desendant of at least one of the specified Categories; else false.
136
+ */
137
+ public static function in_descendant_category($cats = array(), $post_id = '')
138
+ {
139
+ foreach((array)$cats as $cat)
140
+ {
141
+ $descendants = get_term_children((int)$cat, 'category');
142
+ if($descendants && in_category($descendants, $post_id))
143
+ return TRUE;
144
+ }
145
+ return FALSE; // Default return false.
146
+ }
147
+
148
+ /**
149
+ * Checks to see if a URL/URI leads to the site root.
150
+ *
151
+ * @package s2Member\Utilities
152
+ * @since 3.5
153
+ *
154
+ * @param string $url_uri Either a full URL, or a partial URI to test.
155
+ *
156
+ * @return bool True if the URL or URI leads to the site root, else false.
157
+ */
158
+ public static function is_site_root($url_uri = '')
159
+ {
160
+ if(is_array($parse = c_ws_plugin__s2member_utils_urls::parse_url($url_uri)))
161
  {
162
+ $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
163
+ $parse['path'] = !empty($parse['path']) ? (strpos($parse['path'], '/') === 0 ? $parse['path'] : '/'.$parse['path']) : '/';
164
+ $parse['query'] = !empty($parse['query']) ? $parse['query'] : ''; // Has a query string?
165
+
166
+ if(empty($parse['host']) || strcasecmp($parse['host'], c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_HOST)) === 0)
167
+ if($parse['path'] === '/' || preg_match('/^'.preg_quote(rtrim($parse['path'], '/'), '/').'$/'.$ci, rtrim(c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_PATH), '/')))
168
+ if(get_option('permalink_structure') || (empty($_REQUEST['post_id']) && empty($_REQUEST['page_id']) && empty($_REQUEST['p']) && empty($_REQUEST['s'])))
169
+ return TRUE;
170
+
171
+ if(empty($parse['host']) || strcasecmp($parse['host'], c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) === 0)
172
+ if($parse['path'] === '/' || preg_match('/^'.preg_quote(rtrim($parse['path'], '/'), '/').'$/'.$ci, rtrim(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_PATH), '/')))
173
+ if(get_option('permalink_structure') || (empty($_REQUEST['post_id']) && empty($_REQUEST['page_id']) && empty($_REQUEST['p']) && empty($_REQUEST['s'])))
174
+ return TRUE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
+ return FALSE; // Default return false.
177
+ }
178
+
179
+ /**
180
+ * Checks to see if we're in a localhost environment.
181
+ *
182
+ * @package s2Member\Utilities
183
+ * @since 111101
184
+ *
185
+ * @return bool True if we're in a localhost environment, else false.
186
+ */
187
+ public static function is_localhost()
188
+ {
189
+ if((defined('LOCALHOST') && LOCALHOST)
190
+ || stripos($_SERVER['HTTP_HOST'], 'localhost') !== FALSE
191
+ || strpos($_SERVER['HTTP_HOST'], '127.0.0.1') !== FALSE
192
+ ) return TRUE;
193
+
194
+ return FALSE; // Default return false.
195
+ }
196
+
197
+ /**
198
+ * Checks to see if we're using Amazon S3.
199
+ *
200
+ * @package s2Member\Utilities
201
+ * @since 110926
202
+ *
203
+ * @return bool True if using Amazon S3, else false.
204
+ */
205
+ public static function using_amazon_s3_storage()
206
+ {
207
+ foreach($GLOBALS['WS_PLUGIN__']['s2member']['o'] as $option => $option_value)
208
+ if(preg_match('/^amazon_s3_files_/', $option) && ($option = preg_replace('/^amazon_s3_files_/', '', $option)))
209
+ $s3c[$option] = $option_value;
210
+
211
+ if(!empty($s3c['bucket']) && !empty($s3c['access_key']) && !empty($s3c['secret_key']))
212
+ return TRUE;
213
+
214
+ return FALSE; // Default return false.
215
+ }
216
+
217
+ /**
218
+ * Checks to see if we're using Amazon CloudFront.
219
+ *
220
+ * @package s2Member\Utilities
221
+ * @since 110926
222
+ *
223
+ * @return bool True if using Amazon CloudFront, else false.
224
+ */
225
+ public static function using_amazon_cf_storage()
226
+ {
227
+ foreach($GLOBALS['WS_PLUGIN__']['s2member']['o'] as $option => $option_value)
228
+ if(preg_match('/^amazon_s3_files_/', $option) && ($option = preg_replace('/^amazon_s3_files_/', '', $option)))
229
+ $s3c[$option] = $option_value;
230
+
231
+ foreach($GLOBALS['WS_PLUGIN__']['s2member']['o'] as $option => $option_value)
232
+ if(preg_match('/^amazon_cf_files_/', $option) && ($option = preg_replace('/^amazon_cf_files_/', '', $option)))
233
+ $cfc[$option] = $option_value;
234
+
235
+ if(!empty($s3c['bucket']) && !empty($s3c['access_key']) && !empty($s3c['secret_key']))
236
+ if(!empty($cfc['private_key']) && !empty($cfc['private_key_id']) && !empty($cfc['distros_access_id'])
237
+ && !empty($cfc['distros_s3_access_id']) && !empty($cfc['distro_downloads_id']) && !empty($cfc['distro_downloads_dname'])
238
+ && !empty($cfc['distro_streaming_id']) && !empty($cfc['distro_streaming_dname'])
239
+ ) return TRUE;
240
+
241
+ return FALSE; // Default return false.
242
+ }
243
  }
244
+ }
includes/classes/utils-logs.inc.php CHANGED
@@ -28,202 +28,222 @@ if(!class_exists('c_ws_plugin__s2member_utils_logs'))
28
  class c_ws_plugin__s2member_utils_logs
29
  {
30
  /**
31
- * Array of log file descriptions.
32
  *
 
33
  * @package s2Member\Utilities
34
- * @since 120214
35
  *
36
- * @var array Array of log file descriptions.
 
 
 
37
  */
38
- public static $log_file_descriptions = array
39
- ( // Array keys are regex patterns matching their associated log file names.
40
- '/paypal\-api/' => array('short' => 'PayPal API communication.', 'long' => 'This log file records all communication between s2Member and PayPal APIs. Such as PayPal Button Encryption and PayPal Pro API calls that process transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
41
- '/paypal\-payflow\-api/' => array('short' => 'PayPal (PayFlow Edition) API communication.', 'long' => 'This log file records all communication between s2Member and the PayPal (PayFlow Edition) APIs. Only applicable if you operate a PayPal Payments Pro (PayFlow Edition) account. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
42
- '/gateway\-core\-ipn/' => array('short' => 'Core PayPal IPN and post-processing handler.', 'long' => 'This log file records all communication between s2Member and the PayPal IPN service. Also logs all post-processing routines from other Payment Gateway integrations, where s2Member translates its communication with other Payment Gateways into a format it\'s core PayPal processing routines can understand. All transactions pass through s2Member\'s core PayPal processor and they will be logged in this file. Including transactions processed via s2Member Pro Forms; for all Payment Gateway integrations.'),
43
- '/gateway\-core\-rtn/' => array('short' => 'Core PayPal PDT/Auto-Return communication.', 'long' => 'This log file records all communication between s2Member and the PayPal PDT Auto-Return system (i.e. routines that help s2Member process Thank-You pages). Also logs all Auto-Return routines from other Payment Gateway integrations (those implemented via Payment Buttons), where s2Member translates its communication with other Payment Gateways into a format it\'s core PayPal processing routines can understand. Not used in s2Member Pro Form integrations however.'),
44
 
45
- '/stripe\-api/' => array('short' => 'Stripe API communication.', 'long' => 'This log file records all communication between s2Member and Stripe APIs.'),
46
- '/stripe\-ipn/' => array('short' => 'Stripe Webhook/IPN communication.', 'long' => 'This log file records the Webhook/IPN data that Stripe sends to s2Member.'),
47
 
48
- '/authnet\-api/' => array('short' => 'Authorize.Net API communication.', 'long' => 'This log file records all communication between s2Member and Authorize.Net APIs (for both AIM and ARB integrations).'),
49
- '/authnet\-arb/' => array('short' => 'Authorize.Net ARB Subscription status checks.', 'long' => 'This log file records s2Member\'s Authorize.Net ARB Subscription status checks. s2Member polls the ARB service periodically to check the status of existing Members (e.g. to see if billing is still active or not).'),
50
- '/authnet\-ipn/' => array('short' => 'Authorize.Net Silent Post/IPN communication.', 'long' => 'This log file records the Silent Post/IPN data Authorize.Net sends to s2Member with details regarding new transactions.'),
51
 
52
- '/alipay\-ipn/' => array('short' => 'AliPay IPN communication.', 'long' => 'This log file records the IPN data AliPay sends to s2Member with details regarding new transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
53
- '/alipay\-rtn/' => array('short' => 'AliPay Auto-Return communication.', 'long' => 'This log file records the Auto-Return data AliPay sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
54
 
55
- '/clickbank\-ipn/' => array('short' => 'ClickBank IPN communication.', 'long' => 'This log file records the IPN data ClickBank sends to s2Member with details regarding new transactions, cancellations, expirations, etc. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
56
- '/clickbank\-rtn/' => array('short' => 'ClickBank Auto-Return communication.', 'long' => 'This log file records the Auto-Return data ClickBank sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
57
 
58
- '/google\-rtn/' => array('short' => 'Google Auto-Return communication.', 'long' => 'This log file records the Auto-Return data Google sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor). NOTE (regarding Google Wallet)... this particular log file is currently implemented for a possible future use ONLY. At this time there is no need for an Auto-Return handler with Google Wallet, because Google Wallet return handling is done via email-only at this time.'),
59
- '/google\-ipn/' => array('short' => 'Google Postback/IPN communication.', 'long' => 'This log file records the Postback/IPN data Google sends to s2Member with details regarding new transactions, cancellations, expirations, etc. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
 
60
 
61
- '/ccbill\-ipn/' => array('short' => 'ccBill Bg Post/IPN communication.', 'long' => 'This log file records the Bg Post/IPN data ccBill sends to s2Member with details regarding new transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
62
- '/ccbill\-rtn/' => array('short' => 'ccBill Auto-Return communication.', 'long' => 'This log file records the Auto-Return data ccBill sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
63
- '/ccbill\-dl\-ipn/' => array('short' => 'ccBill Datalink Subscription status checks.', 'long' => 'This log file records s2Member\'s ccBill Datalink Subscription status checks that may result in actions taken by s2Member. s2Member polls the ccBill Datalink service periodically to check the status of existing Members (e.g. to see if billing is still active or not).'),
64
- '/ccbill\-dl/' => array('short' => 'ccBill Datalink collections.', 'long' => 'This log file records s2Member\'s ccBill Datalink connections. s2Member polls the ccBill Datalink service periodically to obtain information about existing Users/Members.'),
 
65
 
66
- '/mailchimp\-api/' => array('short' => 'MailChimp API communication.', 'long' => 'This log file records all of s2Member\'s communication with MailChimp APIs.'),
67
- '/aweber\-api/' => array('short' => 'AWeber API communication.', 'long' => 'This log file records all of s2Member\'s communication with AWeber APIs.'),
 
68
 
69
- '/reg\-handler/' => array('short' => 'User registrations processed by s2Member.', 'long' => 'This log file records all User/Member registrations processed by s2Member (either directly or indirectly). This includes both free and paid registrations. It also logs registrations that occur as a result of new Users/Members being created from the Dashboard by a site owner. It also includes registrations that occur through the s2Member Pro Remote Operations API.'),
70
 
71
- '/s2\-http\-api\-debug/' => array('short' => 'All outgoing HTTP connections related to s2Member.', 'long' => 'This log file records all outgoing WP_Http connections that are specifically related to s2Member. This log file can be extremely helpful. It includes technical details about remote HTTP connections that are not available in other log files.'),
72
- '/wp\-http\-api\-debug/' => array('short' => 'All outgoing WordPress HTTP connections.', 'long' => 'This log file records all outgoing HTTP connections processed by the WP_Http class. This includes everything processed by WordPress; even things unrelated to s2Member. This log file can be extremely helpful. It includes technical details about remote HTTP connections that are not available in other log files.'),
73
- );
 
 
74
 
75
  /**
76
  * Logs HTTP communication (if enabled).
77
  *
78
- * @package s2Member\Utilities
79
  * @since 120212
 
 
 
 
 
 
 
 
 
80
  */
81
  public static function http_api_debug($response = NULL, $state = NULL, $class = NULL, $args = NULL, $url = NULL)
82
  {
83
  if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
84
  return; // Logging is NOT enabled in this case.
85
 
86
- $is_s2member = (!empty($args['s2member']) || strpos($url, 's2member') !== FALSE) ? TRUE : FALSE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
- if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs_extensive'] && !$is_s2member)
89
- return; // Extensive logging is NOT enabled in this case.
90
 
91
- global $current_site, $current_blog; // For Multisite support.
 
92
 
93
- $http_api_debug = array(
94
- 'state' => $state,
95
- 'transport_class' => $class,
96
- 'args' => $args,
97
- 'url' => $url,
98
- 'response' => $response
99
- );
100
- $logt = c_ws_plugin__s2member_utilities::time_details();
101
- $logv = c_ws_plugin__s2member_utilities::ver_details();
102
- $logm = c_ws_plugin__s2member_utilities::mem_details();
103
-
104
- $log4 = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n".'User-Agent: '.$_SERVER['HTTP_USER_AGENT'];
105
- $log4 = (is_multisite() && !is_main_site()) ? ($_log4 = $current_blog->domain.$current_blog->path)."\n".$log4 : $log4;
106
- $log2 = (is_multisite() && !is_main_site()) ? 'http-api-debug-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', (!empty($_log4) ? $_log4 : '')), '-').'.log' : 'http-api-debug.log';
107
-
108
- $http_api_debug_conceal_private_info = c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($http_api_debug, TRUE));
109
-
110
- if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
111
- if(is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files())
112
- {
113
- if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs_extensive'])
114
- file_put_contents($logs_dir.'/wp-'.$log2,
115
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
116
- $http_api_debug_conceal_private_info."\n\n",
117
- FILE_APPEND);
118
-
119
- if($is_s2member) // Log s2Member HTTP connections separately.
120
- file_put_contents($logs_dir.'/s2-'.$log2,
121
- 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
122
- $http_api_debug_conceal_private_info."\n\n",
123
- FILE_APPEND);
124
- }
125
  }
126
 
127
  /**
128
  * Archives logs to prevent HUGE files from building up over time.
129
  *
130
- * This routine is staggered to conserve resources.
131
- * This is called by all logging routines for s2Member.
132
- *
133
- * @package s2Member\Utilities
134
  * @since 3.5
 
135
  *
136
- * @param bool $stagger Optional. Defaults to true. If false, the routine will run, regardless.
137
  *
138
- * @return bool Always returns true.
139
  */
140
  public static function archive_oversize_log_files($stagger = TRUE)
141
  {
142
- if(!$stagger || is_float($stagger = time() / 2)) // Stagger this routine?
 
 
 
 
 
 
 
 
 
 
 
 
143
  {
144
- if(is_dir($dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']) && is_writable($dir))
145
- {
146
- $max = apply_filters('ws_plugin__s2member_oversize_log_file_bytes', 2097152, get_defined_vars());
147
-
148
- $log_files = scandir($dir);
149
- shuffle($log_files);
150
- $counter = 1;
151
-
152
- foreach($log_files as $file) // Go through each log file. Up to 25 files at a time.
153
- {
154
- if(preg_match('/\.log$/i', $file) && !preg_match('/\-ARCHIVED\-/i', $file) && is_file($dir_file = $dir.'/'.$file))
155
- {
156
- if(filesize($dir_file) > $max && is_writable($dir_file)) // The file must be writable.
157
- if($log = preg_replace('/\.log$/i', '', $dir_file)) // Strip .log before renaming.
158
- rename($dir_file, $log.'-ARCHIVED-'.date('m-d-Y').'-'.time().'.log');
159
- }
160
- if(($counter = $counter + 1) > 25) // Up to 25 files at a time.
161
- break; // Stop for now.
162
- }
163
- }
164
  }
165
- return TRUE;
166
  }
167
 
168
  /**
169
  * Removes expired Transients inserted into the database by s2Member.
170
  *
171
- * This routine is staggered to conserve resources.
172
- * Only 5 Transients are deleted each time.
173
- *
174
- * This is called by s2Member's Auto-EOT System, every 10 minutes.
175
- *
176
- * @package s2Member\Utilities
177
  * @since 3.5
 
178
  *
179
- * @param bool $stagger Optional. Defaults to true. If false, the routine will run, regardless.
180
  *
181
- * @return bool Always returns true.
182
  */
183
  public static function cleanup_expired_s2m_transients($stagger = TRUE)
184
  {
185
  global $wpdb;
186
  /** @var wpdb $wpdb */
187
 
188
- if(!$stagger || is_float($stagger = time() / 2)) // Stagger this routine?
189
- {
190
- if(is_array($expired_s2m_transients = $wpdb->get_results("SELECT * FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_transient_timeout_s2m_'))."%' AND `option_value` < '".esc_sql(time())."' LIMIT 5")) && !empty($expired_s2m_transients))
191
- {
192
- foreach($expired_s2m_transients as $expired_s2m_transient) // Delete the _timeout, and also the transient entry name itself.
193
- if(($id = $expired_s2m_transient->option_id) && ($name = preg_replace('/_transient_timeout_/i', '_transient_', $expired_s2m_transient->option_name, 1)))
194
- $wpdb->query("DELETE FROM `".$wpdb->options."` WHERE (`option_id` = '".esc_sql($id)."' OR `option_name` = '".esc_sql($name)."')");
195
- }
196
- }
197
- return TRUE;
198
  }
199
 
200
  /**
201
- * Attempts to conceal private details in log entries.
202
  *
 
203
  * @package s2Member\Utilities
204
- * @since 130315
205
  *
206
- * @param string $log_entry The log entry we need to conceal private details in.
207
- *
208
- * @return string Filtered string with some data X'd out :-)
209
  */
210
- public static function conceal_private_info($log_entry)
211
- {
212
- $log_entry = preg_replace('/\b([3456][0-9]{10,11})([0-9]{4})\b/', 'xxxxxxxxxxxx'.'$2', (string)$log_entry);
 
 
 
213
 
214
- $log_entry = preg_replace('/(\'.*pass_?(?:word)?(?:[0-9]+)?\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/pass'.'$3', $log_entry);
215
- $log_entry = preg_replace('/([&?][^&]*pass_?(?:word)?(?:[0-9]+)?\=)([^&]+)/', '$1'.'xxxxxxxx/pass', $log_entry);
216
 
217
- $log_entry = preg_replace('/(\'api_?(?:key|secret)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/api/key/sec'.'$3', $log_entry);
218
- $log_entry = preg_replace('/([&?][^&]api_?(?:key|secret)\=)([^&]+)/', '$1'.'xxxxxxxx/api/key/sec', $log_entry);
 
219
 
220
- $log_entry = preg_replace('/(\'(?:PWD|SIGNATURE)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/PWD/SIG'.'$3', $log_entry);
221
- $log_entry = preg_replace('/([&?][^&](?:PWD|SIGNATURE)\=)([^&]+)/', '$1'.'xxxxxxxx/PWD/SIG', $log_entry);
222
 
223
- $log_entry = preg_replace('/(\'(?:x_login|x_tran_key)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/key/tran'.'$3', $log_entry);
224
- $log_entry = preg_replace('/([&?][^&](?:x_login|x_tran_key)\=)([^&]+)/', '$1'.'xxxxxxxx/key/tran', $log_entry);
225
 
226
- return $log_entry;
227
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
  }
28
  class c_ws_plugin__s2member_utils_logs
29
  {
30
  /**
31
+ * Logs an entry.
32
  *
33
+ * @since 130315
34
  * @package s2Member\Utilities
 
35
  *
36
+ * @param string $slug The file name; i.e. a slug.
37
+ * e.g. `mailchimp-api`, `s2-http-api-debug`.
38
+ *
39
+ * @param mixed $data The data to log.
40
  */
41
+ public static function log_entry($slug, $data)
42
+ {
43
+ if(!($slug = trim((string)$slug)))
44
+ return; // Not possible.
 
 
45
 
46
+ if(!$data) return; // Nothing to log.
 
47
 
48
+ if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
49
+ return; // Nothing to do; logging not enabled right now.
 
50
 
51
+ if(!is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
52
+ return; // Log directory does not exist at this time.
53
 
54
+ if(!is_writable($logs_dir)) return; // Not writable.
 
55
 
56
+ $logt = c_ws_plugin__s2member_utilities::time_details();
57
+ $logv = c_ws_plugin__s2member_utilities::ver_details();
58
+ $logm = c_ws_plugin__s2member_utilities::mem_details();
59
 
60
+ $log4 = ''; // Initialize.
61
+ if(is_multisite() && !is_main_site()) // Child blog in a multisite network?
62
+ $log4 .= $GLOBALS['current_blog']->domain.$GLOBALS['current_blog']->path."\n";
63
+ $log4 .= @$_SERVER['HTTP_HOST'].@$_SERVER['REQUEST_URI']."\n";
64
+ $log4 .= 'User-Agent: '.@$_SERVER['HTTP_USER_AGENT'];
65
 
66
+ $log2 = $slug.'-api.log'; // Initialize.
67
+ if(is_multisite() && !is_main_site()) // Child blog in a multisite network?
68
+ $log2 = $slug.'-api-4-'.trim(preg_replace('/[^a-z0-9]/i', '-', $GLOBALS['current_blog']->domain.$GLOBALS['current_blog']->path), '-').'.log';
69
 
70
+ c_ws_plugin__s2member_utils_logs::archive_oversize_log_files();
71
 
72
+ file_put_contents($logs_dir.'/'.$log2,
73
+ 'LOG ENTRY: '.$logt."\n".$logv."\n".$logm."\n".$log4."\n".
74
+ c_ws_plugin__s2member_utils_logs::conceal_private_info(print_r($data, TRUE))."\n\n",
75
+ FILE_APPEND); // Append to an existing log file; if exists.
76
+ }
77
 
78
  /**
79
  * Logs HTTP communication (if enabled).
80
  *
 
81
  * @since 120212
82
+ * @package s2Member\Utilities
83
+ *
84
+ * @attaches-to `http_api_debug` hook.
85
+ *
86
+ * @param mixed $response Passed by action.
87
+ * @param mixed $state Passed by action.
88
+ * @param mixed $class Passed by action.
89
+ * @param mixed $args Passed by action.
90
+ * @param mixed $url Passed by action.
91
  */
92
  public static function http_api_debug($response = NULL, $state = NULL, $class = NULL, $args = NULL, $url = NULL)
93
  {
94
  if(!$GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs'])
95
  return; // Logging is NOT enabled in this case.
96
 
97
+ $http_api_debug = array(
98
+ 'state' => $state, 'transport_class' => $class,
99
+ 'args' => $args, 'url' => $url, 'response' => $response
100
+ );
101
+ if(!empty($args['s2member']) || strpos($url, 's2member') !== FALSE)
102
+ self::log_entry('s2-http-api-debug', $http_api_debug);
103
+
104
+ if($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs_extensive'])
105
+ self::log_entry('wp-http-api-debug', $http_api_debug);
106
+ }
107
+
108
+ /**
109
+ * Attempts to conceal private details in log entries.
110
+ *
111
+ * @since 130315
112
+ * @package s2Member\Utilities
113
+ *
114
+ * @param string $log_entry The log entry we need to conceal private details in.
115
+ *
116
+ * @return string Filtered string with some data X'd out :-)
117
+ */
118
+ public static function conceal_private_info($log_entry)
119
+ {
120
+ if(!($log_entry = trim((string)$log_entry)))
121
+ return $log_entry; // Nothing to do.
122
+
123
+ $log_entry = preg_replace('/\b([3456][0-9]{10,11})([0-9]{4})\b/', 'xxxxxxxxxxxx'.'$2', $log_entry);
124
 
125
+ $log_entry = preg_replace('/(\'.*pass_?(?:word)?(?:[0-9]+)?\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/pass'.'$3', $log_entry);
126
+ $log_entry = preg_replace('/([&?][^&]*pass_?(?:word)?(?:[0-9]+)?\=)([^&]+)/', '$1'.'xxxxxxxx/pass', $log_entry);
127
 
128
+ $log_entry = preg_replace('/(\'api_?(?:key|secret)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/api/key/sec'.'$3', $log_entry);
129
+ $log_entry = preg_replace('/([&?][^&]api_?(?:key|secret)\=)([^&]+)/', '$1'.'xxxxxxxx/api/key/sec', $log_entry);
130
 
131
+ $log_entry = preg_replace('/(\'(?:PWD|SIGNATURE)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/PWD/SIG'.'$3', $log_entry);
132
+ $log_entry = preg_replace('/([&?][^&](?:PWD|SIGNATURE)\=)([^&]+)/', '$1'.'xxxxxxxx/PWD/SIG', $log_entry);
133
+
134
+ $log_entry = preg_replace('/(\'(?:x_login|x_tran_key)\'\s*\=\>\s*\')([^\']+)(\')/', '$1'.'xxxxxxxx/key/tran'.'$3', $log_entry);
135
+ $log_entry = preg_replace('/([&?][^&](?:x_login|x_tran_key)\=)([^&]+)/', '$1'.'xxxxxxxx/key/tran', $log_entry);
136
+
137
+ return $log_entry; // With some private info concealed now.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
  /**
141
  * Archives logs to prevent HUGE files from building up over time.
142
  *
 
 
 
 
143
  * @since 3.5
144
+ * @package s2Member\Utilities
145
  *
146
+ * @param bool $stagger Defaults to a `TRUE` value.
147
  *
148
+ * @return bool Always returns a `TRUE` value.
149
  */
150
  public static function archive_oversize_log_files($stagger = TRUE)
151
  {
152
+ if($stagger && !is_float($stagger = time() / 2))
153
+ return TRUE; // Bypass this time.
154
+
155
+ if(!is_dir($dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']) || !is_writable($dir))
156
+ return TRUE; // Not necessary; directory is nonexistent or not writable.
157
+
158
+ if(!($log_files = scandir($dir)) || !shuffle($log_files))
159
+ return TRUE; // No files; not necessary.
160
+
161
+ $counter = 1; // Initialize archiving counter.
162
+ $max = apply_filters('ws_plugin__s2member_oversize_log_file_bytes', 2097152, get_defined_vars());
163
+
164
+ foreach($log_files as $file) // Go through each log file. Up to 25 files at a time.
165
  {
166
+ if(preg_match('/\.log$/i', $file) && !preg_match('/\-ARCHIVED\-/i', $file) && is_file($dir_file = $dir.'/'.$file))
167
+ if(filesize($dir_file) > $max && is_writable($dir_file)) // The file must be writable.
168
+ if($log = preg_replace('/\.log$/i', '', $dir_file)) // Strip .log before renaming.
169
+ rename($dir_file, $log.'-ARCHIVED-'.date('m-d-Y').'-'.time().'.log');
170
+
171
+ if(($counter = $counter + 1) > 25) // Up to 25 files at a time.
172
+ break; // Stop for now.
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
174
+ return TRUE; // Always returns a `TRUE` value.
175
  }
176
 
177
  /**
178
  * Removes expired Transients inserted into the database by s2Member.
179
  *
 
 
 
 
 
 
180
  * @since 3.5
181
+ * @package s2Member\Utilities
182
  *
183
+ * @param bool $stagger Defaults to a `TRUE` value.
184
  *
185
+ * @return bool Always returns a `TRUE` value.
186
  */
187
  public static function cleanup_expired_s2m_transients($stagger = TRUE)
188
  {
189
  global $wpdb;
190
  /** @var wpdb $wpdb */
191
 
192
+ if($stagger && !is_float($stagger = time() / 2))
193
+ return TRUE; // Bypass this time.
194
+
195
+ if(($expired_s2m_transients = $wpdb->get_results("SELECT * FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_transient_timeout_s2m_'))."%' AND `option_value` < '".esc_sql(time())."' LIMIT 5")))
196
+ foreach($expired_s2m_transients as $_expired_s2m_transient) // Delete the _timeout, and also the transient entry name itself.
197
+ if(($_id = $_expired_s2m_transient->option_id) && ($_name = preg_replace('/_transient_timeout_/i', '_transient_', $_expired_s2m_transient->option_name, 1)))
198
+ $wpdb->query("DELETE FROM `".$wpdb->options."` WHERE (`option_id` = '".esc_sql($_id)."' OR `option_name` = '".esc_sql($_name)."')");
199
+
200
+ return TRUE; // Always returns a `TRUE` value.
 
201
  }
202
 
203
  /**
204
+ * Array of log file descriptions.
205
  *
206
+ * @since 120214
207
  * @package s2Member\Utilities
 
208
  *
209
+ * @var array Array of log file descriptions.
 
 
210
  */
211
+ public static $log_file_descriptions = array
212
+ ( // Array keys are regex patterns matching their associated log file names.
213
+ '/paypal\-api/' => array('short' => 'PayPal API communication.', 'long' => 'This log file records all communication between s2Member and PayPal APIs. Such as PayPal Button Encryption and PayPal Pro API calls that process transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
214
+ '/paypal\-payflow\-api/' => array('short' => 'PayPal (PayFlow Edition) API communication.', 'long' => 'This log file records all communication between s2Member and the PayPal (PayFlow Edition) APIs. Only applicable if you operate a PayPal Payments Pro (PayFlow Edition) account. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
215
+ '/gateway\-core\-ipn/' => array('short' => 'Core PayPal IPN and post-processing handler.', 'long' => 'This log file records all communication between s2Member and the PayPal IPN service. Also logs all post-processing routines from other Payment Gateway integrations, where s2Member translates its communication with other Payment Gateways into a format it\'s core PayPal processing routines can understand. All transactions pass through s2Member\'s core PayPal processor and they will be logged in this file. Including transactions processed via s2Member Pro Forms; for all Payment Gateway integrations.'),
216
+ '/gateway\-core\-rtn/' => array('short' => 'Core PayPal PDT/Auto-Return communication.', 'long' => 'This log file records all communication between s2Member and the PayPal PDT Auto-Return system (i.e. routines that help s2Member process Thank-You pages). Also logs all Auto-Return routines from other Payment Gateway integrations (those implemented via Payment Buttons), where s2Member translates its communication with other Payment Gateways into a format it\'s core PayPal processing routines can understand. Not used in s2Member Pro Form integrations however.'),
217
 
218
+ '/stripe\-api/' => array('short' => 'Stripe API communication.', 'long' => 'This log file records all communication between s2Member and Stripe APIs.'),
219
+ '/stripe\-ipn/' => array('short' => 'Stripe Webhook/IPN communication.', 'long' => 'This log file records the Webhook/IPN data that Stripe sends to s2Member.'),
220
 
221
+ '/authnet\-api/' => array('short' => 'Authorize.Net API communication.', 'long' => 'This log file records all communication between s2Member and Authorize.Net APIs (for both AIM and ARB integrations).'),
222
+ '/authnet\-arb/' => array('short' => 'Authorize.Net ARB Subscription status checks.', 'long' => 'This log file records s2Member\'s Authorize.Net ARB Subscription status checks. s2Member polls the ARB service periodically to check the status of existing Members (e.g. to see if billing is still active or not).'),
223
+ '/authnet\-ipn/' => array('short' => 'Authorize.Net Silent Post/IPN communication.', 'long' => 'This log file records the Silent Post/IPN data Authorize.Net sends to s2Member with details regarding new transactions.'),
224
 
225
+ '/alipay\-ipn/' => array('short' => 'AliPay IPN communication.', 'long' => 'This log file records the IPN data AliPay sends to s2Member with details regarding new transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
226
+ '/alipay\-rtn/' => array('short' => 'AliPay Auto-Return communication.', 'long' => 'This log file records the Auto-Return data AliPay sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
227
 
228
+ '/clickbank\-ipn/' => array('short' => 'ClickBank IPN communication.', 'long' => 'This log file records the IPN data ClickBank sends to s2Member with details regarding new transactions, cancellations, expirations, etc. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
229
+ '/clickbank\-rtn/' => array('short' => 'ClickBank Auto-Return communication.', 'long' => 'This log file records the Auto-Return data ClickBank sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
230
 
231
+ '/google\-rtn/' => array('short' => 'Google Auto-Return communication.', 'long' => 'This log file records the Auto-Return data Google sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor). NOTE (regarding Google Wallet)... this particular log file is currently implemented for a possible future use ONLY. At this time there is no need for an Auto-Return handler with Google Wallet, because Google Wallet return handling is done via email-only at this time.'),
232
+ '/google\-ipn/' => array('short' => 'Google Postback/IPN communication.', 'long' => 'This log file records the Postback/IPN data Google sends to s2Member with details regarding new transactions, cancellations, expirations, etc. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
233
+
234
+ '/ccbill\-ipn/' => array('short' => 'ccBill Bg Post/IPN communication.', 'long' => 'This log file records the Bg Post/IPN data ccBill sends to s2Member with details regarding new transactions. See also: gateway-core-ipn.log (s2Member\'s core processor).'),
235
+ '/ccbill\-rtn/' => array('short' => 'ccBill Auto-Return communication.', 'long' => 'This log file records the Auto-Return data ccBill sends to s2Member with details regarding new transactions (i.e. logs routines that help s2Member process Thank-You pages). See also: gateway-core-rtn.log (s2Member\'s core processor).'),
236
+ '/ccbill\-dl\-ipn/' => array('short' => 'ccBill Datalink Subscription status checks.', 'long' => 'This log file records s2Member\'s ccBill Datalink Subscription status checks that may result in actions taken by s2Member. s2Member polls the ccBill Datalink service periodically to check the status of existing Members (e.g. to see if billing is still active or not).'),
237
+ '/ccbill\-dl/' => array('short' => 'ccBill Datalink collections.', 'long' => 'This log file records s2Member\'s ccBill Datalink connections. s2Member polls the ccBill Datalink service periodically to obtain information about existing Users/Members.'),
238
+
239
+ '/mailchimp\-api/' => array('short' => 'MailChimp API communication.', 'long' => 'This log file records all of s2Member\'s communication with MailChimp APIs.'),
240
+ '/aweber\-api/' => array('short' => 'AWeber API communication.', 'long' => 'This log file records all of s2Member\'s communication with AWeber APIs.'),
241
+ '/getresponse\-api/' => array('short' => 'GetResponse API communication.', 'long' => 'This log file records all of s2Member\'s communication with GetResponse APIs.'),
242
+
243
+ '/reg\-handler/' => array('short' => 'User registrations processed by s2Member.', 'long' => 'This log file records all User/Member registrations processed by s2Member (either directly or indirectly). This includes both free and paid registrations. It also logs registrations that occur as a result of new Users/Members being created from the Dashboard by a site owner. It also includes registrations that occur through the s2Member Pro Remote Operations API.'),
244
+
245
+ '/s2\-http\-api\-debug/' => array('short' => 'All outgoing HTTP connections related to s2Member.', 'long' => 'This log file records all outgoing WP_Http connections that are specifically related to s2Member. This log file can be extremely helpful. It includes technical details about remote HTTP connections that are not available in other log files.'),
246
+ '/wp\-http\-api\-debug/' => array('short' => 'All outgoing WordPress HTTP connections.', 'long' => 'This log file records all outgoing HTTP connections processed by the WP_Http class. This includes everything processed by WordPress; even things unrelated to s2Member. This log file can be extremely helpful. It includes technical details about remote HTTP connections that are not available in other log files.'),
247
+ );
248
  }
249
  }
includes/codes.inc.php CHANGED
@@ -14,29 +14,28 @@
14
  * @package s2Member
15
  * @since 3.0
16
  */
17
- if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
18
- exit ("Do not access this file directly.");
19
  /*
20
  Add WordPress Editor Shortcodes.
21
  */
22
- add_shortcode("s2Key", "c_ws_plugin__s2member_sc_keys::sc_get_key");
23
- add_shortcode("s2Get", "c_ws_plugin__s2member_sc_gets::sc_get_details");
24
- add_shortcode("s2File", "c_ws_plugin__s2member_sc_files::sc_get_file");
25
- add_shortcode("s2Stream", "c_ws_plugin__s2member_sc_files::sc_get_stream");
26
 
27
- add_shortcode("s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
28
- add_shortcode("_s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
29
- add_shortcode("__s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
30
- add_shortcode("___s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
31
- add_shortcode("____s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
32
- add_shortcode("_____s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
33
- add_shortcode("______s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
34
- add_shortcode("_______s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
35
- add_shortcode("________s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
36
- add_shortcode("_________s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
37
- add_shortcode("__________s2If", "c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals");
38
 
39
- add_shortcode("s2Member-Profile", "c_ws_plugin__s2member_sc_profile::sc_profile");
40
- add_shortcode("s2Member-PayPal-Button", "c_ws_plugin__s2member_sc_paypal_button::sc_paypal_button");
41
- add_shortcode("s2Member-Security-Badge", "c_ws_plugin__s2member_sc_s_badge::sc_s_badge");
42
- ?>
14
  * @package s2Member
15
  * @since 3.0
16
  */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit ('Do not access this file directly.');
19
  /*
20
  Add WordPress Editor Shortcodes.
21
  */
22
+ add_shortcode('s2Key', 'c_ws_plugin__s2member_sc_keys::sc_get_key');
23
+ add_shortcode('s2Get', 'c_ws_plugin__s2member_sc_gets::sc_get_details');
24
+ add_shortcode('s2File', 'c_ws_plugin__s2member_sc_files::sc_get_file');
25
+ add_shortcode('s2Stream', 'c_ws_plugin__s2member_sc_files::sc_get_stream');
26
 
27
+ add_shortcode('s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
28
+ add_shortcode('_s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
29
+ add_shortcode('__s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
30
+ add_shortcode('___s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
31
+ add_shortcode('____s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
32
+ add_shortcode('_____s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
33
+ add_shortcode('______s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
34
+ add_shortcode('_______s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
35
+ add_shortcode('________s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
36
+ add_shortcode('_________s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
37
+ add_shortcode('__________s2If', 'c_ws_plugin__s2member_sc_if_conds::sc_if_conditionals');
38
 
39
+ add_shortcode('s2Member-Profile', 'c_ws_plugin__s2member_sc_profile::sc_profile');
40
+ add_shortcode('s2Member-PayPal-Button', 'c_ws_plugin__s2member_sc_paypal_button::sc_paypal_button');
41
+ add_shortcode('s2Member-Security-Badge', 'c_ws_plugin__s2member_sc_s_badge::sc_s_badge');
 
includes/externals/aweber/aweber.php ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('exceptions.php');
3
+ require_once('oauth_adapter.php');
4
+ require_once('oauth_application.php');
5
+ require_once('aweber_response.php');
6
+ require_once('aweber_collection.php');
7
+ require_once('aweber_entry_data_array.php');
8
+ require_once('aweber_entry.php');
9
+
10
+ /**
11
+ * AWeberServiceProvider
12
+ *
13
+ * Provides specific AWeber information or implementing OAuth.
14
+ * @uses OAuthServiceProvider
15
+ * @package
16
+ * @version $id$
17
+ */
18
+ class AWeberServiceProvider implements OAuthServiceProvider {
19
+
20
+ /**
21
+ * @var String Location for API calls
22
+ */
23
+ public $baseUri = 'https://api.aweber.com/1.0';
24
+
25
+ /**
26
+ * @var String Location to request an access token
27
+ */
28
+ public $accessTokenUrl = 'https://auth.aweber.com/1.0/oauth/access_token';
29
+
30
+ /**
31
+ * @var String Location to authorize an Application
32
+ */
33
+ public $authorizeUrl = 'https://auth.aweber.com/1.0/oauth/authorize';
34
+
35
+ /**
36
+ * @var String Location to request a request token
37
+ */
38
+ public $requestTokenUrl = 'https://auth.aweber.com/1.0/oauth/request_token';
39
+
40
+
41
+ public function getBaseUri() {
42
+ return $this->baseUri;
43
+ }
44
+
45
+ public function removeBaseUri($url) {
46
+ return str_replace($this->getBaseUri(), '', $url);
47
+ }
48
+
49
+ public function getAccessTokenUrl() {
50
+ return $this->accessTokenUrl;
51
+ }
52
+
53
+ public function getAuthorizeUrl() {
54
+ return $this->authorizeUrl;
55
+ }
56
+
57
+ public function getRequestTokenUrl() {
58
+ return $this->requestTokenUrl;
59
+ }
60
+
61
+ public function getAuthTokenFromUrl() { return ''; }
62
+ public function getUserData() { return ''; }
63
+
64
+ }
65
+
66
+ /**
67
+ * AWeberAPIBase
68
+ *
69
+ * Base object that all AWeberAPI objects inherit from. Allows specific pieces
70
+ * of functionality to be shared across any object in the API, such as the
71
+ * ability to introspect the collections map.
72
+ *
73
+ * @package
74
+ * @version $id$
75
+ */
76
+ class AWeberAPIBase {
77
+
78
+ /**
79
+ * Maintains data about what children collections a given object type
80
+ * contains.
81
+ */
82
+ static protected $_collectionMap = array(
83
+ 'account' => array('lists', 'integrations'),
84
+ 'broadcast_campaign' => array('links', 'messages', 'stats'),
85
+ 'followup_campaign' => array('links', 'messages', 'stats'),
86
+ 'link' => array('clicks'),
87
+ 'list' => array('campaigns', 'custom_fields', 'subscribers',
88
+ 'web_forms', 'web_form_split_tests'),
89
+ 'web_form' => array(),
90
+ 'web_form_split_test' => array('components'),
91
+ );
92
+
93
+ /**
94
+ * loadFromUrl
95
+ *
96
+ * Creates an object, either collection or entry, based on the given
97
+ * URL.
98
+ *
99
+ * @param mixed $url URL for this request
100
+ * @access public
101
+ * @return AWeberEntry or AWeberCollection
102
+ */
103
+ public function loadFromUrl($url) {
104
+ $data = $this->adapter->request('GET', $url);
105
+ return $this->readResponse($data, $url);
106
+ }
107
+
108
+ protected function _cleanUrl($url) {
109
+ return str_replace($this->adapter->app->getBaseUri(), '', $url);
110
+ }
111
+
112
+ /**
113
+ * readResponse
114
+ *
115
+ * Interprets a response, and creates the appropriate object from it.
116
+ * @param mixed $response Data returned from a request to the AWeberAPI
117
+ * @param mixed $url URL that this data was requested from
118
+ * @access protected
119
+ * @return mixed
120
+ */
121
+ protected function readResponse($response, $url) {
122
+ $this->adapter->parseAsError($response);
123
+ if (!empty($response['id'])) {
124
+ return new AWeberEntry($response, $url, $this->adapter);
125
+ } else if (array_key_exists('entries', $response)) {
126
+ return new AWeberCollection($response, $url, $this->adapter);
127
+ }
128
+ return false;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * AWeberAPI
134
+ *
135
+ * Creates a connection to the AWeberAPI for a given consumer application.
136
+ * This is generally the starting point for this library. Instances can be
137
+ * created directly with consumerKey and consumerSecret.
138
+ *
139
+ * @property AWeberCollection ___account
140
+ * @uses AWeberAPIBase
141
+ * @package
142
+ * @version $id$
143
+ */
144
+ class AWeberAPI extends AWeberAPIBase {
145
+
146
+ /**
147
+ * @var String Consumer Key
148
+ */
149
+ public $consumerKey = false;
150
+
151
+ /**
152
+ * @var String Consumer Secret
153
+ */
154
+ public $consumerSecret = false;
155
+
156
+ /**
157
+ * @var Object - Populated in setAdapter()
158
+ */
159
+ public $adapter = false;
160
+
161
+ /**
162
+ * Uses the app's authorization code to fetch an access token
163
+ *
164
+ * @param String Authorization code from authorize app page
165
+ */
166
+ public static function getDataFromAweberID($string) {
167
+ list($consumerKey, $consumerSecret, $requestToken, $tokenSecret, $verifier) = AWeberAPI::_parseAweberID($string);
168
+
169
+ if (!$verifier) {
170
+ return null;
171
+ }
172
+ $aweber = new AweberAPI($consumerKey, $consumerSecret);
173
+ $aweber->adapter->user->requestToken = $requestToken;
174
+ $aweber->adapter->user->tokenSecret = $tokenSecret;
175
+ $aweber->adapter->user->verifier = $verifier;
176
+ list($accessToken, $accessSecret) = $aweber->getAccessToken();
177
+ return array($consumerKey, $consumerSecret, $accessToken, $accessSecret);
178
+ }
179
+
180
+ protected static function _parseAWeberID($string) {
181
+ $values = explode('|', $string);
182
+ if (count($values) < 5) {
183
+ return null;
184
+ }
185
+ return array_slice($values, 0, 5);
186
+ }
187
+
188
+ /**
189
+ * Sets the consumer key and secret for the API object. The
190
+ * key and secret are listed in the My Apps page in the labs.aweber.com
191
+ * Control Panel OR, in the case of distributed apps, will be returned
192
+ * from the getDataFromAweberID() function
193
+ *
194
+ * @param String Consumer Key
195
+ * @param String Consumer Secret
196
+ * @return null
197
+ */
198
+ public function __construct($key, $secret) {
199
+ // Load key / secret
200
+ $this->consumerKey = $key;
201
+ $this->consumerSecret = $secret;
202
+
203
+ $this->setAdapter();
204
+ }
205
+
206
+ /**
207
+ * Returns the authorize URL by appending the request
208
+ * token to the end of the Authorize URI, if it exists
209
+ *
210
+ * @return string The Authorization URL
211
+ */
212
+ public function getAuthorizeUrl() {
213
+ $requestToken = $this->user->requestToken;
214
+ return (empty($requestToken)) ?
215
+ $this->adapter->app->getAuthorizeUrl()
216
+ :
217
+ $this->adapter->app->getAuthorizeUrl() . "?oauth_token={$this->user->requestToken}";
218
+ }
219
+
220
+ /**
221
+ * Sets the adapter for use with the API
222
+ */
223
+ public function setAdapter($adapter=null) {
224
+ if (empty($adapter)) {
225
+ $serviceProvider = new AWeberServiceProvider();
226
+ $adapter = new OAuthApplication($serviceProvider);
227
+ $adapter->consumerKey = $this->consumerKey;
228
+ $adapter->consumerSecret = $this->consumerSecret;
229
+ }
230
+ $this->adapter = $adapter;
231
+ }
232
+
233
+ /**
234
+ * Fetches account data for the associated account
235
+ *
236
+ * @param String Access Token (Only optional/cached if you called getAccessToken() earlier
237
+ * on the same page)
238
+ * @param String Access Token Secret (Only optional/cached if you called getAccessToken() earlier
239
+ * on the same page)
240
+ * @return Object AWeberCollection Object with the requested
241
+ * account data
242
+ */
243
+ public function getAccount($token=false, $secret=false) {
244
+ if ($token && $secret) {
245
+ $user = new OAuthUser();
246
+ $user->accessToken = $token;
247
+ $user->tokenSecret = $secret;
248
+ $this->adapter->user = $user;
249
+ }
250
+
251
+ $body = $this->adapter->request('GET', '/accounts');
252
+ $accounts = $this->readResponse($body, '/accounts');
253
+ return $accounts[0];
254
+ }
255
+
256
+ /**
257
+ * PHP Automagic
258
+ */
259
+ public function __get($item) {
260
+ if ($item == 'user') return $this->adapter->user;
261
+ trigger_error("Could not find \"{$item}\"");
262
+ }
263
+
264
+ /**
265
+ * Request a request token from AWeber and associate the
266
+ * provided $callbackUrl with the new token
267
+ * @param String The URL where users should be redirected
268
+ * once they authorize your app
269
+ * @return Array Contains the request token as the first item
270
+ * and the request token secret as the second item of the array
271
+ */
272
+ public function getRequestToken($callbackUrl) {
273
+ $requestToken = $this->adapter->getRequestToken($callbackUrl);
274
+ return array($requestToken, $this->user->tokenSecret);
275
+ }
276
+
277
+ /**
278
+ * Request an access token using the request tokens stored in the
279
+ * current user object. You would want to first set the request tokens
280
+ * on the user before calling this function via:
281
+ *
282
+ * $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
283
+ * $aweber->user->requestToken = $_GET['oauth_token'];
284
+ * $aweber->user->verifier = $_GET['oauth_verifier'];
285
+ *
286
+ * @return Array Contains the access token as the first item
287
+ * and the access token secret as the second item of the array
288
+ */
289
+ public function getAccessToken() {
290
+ return $this->adapter->getAccessToken();
291
+ }
292
+ }
293
+
294
+ ?>
includes/externals/aweber/aweber_api.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (class_exists('AWeberAPI')) {
4
+ trigger_error("Duplicate: Another AWeberAPI client library is already in scope.", E_USER_WARNING);
5
+ }
6
+ else {
7
+ require_once('aweber.php');
8
+ }
includes/externals/aweber/aweber_collection.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class AWeberCollection extends AWeberResponse implements ArrayAccess, Iterator, Countable {
3
+
4
+ protected $pageSize = 100;
5
+ protected $pageStart = 0;
6
+
7
+ protected function _updatePageSize() {
8
+
9
+ # grab the url, or prev and next url and pull ws.size from it
10
+ $url = $this->url;
11
+ if (array_key_exists('next_collection_link', $this->data)) {
12
+ $url = $this->data['next_collection_link'];
13
+
14
+ } elseif (array_key_exists('prev_collection_link', $this->data)) {
15
+ $url = $this->data['prev_collection_link'];
16
+ }
17
+
18
+ # scan querystring for ws_size
19
+ $url_parts = parse_url($url);
20
+
21
+ # we have a query string
22
+ if (array_key_exists('query', $url_parts)) {
23
+ parse_str($url_parts['query'], $params);
24
+
25
+ # we have a ws_size
26
+ if (array_key_exists('ws_size', $params)) {
27
+
28
+ # set pageSize
29
+ $this->pageSize = $params['ws_size'];
30
+ return;
31
+ }
32
+ }
33
+
34
+ # we dont have one, just count the # of entries
35
+ $this->pageSize = count($this->data['entries']);
36
+ }
37
+
38
+ public function __construct($response, $url, $adapter) {
39
+ parent::__construct($response, $url, $adapter);
40
+ $this->_updatePageSize();
41
+ }
42
+
43
+ /**
44
+ * @var array Holds list of keys that are not publicly accessible
45
+ */
46
+ protected $_privateData = array(
47
+ 'entries',
48
+ 'start',
49
+ 'next_collection_link',
50
+ );
51
+
52
+ /**
53
+ * getById
54
+ *
55
+ * Gets an entry object of this collection type with the given id
56
+ * @param mixed $id ID of the entry you are requesting
57
+ * @access public
58
+ * @return AWeberEntry
59
+ */
60
+ public function getById($id) {
61
+ $data = $this->adapter->request('GET', "{$this->url}/{$id}");
62
+ $url = "{$this->url}/{$id}";
63
+ return new AWeberEntry($data, $url, $this->adapter);
64
+ }
65
+
66
+ /** getParentEntry
67
+ *
68
+ * Gets an entry's parent entry
69
+ * Returns NULL if no parent entry
70
+ */
71
+ public function getParentEntry(){
72
+ $url_parts = explode('/', $this->url);
73
+ $size = count($url_parts);
74
+
75
+ # Remove collection id and slash from end of url
76
+ $url = substr($this->url, 0, -strlen($url_parts[$size-1])-1);
77
+
78
+ try {
79
+ $data = $this->adapter->request('GET', $url);
80
+ return new AWeberEntry($data, $url, $this->adapter);
81
+ } catch (Exception $e) {
82
+ return NULL;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * _type
88
+ *
89
+ * Interpret what type of resources are held in this collection by
90
+ * analyzing the URL
91
+ *
92
+ * @access protected
93
+ * @return void
94
+ */
95
+ protected function _type() {
96
+ $urlParts = explode('/', $this->url);
97
+ $type = array_pop($urlParts);
98
+ return $type;
99
+ }
100
+
101
+ /**
102
+ * create
103
+ *
104
+ * Invoke the API method to CREATE a new entry resource.
105
+ *
106
+ * Note: Not all entry resources are eligible to be created, please
107
+ * refer to the AWeber API Reference Documentation at
108
+ * https://labs.aweber.com/docs/reference/1.0 for more
109
+ * details on which entry resources may be created and what
110
+ * attributes are required for creating resources.
111
+ *
112
+ * @access public
113
+ * @param params mixed associtative array of key/value pairs.
114
+ * @return AWeberEntry(Resource) The new resource created
115
+ */
116
+ public function create($kv_pairs) {
117
+ # Create Resource
118
+ $params = array_merge(array('ws.op' => 'create'), $kv_pairs);
119
+ $data = $this->adapter->request('POST', $this->url, $params, array('return' => 'headers'));
120
+
121
+ # Return new Resource
122
+ $url = $data['Location'];
123
+ $resource_data = $this->adapter->request('GET', $url);
124
+ return new AWeberEntry($resource_data, $url, $this->adapter);
125
+ }
126
+
127
+ /**
128
+ * find
129
+ *
130
+ * Invoke the API 'find' operation on a collection to return a subset
131
+ * of that collection. Not all collections support the 'find' operation.
132
+ * refer to https://labs.aweber.com/docs/reference/1.0 for more information.
133
+ *
134
+ * @param mixed $search_data Associative array of key/value pairs used as search filters
135
+ * * refer to https://labs.aweber.com/docs/reference/1.0 for a
136
+ * complete list of valid search filters.
137
+ * * filtering on attributes that require additional permissions to
138
+ * display requires an app authorized with those additional permissions.
139
+ * @access public
140
+ * @return AWeberCollection
141
+ */
142
+ public function find($search_data) {
143
+ # invoke find operation
144
+ $params = array_merge($search_data, array('ws.op' => 'find'));
145
+ $data = $this->adapter->request('GET', $this->url, $params);
146
+
147
+ # get total size
148
+ $ts_params = array_merge($params, array('ws.show' => 'total_size'));
149
+ $total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
150
+ $data['total_size'] = $total_size;
151
+
152
+ # return collection
153
+ return $this->readResponse($data, $this->url);
154
+ }
155
+
156
+ /*
157
+ * ArrayAccess Functions
158
+ *
159
+ * Allows this object to be accessed via bracket notation (ie $obj[$x])
160
+ * http://php.net/manual/en/class.arrayaccess.php
161
+ */
162
+
163
+ public function offsetSet($offset, $value) {}
164
+ public function offsetUnset($offset) {}
165
+ public function offsetExists($offset) {
166
+
167
+ if ($offset >=0 && $offset < $this->total_size) {
168
+ return true;
169
+ }
170
+ return false;
171
+ }
172
+ protected function _fetchCollectionData($offset) {
173
+
174
+ # we dont have a next page, we're done
175
+ if (!array_key_exists('next_collection_link', $this->data)) {
176
+ return null;
177
+ }
178
+
179
+ # snag query string args from collection
180
+ $parsed = parse_url($this->data['next_collection_link']);
181
+
182
+ # parse the query string to get params
183
+ $pairs = explode('&', $parsed['query']);
184
+ foreach ($pairs as $pair) {
185
+ list($key, $val) = explode('=', $pair);
186
+ $params[$key] = $val;
187
+ }
188
+
189
+ # calculate new args
190
+ $limit = $params['ws.size'];
191
+ $pagination_offset = intval($offset / $limit) * $limit;
192
+ $params['ws.start'] = $pagination_offset;
193
+
194
+ # fetch data, exclude query string
195
+ $url_parts = explode('?', $this->url);
196
+ $data = $this->adapter->request('GET', $url_parts[0], $params);
197
+ $this->pageStart = $params['ws.start'];
198
+ $this->pageSize = $params['ws.size'];
199
+
200
+ $collection_data = array('entries', 'next_collection_link', 'prev_collection_link', 'ws.start');
201
+
202
+ foreach ($collection_data as $item) {
203
+ if (!array_key_exists($item, $this->data)) {
204
+ continue;
205
+ }
206
+ if (!array_key_exists($item, $data)) {
207
+ continue;
208
+ }
209
+ $this->data[$item] = $data[$item];
210
+ }
211
+ }
212
+
213
+ public function offsetGet($offset) {
214
+
215
+ if (!$this->offsetExists($offset)) {
216
+ return null;
217
+ }
218
+
219
+ $limit = $this->pageSize;
220
+ $pagination_offset = intval($offset / $limit) * $limit;
221
+
222
+ # load collection page if needed
223
+ if ($pagination_offset !== $this->pageStart) {
224
+ $this->_fetchCollectionData($offset);
225
+ }
226
+
227
+ $entry = $this->data['entries'][$offset - $pagination_offset];
228
+
229
+ # we have an entry, cast it to an AWeberEntry and return it
230
+ $entry_url = $this->adapter->app->removeBaseUri($entry['self_link']);
231
+ return new AWeberEntry($entry, $entry_url, $this->adapter);
232
+ }
233
+
234
+ /*
235
+ * Iterator
236
+ */
237
+ protected $_iterationKey = 0;
238
+
239
+ public function current() {
240
+ return $this->offsetGet($this->_iterationKey);
241
+ }
242
+
243
+ public function key() {
244
+ return $this->_iterationKey;
245
+ }
246
+
247
+ public function next() {
248
+ $this->_iterationKey++;
249
+ }
250
+
251
+ public function rewind() {
252
+ $this->_iterationKey = 0;
253
+ }
254
+
255
+ public function valid() {
256
+ return $this->offsetExists($this->key());
257
+ }
258
+
259
+ /*
260
+ * Countable interface methods
261
+ * Allows PHP's count() and sizeOf() functions to act on this object
262
+ * http://www.php.net/manual/en/class.countable.php
263
+ */
264
+
265
+ public function count() {
266
+ return $this->total_size;
267
+ }
268
+ }
includes/externals/aweber/aweber_entry.php ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AWeberEntry extends AWeberResponse {
4
+
5
+ /**
6
+ * @var array Holds list of data keys that are not publicly accessible
7
+ */
8
+ protected $_privateData = array(
9
+ 'resource_type_link',
10
+ 'http_etag',
11
+ );
12
+
13
+ /**
14
+ * @var array Stores local modifications that have not been saved
15
+ */
16
+ protected $_localDiff = array();
17
+
18
+ /**
19
+ * @var array Holds AWeberCollection objects already instantiated, keyed by
20
+ * their resource name (plural)
21
+ */
22
+ protected $_collections = array();
23
+
24
+ /**
25
+ * attrs
26
+ *
27
+ * Provides a simple array of all the available data (and collections) available
28
+ * in this entry.
29
+ *
30
+ * @access public
31
+ * @return array
32
+ */
33
+ public function attrs() {
34
+ $attrs = array();
35
+ foreach ($this->data as $key => $value) {
36
+ if (!in_array($key, $this->_privateData) && !strpos($key, 'collection_link')) {
37
+ $attrs[$key] = $value;
38
+ }
39
+ }
40
+ if (!empty(AWeberAPI::$_collectionMap[$this->type])) {
41
+ foreach (AWeberAPI::$_collectionMap[$this->type] as $child) {
42
+ $attrs[$child] = 'collection';
43
+ }
44
+ }
45
+ return $attrs;
46
+ }
47
+
48
+ /**
49
+ * _type
50
+ *
51
+ * Used to pull the name of this resource from its resource_type_link
52
+ * @access protected
53
+ * @return String
54
+ */
55
+ protected function _type() {
56
+ if (empty($this->type)) {
57
+ $typeLink = $this->data['resource_type_link'];
58
+ if (empty($typeLink)) return null;
59
+ list($url, $type) = explode('#', $typeLink);
60
+ $this->type = $type;
61
+ }
62
+ return $this->type;
63
+ }
64
+
65
+ /**
66
+ * delete
67
+ *
68
+ * Delete this object from the AWeber system. May not be supported
69
+ * by all entry types.
70
+ * @access public
71
+ * @return boolean Returns true if it is successfully deleted, false
72
+ * if the delete request failed.
73
+ */
74
+ public function delete() {
75
+ $this->adapter->request('DELETE', $this->url, array(), array('return' => 'status'));
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * move
81
+ *
82
+ * Invoke the API method to MOVE an entry resource to a different List.
83
+ *
84
+ * Note: Not all entry resources are eligible to be moved, please
85
+ * refer to the AWeber API Reference Documentation at
86
+ * https://labs.aweber.com/docs/reference/1.0 for more
87
+ * details on which entry resources may be moved and if there
88
+ * are any requirements for moving that resource.
89
+ *
90
+ * @access public
91
+ * @param AWeberEntry(List) List to move Resource (this) too.
92
+ * @return mixed AWeberEntry(Resource) Resource created on List ($list)
93
+ * or False if resource was not created.
94
+ */
95
+ public function move($list, $last_followup_message_number_sent=NULL) {
96
+ # Move Resource
97
+ $params = array(
98
+ 'ws.op' => 'move',
99
+ 'list_link' => $list->self_link
100
+ );
101
+ if (isset($last_followup_message_number_sent)) {
102
+ $params['last_followup_message_number_sent'] = $last_followup_message_number_sent;
103
+ }
104
+
105
+ $data = $this->adapter->request('POST', $this->url, $params, array('return' => 'headers'));
106
+
107
+ # Return new Resource
108
+ $url = $data['Location'];
109
+ $resource_data = $this->adapter->request('GET', $url);
110
+ return new AWeberEntry($resource_data, $url, $this->adapter);
111
+ }
112
+
113
+ /**
114
+ * save
115
+ *
116
+ * Saves the current state of this object if it has been changed.
117
+ * @access public
118
+ * @return void
119
+ */
120
+ public function save() {
121
+ if (!empty($this->_localDiff)) {
122
+ $data = $this->adapter->request('PATCH', $this->url, $this->_localDiff, array('return' => 'status'));
123
+ }
124
+ $this->_localDiff = array();
125
+ return true;
126
+
127
+ }
128
+
129
+ /**
130
+ * __get
131
+ *
132
+ * Used to look up items in data, and special properties like type and
133
+ * child collections dynamically.
134
+ *
135
+ * @param String $value Attribute being accessed
136
+ * @access public
137
+ * @throws AWeberResourceNotImplemented
138
+ * @return mixed
139
+ */
140
+ public function __get($value) {
141
+ if (in_array($value, $this->_privateData)) {
142
+ return null;
143
+ }
144
+ if (!empty($this->data) && array_key_exists($value, $this->data)) {
145
+ if (is_array($this->data[$value])) {
146
+ $array = new AWeberEntryDataArray($this->data[$value], $value, $this);
147
+ $this->data[$value] = $array;
148
+ }
149
+ return $this->data[$value];
150
+ }
151
+ if ($value == 'type') return $this->_type();
152
+ if ($this->_isChildCollection($value)) {
153
+ return $this->_getCollection($value);
154
+ }
155
+ throw new AWeberResourceNotImplemented($this, $value);
156
+ }
157
+
158
+ /**
159
+ * __set
160
+ *
161
+ * If the key provided is part of the data array, then update it in the
162
+ * data array. Otherwise, use the default __set() behavior.
163
+ *
164
+ * @param mixed $key Key of the attr being set
165
+ * @param mixed $value Value being set to the $key attr
166
+ * @access public
167
+ */
168
+ public function __set($key, $value) {
169
+ if (array_key_exists($key, $this->data)) {
170
+ $this->_localDiff[$key] = $value;
171
+ return $this->data[$key] = $value;
172
+ } else {
173
+ return parent::__set($key, $value);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * findSubscribers
179
+ *
180
+ * Looks through all lists for subscribers
181
+ * that match the given filter
182
+ * @access public
183
+ * @return AWeberCollection
184
+ */
185
+ public function findSubscribers($search_data) {
186
+ $this->_methodFor(array('account'));
187
+ $params = array_merge($search_data, array('ws.op' => 'findSubscribers'));
188
+ $data = $this->adapter->request('GET', $this->url, $params);
189
+
190
+ $ts_params = array_merge($params, array('ws.show' => 'total_size'));
191
+ $total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
192
+
193
+ # return collection
194
+ $data['total_size'] = $total_size;
195
+ $url = $this->url . '?'. http_build_query($params);
196
+ return new AWeberCollection($data, $url, $this->adapter);
197
+ }
198
+
199
+ /**
200
+ * getActivity
201
+ *
202
+ * Returns analytics activity for a given subscriber
203
+ * @access public
204
+ * @return AWeberCollection
205
+ */
206
+ public function getActivity() {
207
+ $this->_methodFor(array('subscriber'));
208
+ $params = array('ws.op' => 'getActivity');
209
+ $data = $this->adapter->request('GET', $this->url, $params);
210
+
211
+ $ts_params = array_merge($params, array('ws.show' => 'total_size'));
212
+ $total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
213
+
214
+ # return collection
215
+ $data['total_size'] = $total_size;
216
+ $url = $this->url . '?'. http_build_query($params);
217
+ return new AWeberCollection($data, $url, $this->adapter);
218
+ }
219
+
220
+ /** getParentEntry
221
+ *
222
+ * Gets an entry's parent entry
223
+ * Returns NULL if no parent entry
224
+ */
225
+ public function getParentEntry(){
226
+ $url_parts = explode('/', $this->url);
227
+ $size = count($url_parts);
228
+
229
+ #Remove entry id and slash from end of url
230
+ $url = substr($this->url, 0, -strlen($url_parts[$size-1])-1);
231
+
232
+ #Remove collection name and slash from end of url
233
+ $url = substr($url, 0, -strlen($url_parts[$size-2])-1);
234
+
235
+ try {
236
+ $data = $this->adapter->request('GET', $url);
237
+ return new AWeberEntry($data, $url, $this->adapter);
238
+ } catch (Exception $e) {
239
+ return NULL;
240
+ }
241
+ }
242
+
243
+ /**
244
+ * getWebForms
245
+ *
246
+ * Gets all web_forms for this account
247
+ * @access public
248
+ * @return array
249
+ */
250
+ public function getWebForms() {
251
+ $this->_methodFor(array('account'));
252
+ $data = $this->adapter->request('GET', $this->url.'?ws.op=getWebForms', array(),
253
+ array('allow_empty' => true));
254
+ return $this->_parseNamedOperation($data);
255
+ }
256
+
257
+
258
+ /**
259
+ * getWebFormSplitTests
260
+ *
261
+ * Gets all web_form split tests for this account
262
+ * @access public
263
+ * @return array
264
+ */
265
+ public function getWebFormSplitTests() {
266
+ $this->_methodFor(array('account'));
267
+ $data = $this->adapter->request('GET', $this->url.'?ws.op=getWebFormSplitTests', array(),
268
+ array('allow_empty' => true));
269
+ return $this->_parseNamedOperation($data);
270
+ }
271
+
272
+ /**
273
+ * _parseNamedOperation
274
+ *
275
+ * Turns a dumb array of json into an array of Entries. This is NOT
276
+ * a collection, but simply an array of entries, as returned from a
277
+ * named operation.
278
+ *
279
+ * @param array $data
280
+ * @access protected
281
+ * @return array
282
+ */
283
+ protected function _parseNamedOperation($data) {
284
+ $results = array();
285
+ foreach($data as $entryData) {
286
+ $results[] = new AWeberEntry($entryData, str_replace($this->adapter->app->getBaseUri(), '',
287
+ $entryData['self_link']), $this->adapter);
288
+ }
289
+ return $results;
290
+ }
291
+
292
+ /**
293
+ * _methodFor
294
+ *
295
+ * Raises exception if $this->type is not in array entryTypes.
296
+ * Used to restrict methods to specific entry type(s).
297
+ * @param mixed $entryTypes Array of entry types as strings, ie array('account')
298
+ * @access protected
299
+ * @return void
300
+ */
301
+ protected function _methodFor($entryTypes) {
302
+ if (in_array($this->type, $entryTypes)) return true;
303
+ throw new AWeberMethodNotImplemented($this);
304
+ }
305
+
306
+ /**
307
+ * _getCollection
308
+ *
309
+ * Returns the AWeberCollection object representing the given
310
+ * collection name, relative to this entry.
311
+ *
312
+ * @param String $value The name of the sub-collection
313
+ * @access protected
314
+ * @return AWeberCollection
315
+ */
316
+ protected function _getCollection($value) {
317
+ if (empty($this->_collections[$value])) {
318
+ $url = "{$this->url}/{$value}";
319
+ $data = $this->adapter->request('GET', $url);
320
+ $this->_collections[$value] = new AWeberCollection($data, $url, $this->adapter);
321
+ }
322
+ return $this->_collections[$value];
323
+ }
324
+
325
+
326
+ /**
327
+ * _isChildCollection
328
+ *
329
+ * Is the given name of a collection a child collection of this entry?
330
+ *
331
+ * @param String $value The name of the collection we are looking for
332
+ * @access protected
333
+ * @return boolean
334
+ * @throws AWeberResourceNotImplemented
335
+ */
336
+ protected function _isChildCollection($value) {
337
+ $this->_type();
338
+ if (!empty(AWeberAPI::$_collectionMap[$this->type]) &&
339
+ in_array($value, AWeberAPI::$_collectionMap[$this->type])) return true;
340
+ return false;
341
+ }
342
+
343
+ }
includes/externals/aweber/aweber_entry_data_array.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AWeberEntryDataArray implements ArrayAccess, Countable, Iterator {
4
+ private $counter = 0;
5
+
6
+ protected $data;
7
+ protected $keys;
8
+ protected $name;
9
+ protected $parent;
10
+
11
+ public function __construct($data, $name, $parent) {
12
+ $this->data = $data;
13
+ $this->keys = array_keys($data);
14
+ $this->name = $name;
15
+ $this->parent = $parent;
16
+ }
17
+
18
+ public function count() {
19
+ return sizeOf($this->data);
20
+ }
21
+
22
+ public function offsetExists($offset) {
23
+ return (isset($this->data[$offset]));
24
+ }
25
+
26
+ public function offsetGet($offset) {
27
+ return $this->data[$offset];
28
+ }
29
+
30
+ public function offsetSet($offset, $value) {
31
+ $this->data[$offset] = $value;
32
+ $this->parent->{$this->name} = $this->data;
33
+ return $value;
34
+ }
35
+
36
+ public function offsetUnset($offset) {
37
+ unset($this->data[$offset]);
38
+ }
39
+
40
+ public function rewind() {
41
+ $this->counter = 0;
42
+ }
43
+
44
+ public function current() {
45
+ return $this->data[$this->key()];
46
+ }
47
+
48
+ public function key() {
49
+ return $this->keys[$this->counter];
50
+ }
51
+
52
+ public function next() {
53
+ $this->counter++;
54
+ }
55
+
56
+ public function valid() {
57
+ if ($this->counter >= sizeOf($this->data)) {
58
+ return false;
59
+ }
60
+ return true;
61
+ }
62
+
63
+
64
+ }
65
+
66
+
67
+
68
+ ?>
includes/externals/aweber/aweber_response.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * AWeberResponse
5
+ *
6
+ * Base class for objects that represent a response from the AWeberAPI.
7
+ * Responses will exist as one of the two AWeberResponse subclasses:
8
+ * - AWeberEntry - a single instance of an AWeber resource
9
+ * - AWeberCollection - a collection of AWeber resources
10
+ * @uses AWeberAPIBase
11
+ * @package
12
+ * @version $id$
13
+ */
14
+ class AWeberResponse extends AWeberAPIBase {
15
+
16
+ public $adapter = false;
17
+ public $data = array();
18
+ public $_dynamicData = array();
19
+
20
+ /**
21
+ * __construct
22
+ *
23
+ * Creates a new AWeberRespones
24
+ *
25
+ * @param mixed $response Data returned by the API servers
26
+ * @param mixed $url URL we hit to get the data
27
+ * @param mixed $adapter OAuth adapter used for future interactions
28
+ * @access public
29
+ * @return void
30
+ */
31
+ public function __construct($response, $url, $adapter) {
32
+ $this->adapter = $adapter;
33
+ $this->url = $url;
34
+ $this->data = $response;
35
+ }
36
+
37
+ /**
38
+ * __set
39
+ *
40
+ * Manual re-implementation of __set, allows sub classes to access
41
+ * the default behavior by using the parent:: format.
42
+ *
43
+ * @param mixed $key Key of the attr being set
44
+ * @param mixed $value Value being set to the attr
45
+ * @access public
46
+ */
47
+ public function __set($key, $value) {
48
+ $this->{$key} = $value;
49
+ }
50
+
51
+ /**
52
+ * __get
53
+ *
54
+ * PHP "MagicMethod" to allow for dynamic objects. Defers first to the
55
+ * data in $this->data.
56
+ *
57
+ * @param String $value Name of the attribute requested
58
+ * @access public
59
+ * @return mixed
60
+ */
61
+ public function __get($value) {
62
+ if (in_array($value, $this->_privateData)) {
63
+ return null;
64
+ }
65
+ if (array_key_exists($value, $this->data)) {
66
+ return $this->data[$value];
67
+ }
68
+ if ($value == 'type') return $this->_type();
69
+ }
70
+
71
+ }
72
+
73
+
includes/externals/aweber/curl_object.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * CurlInterface
5
+ *
6
+ * An object-oriented shim that wraps the standard PHP cURL library.
7
+ *
8
+ * This interface has been created so that cURL functionality can be stubbed
9
+ * out for unit testing, or swapped for an alternative library.
10
+ *
11
+ * @see curl
12
+ * @package
13
+ * @version $id$
14
+ */
15
+ interface CurlInterface {
16
+
17
+ /**
18
+ * errNo
19
+ *
20
+ * Encapsulates curl_errno - Returns the last error number
21
+ * @param resource $ch - A cURL handle returned by init.
22
+ * @access public
23
+ * @return the error number or 0 if no error occured.
24
+ */
25
+ public function errno($ch);
26
+
27
+ /**
28
+ * error
29
+ *
30
+ * Encapsulates curl_error - Return last error string
31
+ * @param resource $ch - A cURL handle returned by init.
32
+ * @access public
33
+ * @return the error messge or '' if no error occured.
34
+ */
35
+ public function error($ch);
36
+
37
+ /**
38
+ * execute
39
+ *
40
+ * Encapsulates curl_exec - Perform a cURL session.
41
+ * @param resource $ch - A cURL handle returned by init.
42
+ * @access public
43
+ * @return TRUE on success, FALSE on failure.
44
+ */
45
+ public function execute($ch);
46
+
47
+ /**
48
+ * init
49
+ *
50
+ * Encapsulates curl_init - Initialize a cURL session.
51
+ * @param string $url - url to use.
52
+ * @access public
53
+ * @return cURL handle on success, FALSE on failure.
54
+ */
55
+ public function init($url);
56
+
57
+ /**
58
+ * setopt
59
+ *
60
+ * Encapsulates curl_setopt - Set an option for cURL transfer.
61
+ * @param resource $ch - A cURL handle returned by init.
62
+ * @param int $opt - The CURLOPT to set.
63
+ * @param mixed $value - The value to set.
64
+ * @access public
65
+ * @return True on success, FALSE on failure.
66
+ */
67
+ public function setopt ($ch , $option , $value);
68
+ }
69
+
70
+
71
+ /**
72
+ * CurlObject
73
+ *
74
+ * A concrete implementation of CurlInterface using the PHP cURL library.
75
+ *
76
+ * @package
77
+ * @version $id$
78
+ */
79
+ class CurlObject implements CurlInterface {
80
+
81
+ public function errno($ch) {
82
+ return curl_errno($ch);
83
+ }
84
+
85
+ public function error($ch) {
86
+ return curl_error($ch);
87
+ }
88
+
89
+ public function execute($ch) {
90
+ return curl_exec($ch);
91
+ }
92
+
93
+ public function init($url) {
94
+ return curl_init($url);
95
+ }
96
+
97
+ public function setopt ($ch , $option , $value) {
98
+ return curl_setopt($ch, $option, $value);
99
+ }
100
+
101
+ }
102
+
103
+ ?>
includes/externals/aweber/curl_response.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ # CurlResponse
4
+ #
5
+ # Author Sean Huber - shuber@huberry.com
6
+ # Date May 2008
7
+ #
8
+ # A basic CURL wrapper for PHP
9
+ #
10
+ # See the README for documentation/examples or http://php.net/curl for more information
11
+ # about the libcurl extension for PHP -- http://github.com/shuber/curl/tree/master
12
+ #
13
+
14
+ class CurlResponse
15
+ {
16
+ public $body = '';
17
+ public $headers = array();
18
+
19
+ public function __construct($response)
20
+ {
21
+ # Extract headers from response
22
+ $pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
23
+ preg_match_all($pattern, $response, $matches);
24
+ $headers = explode("\r\n", str_replace("\r\n\r\n", '', array_pop($matches[0])));
25
+
26
+ # Extract the version and status from the first header
27
+ $version_and_status = array_shift($headers);
28
+ preg_match('#HTTP/(\d\.\d)\s(\d\d\d)\s(.*)#', $version_and_status, $matches);
29
+ $this->headers['Http-Version'] = $matches[1];
30
+ $this->headers['Status-Code'] = $matches[2];
31
+ $this->headers['Status'] = $matches[2].' '.$matches[3];
32
+
33
+ # Convert headers into an associative array
34
+ foreach ($headers as $header) {
35
+ preg_match('#(.*?)\:\s(.*)#', $header, $matches);
36
+ $this->headers[$matches[1]] = $matches[2];
37
+ }
38
+
39
+ # Remove the headers from the response body
40
+ $this->body = preg_replace($pattern, '', $response);
41
+ }
42
+
43
+ public function __toString()
44
+ {
45
+ return $this->body;
46
+ }
47
+
48
+ public function headers(){
49
+ return $this->headers;
50
+ }
51
+ }
includes/externals/aweber/exceptions.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AWeberException extends Exception { }
4
+
5
+ /**
6
+ * Thrown when the API returns an error. (HTTP status >= 400)
7
+ *
8
+ *
9
+ * @uses AWeberException
10
+ * @package
11
+ * @version $id$
12
+ */
13
+ class AWeberAPIException extends AWeberException {
14
+
15
+ public $type;
16
+ public $status;
17
+ public $message;
18
+ public $documentation_url;
19
+ public $url;
20
+
21
+ public function __construct($error, $url) {
22
+ // record specific details of the API exception for processing
23
+ $this->url = $url;
24
+ $this->type = $error['type'];
25
+ $this->status = array_key_exists('status', $error) ? $error['status'] : '';
26
+ $this->message = $error['message'];
27
+ $this->documentation_url = $error['documentation_url'];
28
+
29
+ parent::__construct($this->message);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Thrown when attempting to use a resource that is not implemented.
35
+ *
36
+ * @uses AWeberException
37
+ * @package
38
+ * @version $id$
39
+ */
40
+ class AWeberResourceNotImplemented extends AWeberException {
41
+
42
+ public function __construct($object, $value) {
43
+ $this->object = $object;
44
+ $this->value = $value;
45
+ parent::__construct("Resource \"{$value}\" is not implemented on this resource.");
46
+ }
47
+ }
48
+
49
+ /**
50
+ * AWeberMethodNotImplemented
51
+ *
52
+ * Thrown when attempting to call a method that is not implemented for a resource
53
+ * / collection. Differs from standard method not defined errors, as this will
54
+ * be thrown when the method is infact implemented on the base class, but the
55
+ * current resource type does not provide access to that method (ie calling
56
+ * getByMessageNumber on a web_forms collection).
57
+ *
58
+ * @uses AWeberException
59
+ * @package
60
+ * @version $id$
61
+ */
62
+ class AWeberMethodNotImplemented extends AWeberException {
63
+
64
+ public function __construct($object) {
65
+ $this->object = $object;
66
+ parent::__construct("This method is not implemented by the current resource.");
67
+
68
+ }
69
+ }
70
+
71
+ /**
72
+ * AWeberOAuthException
73
+ *
74
+ * OAuth exception, as generated by an API JSON error response
75
+ * @uses AWeberException
76
+ * @package
77
+ * @version $id$
78
+ */
79
+ class AWeberOAuthException extends AWeberException {
80
+
81
+ public function __construct($type, $message) {
82
+ $this->type = $type;
83
+ $this->message = $message;
84
+ parent::__construct("{$type}: {$message}");
85
+ }
86
+ }
87
+
88
+ /**
89
+ * AWeberOAuthDataMissing
90
+ *
91
+ * Used when a specific piece or pieces of data was not found in the
92
+ * response. This differs from the exception that might be thrown as
93
+ * an AWeberOAuthException when parameters are not provided because
94
+ * it is not the servers' expectations that were not met, but rather
95
+ * the expecations of the client were not met by the server.
96
+ *
97
+ * @uses AWeberException
98
+ * @package
99
+ * @version $id$
100
+ */
101
+ class AWeberOAuthDataMissing extends AWeberException {
102
+
103
+ public function __construct($missing) {
104
+ if (!is_array($missing)) $missing = array($missing);
105
+ $this->missing = $missing;
106
+ $required = join(', ', $this->missing);
107
+ parent::__construct("OAuthDataMissing: Response was expected to contain: {$required}");
108
+
109
+ }
110
+ }
111
+
112
+ /**
113
+ * AWeberResponseError
114
+ *
115
+ * This is raised when the server returns a non-JSON response. This
116
+ * should only occur when there is a server or some type of connectivity
117
+ * issue.
118
+ *
119
+ * @uses AWeberException
120
+ * @package
121
+ * @version $id$
122
+ */
123
+ class AWeberResponseError extends AWeberException {
124
+
125
+ public function __construct($uri) {
126
+ $this->uri = $uri;
127
+ parent::__construct("Request for {$uri} did not respond properly.");
128
+ }
129
+
130
+ }
includes/externals/aweber/oauth_adapter.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface AWeberOAuthAdapter {
4
+
5
+ public function request($method, $uri, $data = array());
6
+ public function getRequestToken($callbackUrl=false);
7
+
8
+ }
9
+
10
+
11
+ ?>
includes/externals/aweber/oauth_application.php ADDED
@@ -0,0 +1,681 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!class_exists('CurlObject')) require_once('curl_object.php');
3
+ if (!class_exists('CurlResponse')) require_once('curl_response.php');
4
+
5
+ /**
6
+ * OAuthServiceProvider
7
+ *
8
+ * Represents the service provider in the OAuth authentication model.
9
+ * The class that implements the service provider will contain the
10
+ * specific knowledge about the API we are interfacing with, and
11
+ * provide useful methods for interfacing with its API.
12
+ *
13
+ * For example, an OAuthServiceProvider would know the URLs necessary
14
+ * to perform specific actions, the type of data that the API calls
15
+ * would return, and would be responsible for manipulating the results
16
+ * into a useful manner.
17
+ *
18
+ * It should be noted that the methods enforced by the OAuthServiceProvider
19
+ * interface are made so that it can interact with our OAuthApplication
20
+ * cleanly, rather than from a general use perspective, though some
21
+ * methods for those purposes do exists (such as getUserData).
22
+ *
23
+ * @package
24
+ * @version $id$
25
+ */
26
+ interface OAuthServiceProvider {
27
+
28
+ public function getAccessTokenUrl();
29
+ public function getAuthorizeUrl();
30
+ public function getRequestTokenUrl();
31
+ public function getAuthTokenFromUrl();
32
+ public function getBaseUri();
33
+ public function getUserData();
34
+
35
+ }
36
+
37
+ /**
38
+ * OAuthApplication
39
+ *
40
+ * Base class to represent an OAuthConsumer application. This class is
41
+ * intended to be extended and modified for each ServiceProvider. Each
42
+ * OAuthServiceProvider should have a complementary OAuthApplication
43
+ *
44
+ * The OAuthApplication class should contain any details on preparing
45
+ * requires that is unique or specific to that specific service provider's
46
+ * implementation of the OAuth model.
47
+ *
48
+ * This base class is based on OAuth 1.0, designed with AWeber's implementation
49
+ * as a model. An OAuthApplication built to work with a different service
50
+ * provider (especially an OAuth2.0 Application) may alter or bypass portions
51
+ * of the logic in this class to meet the needs of the service provider it
52
+ * is designed to interface with.
53
+ *
54
+ * @package
55
+ * @version $id$
56
+ */
57
+ class OAuthApplication implements AWeberOAuthAdapter {
58
+ public $debug = false;
59
+
60
+ public $userAgent = 'AWeber OAuth Consumer Application 1.0 - https://labs.aweber.com/';
61
+
62
+ public $format = false;
63
+
64
+ public $requiresTokenSecret = true;
65
+
66
+ public $signatureMethod = 'HMAC-SHA1';
67
+ public $version = '1.0';
68
+
69
+ public $curl = false;
70
+
71
+ /**
72
+ * @var OAuthUser User currently interacting with the service provider
73
+ */
74
+ public $user = false;
75
+
76
+ // Data binding this OAuthApplication to the consumer application it is acting
77
+ // as a proxy for
78
+ public $consumerKey = false;
79
+ public $consumerSecret = false;
80
+
81
+ /**
82
+ * __construct
83
+ *
84
+ * Create a new OAuthApplication, based on an OAuthServiceProvider
85
+ * @access public
86
+ * @return void
87
+ */
88
+ public function __construct($parentApp = false) {
89
+ if ($parentApp) {
90
+ if (!is_a($parentApp, 'OAuthServiceProvider')) {
91
+ throw new Exception('Parent App must be a valid OAuthServiceProvider!');
92
+ }
93
+ $this->app = $parentApp;
94
+ }
95
+ $this->user = new OAuthUser();
96
+ $this->curl = new CurlObject();
97
+ }
98
+
99
+ /**
100
+ * request
101
+ *
102
+ * Implemented for a standard OAuth adapter interface
103
+ * @param mixed $method
104
+ * @param mixed $uri
105
+ * @param array $data
106
+ * @param array $options
107
+ * @access public
108
+ * @return void
109
+ */
110
+ public function request($method, $uri, $data = array(), $options = array()) {
111
+ $uri = $this->app->removeBaseUri($uri);
112
+ $url = $this->app->getBaseUri() . $uri;
113
+
114
+ # WARNING: non-primative items in data must be json serialized in GET and POST.
115
+ if ($method == 'POST' or $method == 'GET') {
116
+ foreach ($data as $key => $value) {
117
+ if (is_array($value)) {
118
+ $data[$key] = json_encode($value);
119
+ }
120
+ }
121
+ }
122
+
123
+ $response = $this->makeRequest($method, $url, $data);
124
+ if (!empty($options['return'])) {
125
+ if ($options['return'] == 'status') {
126
+ return $response->headers['Status-Code'];
127
+ }
128
+ if ($options['return'] == 'headers') {
129
+ return $response->headers;
130
+ }
131
+ if ($options['return'] == 'integer') {
132
+ return intval($response->body);
133
+ }
134
+ }
135
+
136
+ $data = json_decode($response->body, true);
137
+
138
+ if (empty($options['allow_empty']) && !isset($data)) {
139
+ throw new AWeberResponseError($uri);
140
+ }
141
+ return $data;
142
+ }
143
+
144
+ /**
145
+ * getRequestToken
146
+ *
147
+ * Gets a new request token / secret for this user.
148
+ * @access public
149
+ * @return void
150
+ */
151
+ public function getRequestToken($callbackUrl=false) {
152
+ $data = ($callbackUrl)? array('oauth_callback' => $callbackUrl) : array();
153
+ $resp = $this->makeRequest('POST', $this->app->getRequestTokenUrl(), $data);
154
+ $data = $this->parseResponse($resp);
155
+ $this->requiredFromResponse($data, array('oauth_token', 'oauth_token_secret'));
156
+ $this->user->requestToken = $data['oauth_token'];
157
+ $this->user->tokenSecret = $data['oauth_token_secret'];
158
+ return $data['oauth_token'];
159
+ }
160
+
161
+ /**
162
+ * getAccessToken
163
+ *
164
+ * Makes a request for access tokens. Requires that the current user has an authorized
165
+ * token and token secret.
166
+ *
167
+ * @access public
168
+ * @return void
169
+ */
170
+ public function getAccessToken() {
171
+ $resp = $this->makeRequest('POST', $this->app->getAccessTokenUrl(),
172
+ array('oauth_verifier' => $this->user->verifier)
173
+ );
174
+ $data = $this->parseResponse($resp);
175
+ $this->requiredFromResponse($data, array('oauth_token', 'oauth_token_secret'));
176
+
177
+ if (empty($data['oauth_token'])) {
178
+ throw new AWeberOAuthDataMissing('oauth_token');
179
+ }
180
+
181
+ $this->user->accessToken = $data['oauth_token'];
182
+ $this->user->tokenSecret = $data['oauth_token_secret'];
183
+ return array($data['oauth_token'], $data['oauth_token_secret']);
184
+ }
185
+
186
+ /**
187
+ * parseAsError
188
+ *
189
+ * Checks if response is an error. If it is, raise an appropriately
190
+ * configured exception.
191
+ *
192
+ * @param mixed $response Data returned from the server, in array form
193
+ * @access public
194
+ * @throws AWeberOAuthException
195
+ * @return void
196
+ */
197
+ public function parseAsError($response) {
198
+ if (!empty($response['error'])) {
199
+ throw new AWeberOAuthException($response['error']['type'],
200
+ $response['error']['message']);
201
+ }
202
+ }
203
+
204
+ /**
205
+ * requiredFromResponse
206
+ *
207
+ * Enforce that all the fields in requiredFields are present and not
208
+ * empty in data. If a required field is empty, throw an exception.
209
+ *
210
+ * @param mixed $data Array of data
211
+ * @param mixed $requiredFields Array of required field names.
212
+ * @access protected
213
+ * @return void
214
+ */
215
+ protected function requiredFromResponse($data, $requiredFields) {
216
+ foreach ($requiredFields as $field) {
217
+ if (empty($data[$field])) {
218
+ throw new AWeberOAuthDataMissing($field);
219
+ }
220
+ }
221
+ }
222
+
223
+ /**
224
+ * get
225
+ *
226
+ * Make a get request. Used to exchange user tokens with serice provider.
227
+ * @param mixed $url URL to make a get request from.
228
+ * @param array $data Data for the request.
229
+ * @access protected
230
+ * @return void
231
+ */
232
+ protected function get($url, $data) {
233
+ $url = $this->_addParametersToUrl($url, $data);
234
+ $handle = $this->curl->init($url);
235
+ $resp = $this->_sendRequest($handle);
236
+ return $resp;
237
+ }
238
+
239
+ /**
240
+ * _addParametersToUrl
241
+ *
242
+ * Adds the parameters in associative array $data to the
243
+ * given URL
244
+ * @param String $url URL
245
+ * @param array $data Parameters to be added as a query string to
246
+ * the URL provided
247
+ * @access protected
248
+ * @return void
249
+ */
250
+ protected function _addParametersToUrl($url, $data) {
251
+ if (!empty($data)) {
252
+ if (strpos($url, '?') === false) {
253
+ $url .= '?'.$this->buildData($data);
254
+ } else {
255
+ $url .= '&'.$this->buildData($data);
256
+ }
257
+ }
258
+ return $url;
259
+ }
260
+
261
+ /**
262
+ * generateNonce
263
+ *
264
+ * Generates a 'nonce', which is a unique request id based on the
265
+ * timestamp. If no timestamp is provided, generate one.
266
+ * @param mixed $timestamp Either a timestamp (epoch seconds) or false,
267
+ * in which case it will generate a timestamp.
268
+ * @access public
269
+ * @return string Returns a unique nonce
270
+ */
271
+ public function generateNonce($timestamp = false) {
272
+ if (!$timestamp) $timestamp = $this->generateTimestamp();
273
+ return md5($timestamp.'-'.rand(10000,99999).'-'.uniqid());
274
+ }
275
+
276
+ /**
277
+ * generateTimestamp
278
+ *
279
+ * Generates a timestamp, in seconds
280
+ * @access public
281
+ * @return int Timestamp, in epoch seconds
282
+ */
283
+ public function generateTimestamp() {
284
+ return time();
285
+ }
286
+
287
+ /**
288
+ * createSignature
289
+ *
290
+ * Creates a signature on the signature base and the signature key
291
+ * @param mixed $sigBase Base string of data to sign
292
+ * @param mixed $sigKey Key to sign the data with
293
+ * @access public
294
+ * @return string The signature
295
+ */
296
+ public function createSignature($sigBase, $sigKey) {
297
+ switch ($this->signatureMethod) {
298
+ case 'HMAC-SHA1':
299
+ default:
300
+ return base64_encode(hash_hmac('sha1', $sigBase, $sigKey, true));
301
+ }
302
+ }
303
+
304
+ /**
305
+ * encode
306
+ *
307
+ * Short-cut for utf8_encode / rawurlencode
308
+ * @param mixed $data Data to encode
309
+ * @access protected
310
+ * @return void Encoded data
311
+ */
312
+ protected function encode($data) {
313
+ return rawurlencode(utf8_encode($data));
314
+ }
315
+
316
+ /**
317
+ * createSignatureKey
318
+ *
319
+ * Creates a key that will be used to sign our signature. Signatures
320
+ * are signed with the consumerSecret for this consumer application and
321
+ * the token secret of the user that the application is acting on behalf
322
+ * of.
323
+ * @access public
324
+ * @return void
325
+ */
326
+ public function createSignatureKey() {
327
+ return $this->consumerSecret.'&'.$this->user->tokenSecret;
328
+ }
329
+
330
+ /**
331
+ * getOAuthRequestData
332
+ *
333
+ * Get all the pre-signature, OAuth specific parameters for a request.
334
+ * @access public
335
+ * @return void
336
+ */
337
+ public function getOAuthRequestData() {
338
+ $token = $this->user->getHighestPriorityToken();
339
+ $ts = $this->generateTimestamp();
340
+ $nonce = $this->generateNonce($ts);
341
+ return array(
342
+ 'oauth_token' => $token,
343
+ 'oauth_consumer_key' => $this->consumerKey,
344
+ 'oauth_version' => $this->version,
345
+ 'oauth_timestamp' => $ts,
346
+ 'oauth_signature_method' => $this->signatureMethod,
347
+ 'oauth_nonce' => $nonce);
348
+ }
349
+
350
+
351
+ /**
352
+ * mergeOAuthData
353
+ *
354
+ * @param mixed $requestData
355
+ * @access public
356
+ * @return void
357
+ */
358
+ public function mergeOAuthData($requestData) {
359
+ $oauthData = $this->getOAuthRequestData();
360
+ return array_merge($requestData, $oauthData);
361
+ }
362
+
363
+ /**
364
+ * createSignatureBase
365
+ *
366
+ * @param mixed $method String name of HTTP method, such as "GET"
367
+ * @param mixed $url URL where this request will go
368
+ * @param mixed $data Array of params for this request. This should
369
+ * include ALL oauth properties except for the signature.
370
+ * @access public
371
+ * @return void
372
+ */
373
+ public function createSignatureBase($method, $url, $data) {
374
+ $method = $this->encode(strtoupper($method));
375
+ $query = parse_url($url, PHP_URL_QUERY);
376
+ if ($query) {
377
+ $parts = explode('?', $url, 2);
378
+ $url = array_shift($parts);
379
+ $items = explode('&', $query);
380
+ foreach ($items as $item) {
381
+ list($key, $value) = explode('=', $item);
382
+ $data[rawurldecode($key)] = rawurldecode($value);
383
+ }
384
+ }
385
+ $url = $this->encode($url);
386
+ $data = $this->encode($this->collapseDataForSignature($data));
387
+ return $method.'&'.$url.'&'.$data;
388
+ }
389
+
390
+ /**
391
+ * collapseDataForSignature
392
+ *
393
+ * Turns an array of request data into a string, as used by the oauth
394
+ * signature
395
+ * @param mixed $data
396
+ * @access public
397
+ * @return void
398
+ */
399
+ public function collapseDataForSignature($data) {
400
+ ksort($data);
401
+ $collapse = '';
402
+ foreach ($data as $key => $val) {
403
+ if (!empty($collapse)) $collapse .= '&';
404
+ $collapse .= $key.'='.$this->encode($val);
405
+ }
406
+ return $collapse;
407
+ }
408
+
409
+ /**
410
+ * signRequest
411
+ *
412
+ * Signs the request.
413
+ *
414
+ * @param mixed $method HTTP method
415
+ * @param mixed $url URL for the request
416
+ * @param mixed $data The data to be signed
417
+ * @access public
418
+ * @return array The data, with the signature.
419
+ */
420
+ public function signRequest($method, $url, $data) {
421
+ $base = $this->createSignatureBase($method, $url, $data);
422
+ $key = $this->createSignatureKey();
423
+ $data['oauth_signature'] = $this->createSignature($base, $key);
424
+ ksort($data);
425
+ return $data;
426
+ }
427
+
428
+
429
+ /**
430
+ * makeRequest
431
+ *
432
+ * Public facing function to make a request
433
+ *
434
+ * @param mixed $method
435
+ * @param mixed $url - Reserved characters in query params MUST be escaped
436
+ * @param mixed $data - Reserved characters in values MUST NOT be escaped
437
+ * @access public
438
+ * @return void
439
+ */
440
+ public function makeRequest($method, $url, $data=array()) {
441
+
442
+ if ($this->debug) echo "\n** {$method}: $url\n";
443
+
444
+ switch (strtoupper($method)) {
445
+ case 'POST':
446
+ $oauth = $this->prepareRequest($method, $url, $data);
447
+ $resp = $this->post($url, $oauth);
448
+ break;
449
+
450
+ case 'GET':
451
+ $oauth = $this->prepareRequest($method, $url, $data);
452
+ $resp = $this->get($url, $oauth, $data);
453
+ break;
454
+
455
+ case 'DELETE':
456
+ $oauth = $this->prepareRequest($method, $url, $data);
457
+ $resp = $this->delete($url, $oauth);
458
+ break;
459
+
460
+ case 'PATCH':
461
+ $oauth = $this->prepareRequest($method, $url, array());
462
+ $resp = $this->patch($url, $oauth, $data);
463
+ break;
464
+ }
465
+
466
+ // enable debug output
467
+ if ($this->debug) {
468
+ echo "<pre>";
469
+ print_r($oauth);
470
+ echo " --> Status: {$resp->headers['Status-Code']}\n";
471
+ echo " --> Body: {$resp->body}";
472
+ echo "</pre>";
473
+ }
474
+
475
+ if (!$resp) {
476
+ $msg = 'Unable to connect to the AWeber API. (' . $this->error . ')';
477
+ $error = array('message' => $msg, 'type' => 'APIUnreachableError',
478
+ 'documentation_url' => 'https://labs.aweber.com/docs/troubleshooting');
479
+ throw new AWeberAPIException($error, $url);
480
+ }
481
+
482
+ if($resp->headers['Status-Code'] >= 400) {
483
+ $data = json_decode($resp->body, true);
484
+ throw new AWeberAPIException($data['error'], $url);
485
+ }
486
+
487
+ return $resp;
488
+ }
489
+
490
+ /**
491
+ * put
492
+ *
493
+ * Prepare an OAuth put method.
494
+ *
495
+ * @param mixed $url URL where we are making the request to
496
+ * @param mixed $data Data that is used to make the request
497
+ * @access protected
498
+ * @return void
499
+ */
500
+ protected function patch($url, $oauth, $data) {
501
+ $url = $this->_addParametersToUrl($url, $oauth);
502
+ $handle = $this->curl->init($url);
503
+ $this->curl->setopt($handle, CURLOPT_CUSTOMREQUEST, 'PATCH');
504
+ $this->curl->setopt($handle, CURLOPT_POSTFIELDS, json_encode($data));
505
+ $resp = $this->_sendRequest($handle, array('Expect:', 'Content-Type: application/json'));
506
+ return $resp;
507
+ }
508
+
509
+ /**
510
+ * post
511
+ *
512
+ * Prepare an OAuth post method.
513
+ *
514
+ * @param mixed $url URL where we are making the request to
515
+ * @param mixed $data Data that is used to make the request
516
+ * @access protected
517
+ * @return void
518
+ */
519
+ protected function post($url, $oauth) {
520
+ $handle = $this->curl->init($url);
521
+ $postData = $this->buildData($oauth);
522
+ $this->curl->setopt($handle, CURLOPT_POST, true);
523
+ $this->curl->setopt($handle, CURLOPT_POSTFIELDS, $postData);
524
+ $resp = $this->_sendRequest($handle);
525
+ return $resp;
526
+ }
527
+
528
+ /**
529
+ * delete
530
+ *
531
+ * Makes a DELETE request
532
+ * @param mixed $url URL where we are making the request to
533
+ * @param mixed $data Data that is used in the request
534
+ * @access protected
535
+ * @return void
536
+ */
537
+ protected function delete($url, $data) {
538
+ $url = $this->_addParametersToUrl($url, $data);
539
+ $handle = $this->curl->init($url);
540
+ $this->curl->setopt($handle, CURLOPT_CUSTOMREQUEST, 'DELETE');
541
+ $resp = $this->_sendRequest($handle);
542
+ return $resp;
543
+ }
544
+
545
+ /**
546
+ * buildData
547
+ *
548
+ * Creates a string of data for either post or get requests.
549
+ * @param mixed $data Array of key value pairs
550
+ * @access public
551
+ * @return void
552
+ */
553
+ public function buildData($data) {
554
+ ksort($data);
555
+ $params = array();
556
+ foreach ($data as $key => $value) {
557
+ $params[] = $key.'='.$this->encode($value);
558
+ }
559
+ return implode('&', $params);
560
+ }
561
+
562
+ /**
563
+ * _sendRequest
564
+ *
565
+ * Actually makes a request.
566
+ * @param mixed $handle Curl handle
567
+ * @param array $headers Additional headers needed for request
568
+ * @access private
569
+ * @return void
570
+ */
571
+ private function _sendRequest($handle, $headers = array('Expect:')) {
572
+ $this->curl->setopt($handle, CURLOPT_RETURNTRANSFER, true);
573
+ $this->curl->setopt($handle, CURLOPT_HEADER, true);
574
+ $this->curl->setopt($handle, CURLOPT_HTTPHEADER, $headers);
575
+ $this->curl->setopt($handle, CURLOPT_USERAGENT, $this->userAgent);
576
+ $this->curl->setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE);
577
+ $this->curl->setopt($handle, CURLOPT_VERBOSE, FALSE);
578
+ $this->curl->setopt($handle, CURLOPT_CONNECTTIMEOUT, 10);
579
+ $this->curl->setopt($handle, CURLOPT_TIMEOUT, 90);
580
+ $resp = $this->curl->execute($handle);
581
+ if ($resp) {
582
+ return new CurlResponse($resp);
583
+ }
584
+ $this->error = $this->curl->errno($handle) . ' - ' .
585
+ $this->curl->error($handle);
586
+ return false;
587
+ }
588
+
589
+ /**
590
+ * prepareRequest
591
+ *
592
+ * @param mixed $method HTTP method
593
+ * @param mixed $url URL for the request
594
+ * @param mixed $data The data to generate oauth data and be signed
595
+ * @access public
596
+ * @return void The data, with all its OAuth variables and signature
597
+ */
598
+ public function prepareRequest($method, $url, $data) {
599
+ $data = $this->mergeOAuthData($data);
600
+ $data = $this->signRequest($method, $url, $data);
601
+ return $data;
602
+ }
603
+
604
+ /**
605
+ * parseResponse
606
+ *
607
+ * Parses the body of the response into an array
608
+ * @param mixed $string The body of a response
609
+ * @access public
610
+ * @return void
611
+ */
612
+ public function parseResponse($resp) {
613
+ $data = array();
614
+
615
+ if (!$resp) { return $data; }
616
+ if (empty($resp)) { return $data; }
617
+ if (empty($resp->body)) { return $data; }
618
+
619
+ switch ($this->format) {
620
+ case 'json':
621
+ $data = json_decode($resp->body);
622
+ break;
623
+ default:
624
+ parse_str($resp->body, $data);
625
+ }
626
+ $this->parseAsError($data);
627
+ return $data;
628
+ }
629
+
630
+ }
631
+
632
+ /**
633
+ * OAuthUser
634
+ *
635
+ * Simple data class representing the user in an OAuth application.
636
+ * @package
637
+ * @version $id$
638
+ */
639
+ class OAuthUser {
640
+
641
+ public $authorizedToken = false;
642
+ public $requestToken = false;
643
+ public $verifier = false;
644
+ public $tokenSecret = false;
645
+ public $accessToken = false;
646
+
647
+ /**
648
+ * isAuthorized
649
+ *
650
+ * Checks if this user is authorized.
651
+ * @access public
652
+ * @return void
653
+ */
654
+ public function isAuthorized() {
655
+ if (empty($this->authorizedToken) && empty($this->accessToken)) {
656
+ return false;
657
+ }
658
+ return true;
659
+ }
660
+
661
+
662
+ /**
663
+ * getHighestPriorityToken
664
+ *
665
+ * Returns highest priority token - used to define authorization
666
+ * state for a given OAuthUser
667
+ * @access public
668
+ * @return void
669
+ */
670
+ public function getHighestPriorityToken() {
671
+ if (!empty($this->accessToken)) return $this->accessToken;
672
+ if (!empty($this->authorizedToken)) return $this->authorizedToken;
673
+ if (!empty($this->requestToken)) return $this->requestToken;
674
+
675
+ // Return no token, new user
676
+ return '';
677
+ }
678
+
679
+ }
680
+
681
+ ?>
includes/externals/mailchimp/{nc-mcapi.inc.php → Mailchimp-o.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package Xtnls\MailChimp
14
  * @since 3.0
15
  */
16
- class NC_MCAPI {
17
  var $version = "1.3";
18
  var $errorMessage;
19
  var $errorCode;
@@ -49,7 +49,7 @@ class NC_MCAPI {
49
  * @param string $apikey Your MailChimp apikey
50
  * @param string $secure Whether or not this should use a secure connection
51
  */
52
- function NC_MCAPI($apikey, $secure=false) {
53
  $this->secure = $secure;
54
  $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
55
  $this->api_key = $apikey;
13
  * @package Xtnls\MailChimp
14
  * @since 3.0
15
  */
16
+ class Mailchimp_o {
17
  var $version = "1.3";
18
  var $errorMessage;
19
  var $errorCode;
49
  * @param string $apikey Your MailChimp apikey
50
  * @param string $secure Whether or not this should use a secure connection
51
  */
52
+ function Mailchimp_o($apikey, $secure=false) {
53
  $this->secure = $secure;
54
  $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
55
  $this->api_key = $apikey;
includes/externals/mailchimp/Mailchimp.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mailchimp/Folders.php';
4
+ require_once 'Mailchimp/Templates.php';
5
+ require_once 'Mailchimp/Users.php';
6
+ require_once 'Mailchimp/Helper.php';
7
+ require_once 'Mailchimp/Mobile.php';
8
+ require_once 'Mailchimp/Conversations.php';
9
+ require_once 'Mailchimp/Ecomm.php';
10
+ require_once 'Mailchimp/Neapolitan.php';
11
+ require_once 'Mailchimp/Lists.php';
12
+ require_once 'Mailchimp/Campaigns.php';
13
+ require_once 'Mailchimp/Vip.php';
14
+ require_once 'Mailchimp/Reports.php';
15
+ require_once 'Mailchimp/Gallery.php';
16
+ require_once 'Mailchimp/Goal.php';
17
+ require_once 'Mailchimp/Exceptions.php';
18
+
19
+ class Mailchimp {
20
+
21
+ public $apikey;
22
+ public $ch;
23
+ public $root = 'https://api.mailchimp.com/2.0';
24
+ public $debug = false;
25
+
26
+ public static $error_map = array(
27
+ "ValidationError" => "Mailchimp_ValidationError",
28
+ "ServerError_MethodUnknown" => "Mailchimp_ServerError_MethodUnknown",
29
+ "ServerError_InvalidParameters" => "Mailchimp_ServerError_InvalidParameters",
30
+ "Unknown_Exception" => "Mailchimp_Unknown_Exception",
31
+ "Request_TimedOut" => "Mailchimp_Request_TimedOut",
32
+ "Zend_Uri_Exception" => "Mailchimp_Zend_Uri_Exception",
33
+ "PDOException" => "Mailchimp_PDOException",
34
+ "Avesta_Db_Exception" => "Mailchimp_Avesta_Db_Exception",
35
+ "XML_RPC2_Exception" => "Mailchimp_XML_RPC2_Exception",
36
+ "XML_RPC2_FaultException" => "Mailchimp_XML_RPC2_FaultException",
37
+ "Too_Many_Connections" => "Mailchimp_Too_Many_Connections",
38
+ "Parse_Exception" => "Mailchimp_Parse_Exception",
39
+ "User_Unknown" => "Mailchimp_User_Unknown",
40
+ "User_Disabled" => "Mailchimp_User_Disabled",
41
+ "User_DoesNotExist" => "Mailchimp_User_DoesNotExist",
42
+ "User_NotApproved" => "Mailchimp_User_NotApproved",
43
+ "Invalid_ApiKey" => "Mailchimp_Invalid_ApiKey",
44
+ "User_UnderMaintenance" => "Mailchimp_User_UnderMaintenance",
45
+ "Invalid_AppKey" => "Mailchimp_Invalid_AppKey",
46
+ "Invalid_IP" => "Mailchimp_Invalid_IP",
47
+ "User_DoesExist" => "Mailchimp_User_DoesExist",
48
+ "User_InvalidRole" => "Mailchimp_User_InvalidRole",
49
+ "User_InvalidAction" => "Mailchimp_User_InvalidAction",
50
+ "User_MissingEmail" => "Mailchimp_User_MissingEmail",
51
+ "User_CannotSendCampaign" => "Mailchimp_User_CannotSendCampaign",
52
+ "User_MissingModuleOutbox" => "Mailchimp_User_MissingModuleOutbox",
53
+ "User_ModuleAlreadyPurchased" => "Mailchimp_User_ModuleAlreadyPurchased",
54
+ "User_ModuleNotPurchased" => "Mailchimp_User_ModuleNotPurchased",
55
+ "User_NotEnoughCredit" => "Mailchimp_User_NotEnoughCredit",
56
+ "MC_InvalidPayment" => "Mailchimp_MC_InvalidPayment",
57
+ "List_DoesNotExist" => "Mailchimp_List_DoesNotExist",
58
+ "List_InvalidInterestFieldType" => "Mailchimp_List_InvalidInterestFieldType",
59
+ "List_InvalidOption" => "Mailchimp_List_InvalidOption",
60
+ "List_InvalidUnsubMember" => "Mailchimp_List_InvalidUnsubMember",
61
+ "List_InvalidBounceMember" => "Mailchimp_List_InvalidBounceMember",
62
+ "List_AlreadySubscribed" => "Mailchimp_List_AlreadySubscribed",
63
+ "List_NotSubscribed" => "Mailchimp_List_NotSubscribed",
64
+ "List_InvalidImport" => "Mailchimp_List_InvalidImport",
65
+ "MC_PastedList_Duplicate" => "Mailchimp_MC_PastedList_Duplicate",
66
+ "MC_PastedList_InvalidImport" => "Mailchimp_MC_PastedList_InvalidImport",
67
+ "Email_AlreadySubscribed" => "Mailchimp_Email_AlreadySubscribed",
68
+ "Email_AlreadyUnsubscribed" => "Mailchimp_Email_AlreadyUnsubscribed",
69
+ "Email_NotExists" => "Mailchimp_Email_NotExists",
70
+ "Email_NotSubscribed" => "Mailchimp_Email_NotSubscribed",
71
+ "List_MergeFieldRequired" => "Mailchimp_List_MergeFieldRequired",
72
+ "List_CannotRemoveEmailMerge" => "Mailchimp_List_CannotRemoveEmailMerge",
73
+ "List_Merge_InvalidMergeID" => "Mailchimp_List_Merge_InvalidMergeID",
74
+ "List_TooManyMergeFields" => "Mailchimp_List_TooManyMergeFields",
75
+ "List_InvalidMergeField" => "Mailchimp_List_InvalidMergeField",
76
+ "List_InvalidInterestGroup" => "Mailchimp_List_InvalidInterestGroup",
77
+ "List_TooManyInterestGroups" => "Mailchimp_List_TooManyInterestGroups",
78
+ "Campaign_DoesNotExist" => "Mailchimp_Campaign_DoesNotExist",
79
+ "Campaign_StatsNotAvailable" => "Mailchimp_Campaign_StatsNotAvailable",
80
+ "Campaign_InvalidAbsplit" => "Mailchimp_Campaign_InvalidAbsplit",
81
+ "Campaign_InvalidContent" => "Mailchimp_Campaign_InvalidContent",
82
+ "Campaign_InvalidOption" => "Mailchimp_Campaign_InvalidOption",
83
+ "Campaign_InvalidStatus" => "Mailchimp_Campaign_InvalidStatus",
84
+ "Campaign_NotSaved" => "Mailchimp_Campaign_NotSaved",
85
+ "Campaign_InvalidSegment" => "Mailchimp_Campaign_InvalidSegment",
86
+ "Campaign_InvalidRss" => "Mailchimp_Campaign_InvalidRss",
87
+ "Campaign_InvalidAuto" => "Mailchimp_Campaign_InvalidAuto",
88
+ "MC_ContentImport_InvalidArchive" => "Mailchimp_MC_ContentImport_InvalidArchive",
89
+ "Campaign_BounceMissing" => "Mailchimp_Campaign_BounceMissing",
90
+ "Campaign_InvalidTemplate" => "Mailchimp_Campaign_InvalidTemplate",
91
+ "Invalid_EcommOrder" => "Mailchimp_Invalid_EcommOrder",
92
+ "Absplit_UnknownError" => "Mailchimp_Absplit_UnknownError",
93
+ "Absplit_UnknownSplitTest" => "Mailchimp_Absplit_UnknownSplitTest",
94
+ "Absplit_UnknownTestType" => "Mailchimp_Absplit_UnknownTestType",
95
+ "Absplit_UnknownWaitUnit" => "Mailchimp_Absplit_UnknownWaitUnit",
96
+ "Absplit_UnknownWinnerType" => "Mailchimp_Absplit_UnknownWinnerType",
97
+ "Absplit_WinnerNotSelected" => "Mailchimp_Absplit_WinnerNotSelected",
98
+ "Invalid_Analytics" => "Mailchimp_Invalid_Analytics",
99
+ "Invalid_DateTime" => "Mailchimp_Invalid_DateTime",
100
+ "Invalid_Email" => "Mailchimp_Invalid_Email",
101
+ "Invalid_SendType" => "Mailchimp_Invalid_SendType",
102
+ "Invalid_Template" => "Mailchimp_Invalid_Template",
103
+ "Invalid_TrackingOptions" => "Mailchimp_Invalid_TrackingOptions",
104
+ "Invalid_Options" => "Mailchimp_Invalid_Options",
105
+ "Invalid_Folder" => "Mailchimp_Invalid_Folder",
106
+ "Invalid_URL" => "Mailchimp_Invalid_URL",
107
+ "Module_Unknown" => "Mailchimp_Module_Unknown",
108
+ "MonthlyPlan_Unknown" => "Mailchimp_MonthlyPlan_Unknown",
109
+ "Order_TypeUnknown" => "Mailchimp_Order_TypeUnknown",
110
+ "Invalid_PagingLimit" => "Mailchimp_Invalid_PagingLimit",
111
+ "Invalid_PagingStart" => "Mailchimp_Invalid_PagingStart",
112
+ "Max_Size_Reached" => "Mailchimp_Max_Size_Reached",
113
+ "MC_SearchException" => "Mailchimp_MC_SearchException",
114
+ "Goal_SaveFailed" => "Mailchimp_Goal_SaveFailed",
115
+ "Conversation_DoesNotExist" => "Mailchimp_Conversation_DoesNotExist",
116
+ "Conversation_ReplySaveFailed" => "Mailchimp_Conversation_ReplySaveFailed",
117
+ "File_Not_Found_Exception" => "Mailchimp_File_Not_Found_Exception",
118
+ "Folder_Not_Found_Exception" => "Mailchimp_Folder_Not_Found_Exception",
119
+ "Folder_Exists_Exception" => "Mailchimp_Folder_Exists_Exception"
120
+ );
121
+
122
+ public function __construct($apikey=null, $opts=array()) {
123
+ if (!$apikey) {
124
+ $apikey = getenv('MAILCHIMP_APIKEY');
125
+ }
126
+
127
+ if (!$apikey) {
128
+ $apikey = $this->readConfigs();
129
+ }
130
+
131
+ if (!$apikey) {
132
+ throw new Mailchimp_Error('You must provide a MailChimp API key');
133
+ }
134
+
135
+ $this->apikey = $apikey;
136
+ $dc = "us1";
137
+
138
+ if (strstr($this->apikey, "-")){
139
+ list($key, $dc) = explode("-", $this->apikey, 2);
140
+ if (!$dc) {
141
+ $dc = "us1";
142
+ }
143
+ }
144
+
145
+ $this->root = str_replace('https://api', 'https://' . $dc . '.api', $this->root);
146
+ $this->root = rtrim($this->root, '/') . '/';
147
+
148
+ if (!isset($opts['timeout']) || !is_int($opts['timeout'])){
149
+ $opts['timeout'] = 600;
150
+ }
151
+ if (isset($opts['debug'])){
152
+ $this->debug = true;
153
+ }
154
+
155
+
156
+ $this->ch = curl_init();
157
+
158
+ if (isset($opts['CURLOPT_FOLLOWLOCATION']) && $opts['CURLOPT_FOLLOWLOCATION'] === true) {
159
+ curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
160
+ }
161
+
162
+ curl_setopt($this->ch, CURLOPT_USERAGENT, 'MailChimp-PHP/2.0.5');
163
+ curl_setopt($this->ch, CURLOPT_POST, true);
164
+ curl_setopt($this->ch, CURLOPT_HEADER, false);
165
+ curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
166
+ curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 30);
167
+ curl_setopt($this->ch, CURLOPT_TIMEOUT, $opts['timeout']);
168
+
169
+
170
+ $this->folders = new Mailchimp_Folders($this);
171
+ $this->templates = new Mailchimp_Templates($this);
172
+ $this->users = new Mailchimp_Users($this);
173
+ $this->helper = new Mailchimp_Helper($this);
174
+ $this->mobile = new Mailchimp_Mobile($this);
175
+ $this->conversations = new Mailchimp_Conversations($this);
176
+ $this->ecomm = new Mailchimp_Ecomm($this);
177
+ $this->neapolitan = new Mailchimp_Neapolitan($this);
178
+ $this->lists = new Mailchimp_Lists($this);
179
+ $this->campaigns = new Mailchimp_Campaigns($this);
180
+ $this->vip = new Mailchimp_Vip($this);
181
+ $this->reports = new Mailchimp_Reports($this);
182
+ $this->gallery = new Mailchimp_Gallery($this);
183
+ $this->goal = new Mailchimp_Goal($this);
184
+ }
185
+
186
+ public function __destruct() {
187
+ curl_close($this->ch);
188
+ }
189
+
190
+ public function call($url, $params) {
191
+ $params['apikey'] = $this->apikey;
192
+
193
+ $params = json_encode($params);
194
+ $ch = $this->ch;
195
+
196
+ curl_setopt($ch, CURLOPT_URL, $this->root . $url . '.json');
197
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
198
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
199
+ curl_setopt($ch, CURLOPT_VERBOSE, $this->debug);
200
+
201
+ $start = microtime(true);
202
+ $this->log('Call to ' . $this->root . $url . '.json: ' . $params);
203
+ if($this->debug) {
204
+ $curl_buffer = fopen('php://memory', 'w+');
205
+ curl_setopt($ch, CURLOPT_STDERR, $curl_buffer);
206
+ }
207
+
208
+ $response_body = curl_exec($ch);
209
+
210
+ $info = curl_getinfo($ch);
211
+ $time = microtime(true) - $start;
212
+ if($this->debug) {
213
+ rewind($curl_buffer);
214
+ $this->log(stream_get_contents($curl_buffer));
215
+ fclose($curl_buffer);
216
+ }
217
+ $this->log('Completed in ' . number_format($time * 1000, 2) . 'ms');
218
+ $this->log('Got response: ' . $response_body);
219
+
220
+ if(curl_error($ch)) {
221
+ throw new Mailchimp_HttpError("API call to $url failed: " . curl_error($ch));
222
+ }
223
+ $result = json_decode($response_body, true);
224
+
225
+ if(floor($info['http_code'] / 100) >= 4) {
226
+ throw $this->castError($result);
227
+ }
228
+
229
+ return $result;
230
+ }
231
+
232
+ public function readConfigs() {
233
+ $paths = array('~/.mailchimp.key', '/etc/mailchimp.key');
234
+ foreach($paths as $path) {
235
+ if(file_exists($path)) {
236
+ $apikey = trim(file_get_contents($path));
237
+ if ($apikey) {
238
+ return $apikey;
239
+ }
240
+ }
241
+ }
242
+ return false;
243
+ }
244
+
245
+ public function castError($result) {
246
+ if ($result['status'] !== 'error' || !$result['name']) {
247
+ throw new Mailchimp_Error('We received an unexpected error: ' . json_encode($result));
248
+ }
249
+
250
+ $class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Mailchimp_Error';
251
+ return new $class($result['error'], $result['code']);
252
+ }
253
+
254
+ public function log($msg) {
255
+ if ($this->debug) {
256
+ error_log($msg);
257
+ }
258
+ }
259
+ }
260
+
261
+
includes/externals/mailchimp/Mailchimp/Campaigns.php ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Campaigns {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content
10
+ * @param string $cid
11
+ * @param associative_array $options
12
+ * - view string optional one of "archive" (default), "preview" (like our popup-preview) or "raw"
13
+ * - email associative_array optional if provided, view is "archive" or "preview", the campaign's list still exists, and the requested record is subscribed to the list. the returned content will be populated with member data populated. a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
14
+ * - email string an email address
15
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
16
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
17
+ * @return associative_array containing all content for the campaign
18
+ * - html string The HTML content used for the campaign with merge tags intact
19
+ * - text string The Text content used for the campaign with merge tags intact
20
+ */
21
+ public function content($cid, $options=array()) {
22
+ $_params = array("cid" => $cid, "options" => $options);
23
+ return $this->master->call('campaigns/content', $_params);
24
+ }
25
+
26
+ /**
27
+ * Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
28
+ * @param string $type
29
+ * @param associative_array $options
30
+ * - list_id string the list to send this campaign to- get lists using lists/list()
31
+ * - subject string the subject line for your campaign message
32
+ * - from_email string the From: email address for your campaign message
33
+ * - from_name string the From: name for your campaign message (not an email address)
34
+ * - to_name string the To: name recipients will see (not email address)
35
+ * - template_id int optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
36
+ * - gallery_template_id int optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
37
+ * - base_template_id int optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
38
+ * - folder_id int optional - automatically file the new campaign in the folder_id passed. Get using folders/list() - note that Campaigns and Autoresponders have separate folder setups
39
+ * - tracking associative_array optional - set which recipient actions will be tracked. Click tracking can not be disabled for Free accounts.
40
+ * - opens bool whether to track opens, defaults to true
41
+ * - html_clicks bool whether to track clicks in HTML content, defaults to true
42
+ * - text_clicks bool whether to track clicks in Text content, defaults to false
43
+ * - title string optional - an internal name to use for this campaign. By default, the campaign subject will be used.
44
+ * - authenticate boolean optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
45
+ * - analytics associative_array optional - one or more of these keys set to the tag to use - that can be any custom text (up to 50 bytes)
46
+ * - google string for Google Analytics tracking
47
+ * - clicktale string for ClickTale tracking
48
+ * - gooal string for Goal tracking (the extra 'o' in the param name is not a typo)
49
+ * - auto_footer boolean optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
50
+ * - inline_css boolean optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
51
+ * - generate_text boolean optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
52
+ * - auto_tweet boolean optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored.
53
+ * - auto_fb_post array optional If set, this campaign will be auto-posted to the page_ids contained in the array. If a Facebook account isn't linked or the account does not have permission to post to the page_ids requested, those failures will be silently ignored.
54
+ * - fb_comments boolean optional If true, the Facebook comments (and thus the <a href="http://kb.mailchimp.com/article/i-dont-want-an-archiave-of-my-campaign-can-i-turn-it-off/" target="_blank">archive bar</a> will be displayed. If false, Facebook comments will not be enabled (does not imply no archive bar, see previous link). Defaults to "true".
55
+ * - timewarp boolean optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time.
56
+ * - ecomm360 boolean optional If set, our <a href="http://www.mailchimp.com/blog/ecommerce-tracking-plugin/" target="_blank">Ecommerce360 tracking</a> will be enabled for links in the campaign
57
+ * - crm_tracking array optional If set, an array of structs to enable CRM tracking for:
58
+ * - salesforce associative_array optional Enable SalesForce push back
59
+ * - campaign bool optional - if true, create a Campaign object and update it with aggregate stats
60
+ * - notes bool optional - if true, attempt to update Contact notes based on email address
61
+ * - highrise associative_array optional Enable Highrise push back
62
+ * - campaign bool optional - if true, create a Kase object and update it with aggregate stats
63
+ * - notes bool optional - if true, attempt to update Contact notes based on email address
64
+ * - capsule associative_array optional Enable Capsule push back (only notes are supported)
65
+ * - notes bool optional - if true, attempt to update Contact notes based on email address
66
+ * @param associative_array $content
67
+ * - html string for raw/pasted HTML content
68
+ * - sections associative_array when using a template instead of raw HTML, each key should be the unique mc:edit area name from the template.
69
+ * - text string for the plain-text version
70
+ * - url string to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
71
+ * - archive string to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
72
+ * - archive_type string optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
73
+ * @param associative_array $segment_opts
74
+ * @param associative_array $type_opts
75
+ * - rss associative_array For RSS Campaigns this, struct should contain:
76
+ * - url string the URL to pull RSS content from - it will be verified and must exist
77
+ * - schedule string optional one of "daily", "weekly", "monthly" - defaults to "daily"
78
+ * - schedule_hour string optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
79
+ * - schedule_weekday string optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday)
80
+ * - schedule_monthday string optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month
81
+ * - days associative_array optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on
82
+ * - 1 bool optional Monday, defaults to true
83
+ * - 2 bool optional Tuesday, defaults to true
84
+ * - 3 bool optional Wednesday, defaults to true
85
+ * - 4 bool optional Thursday, defaults to true
86
+ * - 5 bool optional Friday, defaults to true
87
+ * - 6 bool optional Saturday, defaults to true
88
+ * - 7 bool optional Sunday, defaults to true
89
+ * - absplit associative_array For A/B Split campaigns, this struct should contain:
90
+ * - split_test string The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaigns/schedule() separately!
91
+ * - pick_winner string How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
92
+ * - wait_units int optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
93
+ * - wait_time int optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
94
+ * - split_size int optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
95
+ * - from_name_a string optional sort of, required when split_test is "from_name"
96
+ * - from_name_b string optional sort of, required when split_test is "from_name"
97
+ * - from_email_a string optional sort of, required when split_test is "from_name"
98
+ * - from_email_b string optional sort of, required when split_test is "from_name"
99
+ * - subject_a string optional sort of, required when split_test is "subject"
100
+ * - subject_b string optional sort of, required when split_test is "subject"
101
+ * - auto associative_array For AutoResponder campaigns, this struct should contain:
102
+ * - offset-units string one of "hourly", "day", "week", "month", "year" - required
103
+ * - offset-time string optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders, ignored for "hourly"
104
+ * - offset-dir string either "before" or "after", ignored for "hourly"
105
+ * - event string optional "signup" (default) to base this members added to a list, "date", "annual", or "birthday" to base this on merge field in the list, "campaignOpen" or "campaignClicka" to base this on any activity for a campaign, "campaignClicko" to base this on clicks on a specific URL in a campaign, "mergeChanged" to base this on a specific merge field being changed to a specific value
106
+ * - event-datemerge string optional sort of, this is required if the event is "date", "annual", "birthday", or "mergeChanged"
107
+ * - campaign_id string optional sort of, required for "campaignOpen", "campaignClicka", or "campaignClicko"
108
+ * - campaign_url string optional sort of, required for "campaignClicko"
109
+ * - schedule_hour int The hour of the day - 24 hour format in GMT - the autoresponder should be triggered, ignored for "hourly"
110
+ * - use_import_time boolean whether or not imported subscribers (ie, <em>any</em> non-double optin subscribers) will receive
111
+ * - days associative_array optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on<
112
+ * - 1 bool optional Monday, defaults to true
113
+ * - 2 bool optional Tuesday, defaults to true
114
+ * - 3 bool optional Wednesday, defaults to true
115
+ * - 4 bool optional Thursday, defaults to true
116
+ * - 5 bool optional Friday, defaults to true
117
+ * - 6 bool optional Saturday, defaults to true
118
+ * - 7 bool optional Sunday, defaults to true
119
+ * @return associative_array the new campaign's details - will return same data as single campaign from campaigns/list()
120
+ */
121
+ public function create($type, $options, $content, $segment_opts=null, $type_opts=null) {
122
+ $_params = array("type" => $type, "options" => $options, "content" => $content, "segment_opts" => $segment_opts, "type_opts" => $type_opts);
123
+ return $this->master->call('campaigns/create', $_params);
124
+ }
125
+
126
+ /**
127
+ * Delete a campaign. Seriously, "poof, gone!" - be careful! Seriously, no one can undelete these.
128
+ * @param string $cid
129
+ * @return associative_array with a single entry:
130
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
131
+ */
132
+ public function delete($cid) {
133
+ $_params = array("cid" => $cid);
134
+ return $this->master->call('campaigns/delete', $_params);
135
+ }
136
+
137
+ /**
138
+ * Get the list of campaigns and their details matching the specified filters
139
+ * @param associative_array $filters
140
+ * - campaign_id string optional - return the campaign using a know campaign_id. Accepts multiples separated by commas when not using exact matching.
141
+ * - parent_id string optional - return the child campaigns using a known parent campaign_id. Accepts multiples separated by commas when not using exact matching.
142
+ * - list_id string optional - the list to send this campaign to - get lists using lists/list(). Accepts multiples separated by commas when not using exact matching.
143
+ * - folder_id int optional - only show campaigns from this folder id - get folders using folders/list(). Accepts multiples separated by commas when not using exact matching.
144
+ * - template_id int optional - only show campaigns using this template id - get templates using templates/list(). Accepts multiples separated by commas when not using exact matching.
145
+ * - status string optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
146
+ * - type string optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "auto". Accepts multiples separated by commas when not using exact matching.
147
+ * - from_name string optional - only show campaigns that have this "From Name"
148
+ * - from_email string optional - only show campaigns that have this "Reply-to Email"
149
+ * - title string optional - only show campaigns that have this title
150
+ * - subject string optional - only show campaigns that have this subject
151
+ * - sendtime_start string optional - only show campaigns that have been sent since this date/time (in GMT) - - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
152
+ * - sendtime_end string optional - only show campaigns that have been sent before this date/time (in GMT) - - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
153
+ * - uses_segment boolean - whether to return just campaigns with or without segments
154
+ * - exact boolean optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
155
+ * @param int $start
156
+ * @param int $limit
157
+ * @param string $sort_field
158
+ * @param string $sort_dir
159
+ * @return associative_array containing a count of all matching campaigns, the specific ones for the current page, and any errors from the filters provided
160
+ * - total int the total number of campaigns matching the filters passed in
161
+ * - data array structs for each campaign being returned
162
+ * - id string Campaign Id (used for all other campaign functions)
163
+ * - web_id int The Campaign id used in our web app, allows you to create a link directly to it
164
+ * - list_id string The List used for this campaign
165
+ * - folder_id int The Folder this campaign is in
166
+ * - template_id int The Template this campaign uses
167
+ * - content_type string How the campaign's content is put together - one of 'template', 'html', 'url'
168
+ * - title string Title of the campaign
169
+ * - type string The type of campaign this is (regular,plaintext,absplit,rss,inspection,auto)
170
+ * - create_time string Creation time for the campaign
171
+ * - send_time string Send time for the campaign - also the scheduled time for scheduled campaigns.
172
+ * - emails_sent int Number of emails email was sent to
173
+ * - status string Status of the given campaign (save,paused,schedule,sending,sent)
174
+ * - from_name string From name of the given campaign
175
+ * - from_email string Reply-to email of the given campaign
176
+ * - subject string Subject of the given campaign
177
+ * - to_name string Custom "To:" email string using merge variables
178
+ * - archive_url string Archive link for the given campaign
179
+ * - inline_css boolean Whether or not the campaign content's css was auto-inlined
180
+ * - analytics string Either "google" if enabled or "N" if disabled
181
+ * - analytics_tag string The name/tag the campaign's links were tagged with if analytics were enabled.
182
+ * - authenticate boolean Whether or not the campaign was authenticated
183
+ * - ecomm360 boolean Whether or not ecomm360 tracking was appended to links
184
+ * - auto_tweet boolean Whether or not the campaign was auto tweeted after sending
185
+ * - auto_fb_post string A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
186
+ * - auto_footer boolean Whether or not the auto_footer was manually turned on
187
+ * - timewarp boolean Whether or not the campaign used Timewarp
188
+ * - timewarp_schedule string The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
189
+ * - parent_id string the unique id of the parent campaign (currently only valid for rss children). Will be blank for non-rss child campaigns or parent campaign has been deleted.
190
+ * - is_child boolean true if this is an RSS child campaign. Will return true even if the parent campaign has been deleted.
191
+ * - tests_sent string tests sent
192
+ * - tests_remain int test sends remaining
193
+ * - tracking associative_array the various tracking options used
194
+ * - html_clicks boolean whether or not tracking for html clicks was enabled.
195
+ * - text_clicks boolean whether or not tracking for text clicks was enabled.
196
+ * - opens boolean whether or not opens tracking was enabled.
197
+ * - segment_text string a string marked-up with HTML explaining the segment used for the campaign in plain English
198
+ * - segment_opts array the segment used for the campaign - can be passed to campaigns/segment-test or campaigns/create()
199
+ * - saved_segment associative_array if a saved segment was used (match+conditions returned above):
200
+ * - id int the saved segment id
201
+ * - type string the saved segment type
202
+ * - name string the saved segment name
203
+ * - type_opts associative_array the type-specific options for the campaign - can be passed to campaigns/create()
204
+ * - comments_total int total number of comments left on this campaign
205
+ * - comments_unread int total number of unread comments for this campaign based on the login the apikey belongs to
206
+ * - summary associative_array if available, the basic aggregate stats returned by reports/summary
207
+ * - errors array structs of any errors found while loading lists - usually just from providing invalid list ids
208
+ * - filter string the filter that caused the failure
209
+ * - value string the filter value that caused the failure
210
+ * - code int the error code
211
+ * - error string the error message
212
+ */
213
+ public function getList($filters=array(), $start=0, $limit=25, $sort_field='create_time', $sort_dir='DESC') {
214
+ $_params = array("filters" => $filters, "start" => $start, "limit" => $limit, "sort_field" => $sort_field, "sort_dir" => $sort_dir);
215
+ return $this->master->call('campaigns/list', $_params);
216
+ }
217
+
218
+ /**
219
+ * Pause an AutoResponder or RSS campaign from sending
220
+ * @param string $cid
221
+ * @return associative_array with a single entry:
222
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
223
+ */
224
+ public function pause($cid) {
225
+ $_params = array("cid" => $cid);
226
+ return $this->master->call('campaigns/pause', $_params);
227
+ }
228
+
229
+ /**
230
+ * Returns information on whether a campaign is ready to send and possible issues we may have detected with it - very similar to the confirmation step in the app.
231
+ * @param string $cid
232
+ * @return associative_array containing:
233
+ * - is_ready bool whether or not you're going to be able to send this campaign
234
+ * - items array an array of structs explaining basically what the app's confirmation step would
235
+ * - type string the item type - generally success, warning, or error
236
+ * - heading string the item's heading in the app
237
+ * - details string the item's details from the app, sans any html tags/links
238
+ */
239
+ public function ready($cid) {
240
+ $_params = array("cid" => $cid);
241
+ return $this->master->call('campaigns/ready', $_params);
242
+ }
243
+
244
+ /**
245
+ * Replicate a campaign.
246
+ * @param string $cid
247
+ * @return associative_array the matching campaign's details - will return same data as single campaign from campaigns/list()
248
+ */
249
+ public function replicate($cid) {
250
+ $_params = array("cid" => $cid);
251
+ return $this->master->call('campaigns/replicate', $_params);
252
+ }
253
+
254
+ /**
255
+ * Resume sending an AutoResponder or RSS campaign
256
+ * @param string $cid
257
+ * @return associative_array with a single entry:
258
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
259
+ */
260
+ public function resume($cid) {
261
+ $_params = array("cid" => $cid);
262
+ return $this->master->call('campaigns/resume', $_params);
263
+ }
264
+
265
+ /**
266
+ * Schedule a campaign to be sent in the future
267
+ * @param string $cid
268
+ * @param string $schedule_time
269
+ * @param string $schedule_time_b
270
+ * @return associative_array with a single entry:
271
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
272
+ */
273
+ public function schedule($cid, $schedule_time, $schedule_time_b=null) {
274
+ $_params = array("cid" => $cid, "schedule_time" => $schedule_time, "schedule_time_b" => $schedule_time_b);
275
+ return $this->master->call('campaigns/schedule', $_params);
276
+ }
277
+
278
+ /**
279
+ * Schedule a campaign to be sent in batches sometime in the future. Only valid for "regular" campaigns
280
+ * @param string $cid
281
+ * @param string $schedule_time
282
+ * @param int $num_batches
283
+ * @param int $stagger_mins
284
+ * @return associative_array with a single entry:
285
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
286
+ */
287
+ public function scheduleBatch($cid, $schedule_time, $num_batches=2, $stagger_mins=5) {
288
+ $_params = array("cid" => $cid, "schedule_time" => $schedule_time, "num_batches" => $num_batches, "stagger_mins" => $stagger_mins);
289
+ return $this->master->call('campaigns/schedule-batch', $_params);
290
+ }
291
+
292
+ /**
293
+ * Allows one to test their segmentation rules before creating a campaign using them.
294
+ * @param string $list_id
295
+ * @param associative_array $options
296
+ * - saved_segment_id string a saved segment id from lists/segments() - this will take precendence, otherwise the match+conditions are required.
297
+ * - match string controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
298
+ * - conditions array of up to 5 structs for different criteria to apply while segmenting. Each criteria row must contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", and "<strong>value</strong>" - and possibly a fourth, "<strong>extra</strong>", based on these definitions:
299
+ * @return associative_array with a single entry:
300
+ * - total int The total number of subscribers matching your segmentation options
301
+ */
302
+ public function segmentTest($list_id, $options) {
303
+ $_params = array("list_id" => $list_id, "options" => $options);
304
+ return $this->master->call('campaigns/segment-test', $_params);
305
+ }
306
+
307
+ /**
308
+ * Send a given campaign immediately. For RSS campaigns, this will "start" them.
309
+ * @param string $cid
310
+ * @return associative_array with a single entry:
311
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
312
+ */
313
+ public function send($cid) {
314
+ $_params = array("cid" => $cid);
315
+ return $this->master->call('campaigns/send', $_params);
316
+ }
317
+
318
+ /**
319
+ * Send a test of this campaign to the provided email addresses
320
+ * @param string $cid
321
+ * @param array $test_emails
322
+ * @param string $send_type
323
+ * @return associative_array with a single entry:
324
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
325
+ */
326
+ public function sendTest($cid, $test_emails=array(), $send_type='html') {
327
+ $_params = array("cid" => $cid, "test_emails" => $test_emails, "send_type" => $send_type);
328
+ return $this->master->call('campaigns/send-test', $_params);
329
+ }
330
+
331
+ /**
332
+ * Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template
333
+ a campaign is using. You only want to use this if you want to allow editing template sections in your application.
334
+ * @param string $cid
335
+ * @return associative_array content containing all content section for the campaign - section name are dependent upon the template used and thus can't be documented
336
+ */
337
+ public function templateContent($cid) {
338
+ $_params = array("cid" => $cid);
339
+ return $this->master->call('campaigns/template-content', $_params);
340
+ }
341
+
342
+ /**
343
+ * Unschedule a campaign that is scheduled to be sent in the future
344
+ * @param string $cid
345
+ * @return associative_array with a single entry:
346
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
347
+ */
348
+ public function unschedule($cid) {
349
+ $_params = array("cid" => $cid);
350
+ return $this->master->call('campaigns/unschedule', $_params);
351
+ }
352
+
353
+ /**
354
+ * Update just about any setting besides type for a campaign that has <em>not</em> been sent. See campaigns/create() for details.
355
+ Caveats:<br/><ul class='bullets'>
356
+ <li>If you set a new list_id, all segmentation options will be deleted and must be re-added.</li>
357
+ <li>If you set template_id, you need to follow that up by setting it's 'content'</li>
358
+ <li>If you set segment_opts, you should have tested your options against campaigns/segment-test().</li>
359
+ <li>To clear/unset segment_opts, pass an empty string or array as the value. Various wrappers may require one or the other.</li>
360
+ </ul>
361
+ * @param string $cid
362
+ * @param string $name
363
+ * @param array $value
364
+ * @return associative_array updated campaign details and any errors
365
+ * - data associative_array the update campaign details - will return same data as single campaign from campaigns/list()
366
+ * - errors array for "options" only - structs containing:
367
+ * - code int the error code
368
+ * - message string the full error message
369
+ * - name string the parameter name that failed
370
+ */
371
+ public function update($cid, $name, $value) {
372
+ $_params = array("cid" => $cid, "name" => $name, "value" => $value);
373
+ return $this->master->call('campaigns/update', $_params);
374
+ }
375
+
376
+ }
377
+
378
+
includes/externals/mailchimp/Mailchimp/Conversations.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Conversations {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Retrieve conversation metadata, includes message data for the most recent message in the conversation
10
+ * @param string $list_id
11
+ * @param string $leid
12
+ * @param string $campaign_id
13
+ * @param int $start
14
+ * @param int $limit
15
+ * @return associative_array Conversation data and metadata
16
+ * - count int Total number of conversations, irrespective of pagination.
17
+ * - data array An array of structs representing individual conversations
18
+ * - unique_id string A string identifying this particular conversation
19
+ * - message_count int The total number of messages in this conversation
20
+ * - campaign_id string The unique identifier of the campaign this conversation is associated with
21
+ * - list_id string The unique identifier of the list this conversation is associated with
22
+ * - unread_messages int The number of messages in this conversation which have not yet been read.
23
+ * - from_label string A label representing the sender of this message.
24
+ * - from_email string The email address of the sender of this message.
25
+ * - subject string The subject of the message.
26
+ * - timestamp string Date the message was either sent or received.
27
+ * - last_message associative_array The most recent message in the conversation
28
+ * - from_label string A label representing the sender of this message.
29
+ * - from_email string The email address of the sender of this message.
30
+ * - subject string The subject of the message.
31
+ * - message string The plain-text content of the message.
32
+ * - read boolean Whether or not this message has been marked as read.
33
+ * - timestamp string Date the message was either sent or received.
34
+ */
35
+ public function getList($list_id=null, $leid=null, $campaign_id=null, $start=0, $limit=25) {
36
+ $_params = array("list_id" => $list_id, "leid" => $leid, "campaign_id" => $campaign_id, "start" => $start, "limit" => $limit);
37
+ return $this->master->call('conversations/list', $_params);
38
+ }
39
+
40
+ /**
41
+ * Retrieve conversation messages
42
+ * @param string $conversation_id
43
+ * @param boolean $mark_as_read
44
+ * @param int $start
45
+ * @param int $limit
46
+ * @return associative_array Message data and metadata
47
+ * - count int The number of messages in this conversation, irrespective of paging.
48
+ * - data array An array of structs representing each message in a conversation
49
+ * - from_label string A label representing the sender of this message.
50
+ * - from_email string The email address of the sender of this message.
51
+ * - subject string The subject of the message.
52
+ * - message string The plain-text content of the message.
53
+ * - read boolean Whether or not this message has been marked as read.
54
+ * - timestamp string Date the message was either sent or received.
55
+ */
56
+ public function messages($conversation_id, $mark_as_read=false, $start=0, $limit=25) {
57
+ $_params = array("conversation_id" => $conversation_id, "mark_as_read" => $mark_as_read, "start" => $start, "limit" => $limit);
58
+ return $this->master->call('conversations/messages', $_params);
59
+ }
60
+
61
+ /**
62
+ * Retrieve conversation messages
63
+ * @param string $conversation_id
64
+ * @param string $message
65
+ * @return associative_array Message data from the created message
66
+ * - from_label string A label representing the sender of this message.
67
+ * - from_email string The email address of the sender of this message.
68
+ * - subject string The subject of the message.
69
+ * - message string The plain-text content of the message.
70
+ * - read boolean Whether or not this message has been marked as read.
71
+ * - timestamp string Date the message was either sent or received.
72
+ */
73
+ public function reply($conversation_id, $message) {
74
+ $_params = array("conversation_id" => $conversation_id, "message" => $message);
75
+ return $this->master->call('conversations/reply', $_params);
76
+ }
77
+
78
+ }
79
+
80
+
includes/externals/mailchimp/Mailchimp/Ecomm.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Ecomm {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins
10
+ <a href="http://connect.mailchimp.com/category/ecommerce" target="_blank">provided by us or by 3rd part system developers</a>.
11
+ * @param associative_array $order
12
+ * - id string the Order Id
13
+ * - campaign_id string optional the Campaign Id to track this order against (see the "mc_cid" query string variable a campaign passes)
14
+ * - email_id string optional (kind of) the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) - required if campaign_id is passed, otherwise either this or <strong>email</strong> is required. If both are provided, email_id takes precedence
15
+ * - email string optional (kind of) the Email Address we should attach this order to - either this or <strong>email_id</strong> is required. If both are provided, email_id takes precedence
16
+ * - total double The Order Total (ie, the full amount the customer ends up paying)
17
+ * - order_date string optional the date of the order - if this is not provided, we will default the date to now. Should be in the format of 2012-12-30
18
+ * - shipping double optional the total paid for Shipping Fees
19
+ * - tax double optional the total tax paid
20
+ * - store_id string a unique id for the store sending the order in (32 bytes max)
21
+ * - store_name string optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
22
+ * - items array structs for each individual line item including:
23
+ * - line_num int optional the line number of the item on the order. We will generate these if they are not passed
24
+ * - product_id int the store's internal Id for the product. Lines that do no contain this will be skipped
25
+ * - sku string optional the store's internal SKU for the product. (max 30 bytes)
26
+ * - product_name string the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
27
+ * - category_id int (required) the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
28
+ * - category_name string (required) the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
29
+ * - qty double optional the quantity of the item ordered - defaults to 1
30
+ * - cost double optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
31
+ * @return associative_array with a single entry:
32
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
33
+ */
34
+ public function orderAdd($order) {
35
+ $_params = array("order" => $order);
36
+ return $this->master->call('ecomm/order-add', $_params);
37
+ }
38
+
39
+ /**
40
+ * Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins
41
+ <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
42
+ * @param string $store_id
43
+ * @param string $order_id
44
+ * @return associative_array with a single entry:
45
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
46
+ */
47
+ public function orderDel($store_id, $order_id) {
48
+ $_params = array("store_id" => $store_id, "order_id" => $order_id);
49
+ return $this->master->call('ecomm/order-del', $_params);
50
+ }
51
+
52
+ /**
53
+ * Retrieve the Ecommerce Orders for an account
54
+ * @param string $cid
55
+ * @param int $start
56
+ * @param int $limit
57
+ * @param string $since
58
+ * @return associative_array the total matching orders and the specific orders for the requested page
59
+ * - total int the total matching orders
60
+ * - data array structs for each order being returned
61
+ * - store_id string the store id generated by the plugin used to uniquely identify a store
62
+ * - store_name string the store name collected by the plugin - often the domain name
63
+ * - order_id string the internal order id the store tracked this order by
64
+ * - email string the email address that received this campaign and is associated with this order
65
+ * - order_total double the order total
66
+ * - tax_total double the total tax for the order (if collected)
67
+ * - ship_total double the shipping total for the order (if collected)
68
+ * - order_date string the date the order was tracked - from the store if possible, otherwise the GMT time we received it
69
+ * - items array structs for each line item on this order.:
70
+ * - line_num int the line number
71
+ * - product_id int the product id
72
+ * - product_name string the product name
73
+ * - product_sku string the sku for the product
74
+ * - product_category_id int the category id for the product
75
+ * - product_category_name string the category name for the product
76
+ * - qty int the quantity ordered
77
+ * - cost double the cost of the item
78
+ */
79
+ public function orders($cid=null, $start=0, $limit=100, $since=null) {
80
+ $_params = array("cid" => $cid, "start" => $start, "limit" => $limit, "since" => $since);
81
+ return $this->master->call('ecomm/orders', $_params);
82
+ }
83
+
84
+ }
85
+
86
+
includes/externals/mailchimp/Mailchimp/Exceptions.php ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Error extends Exception {}
4
+ class Mailchimp_HttpError extends Mailchimp_Error {}
5
+
6
+ /**
7
+ * The parameters passed to the API call are invalid or not provided when required
8
+ */
9
+ class Mailchimp_ValidationError extends Mailchimp_Error {}
10
+
11
+ /**
12
+ * None
13
+ */
14
+ class Mailchimp_ServerError_MethodUnknown extends Mailchimp_Error {}
15
+
16
+ /**
17
+ * None
18
+ */
19
+ class Mailchimp_ServerError_InvalidParameters extends Mailchimp_Error {}
20
+
21
+ /**
22
+ * None
23
+ */
24
+ class Mailchimp_Unknown_Exception extends Mailchimp_Error {}
25
+
26
+ /**
27
+ * None
28
+ */
29
+ class Mailchimp_Request_TimedOut extends Mailchimp_Error {}
30
+
31
+ /**
32
+ * None
33
+ */
34
+ class Mailchimp_Zend_Uri_Exception extends Mailchimp_Error {}
35
+
36
+ /**
37
+ * None
38
+ */
39
+ class Mailchimp_PDOException extends Mailchimp_Error {}
40
+
41
+ /**
42
+ * None
43
+ */
44
+ class Mailchimp_Avesta_Db_Exception extends Mailchimp_Error {}
45
+
46
+ /**
47
+ * None
48
+ */
49
+ class Mailchimp_XML_RPC2_Exception extends Mailchimp_Error {}
50
+
51
+ /**
52
+ * None
53
+ */
54
+ class Mailchimp_XML_RPC2_FaultException extends Mailchimp_Error {}
55
+
56
+ /**
57
+ * None
58
+ */
59
+ class Mailchimp_Too_Many_Connections extends Mailchimp_Error {}
60
+
61
+ /**
62
+ * None
63
+ */
64
+ class Mailchimp_Parse_Exception extends Mailchimp_Error {}
65
+
66
+ /**
67
+ * None
68
+ */
69
+ class Mailchimp_User_Unknown extends Mailchimp_Error {}
70
+
71
+ /**
72
+ * None
73
+ */
74
+ class Mailchimp_User_Disabled extends Mailchimp_Error {}
75
+
76
+ /**
77
+ * None
78
+ */
79
+ class Mailchimp_User_DoesNotExist extends Mailchimp_Error {}
80
+
81
+ /**
82
+ * None
83
+ */
84
+ class Mailchimp_User_NotApproved extends Mailchimp_Error {}
85
+
86
+ /**
87
+ * None
88
+ */
89
+ class Mailchimp_Invalid_ApiKey extends Mailchimp_Error {}
90
+
91
+ /**
92
+ * None
93
+ */
94
+ class Mailchimp_User_UnderMaintenance extends Mailchimp_Error {}
95
+
96
+ /**
97
+ * None
98
+ */
99
+ class Mailchimp_Invalid_AppKey extends Mailchimp_Error {}
100
+
101
+ /**
102
+ * None
103
+ */
104
+ class Mailchimp_Invalid_IP extends Mailchimp_Error {}
105
+
106
+ /**
107
+ * None
108
+ */
109
+ class Mailchimp_User_DoesExist extends Mailchimp_Error {}
110
+
111
+ /**
112
+ * None
113
+ */
114
+ class Mailchimp_User_InvalidRole extends Mailchimp_Error {}
115
+
116
+ /**
117
+ * None
118
+ */
119
+ class Mailchimp_User_InvalidAction extends Mailchimp_Error {}
120
+
121
+ /**
122
+ * None
123
+ */
124
+ class Mailchimp_User_MissingEmail extends Mailchimp_Error {}
125
+
126
+ /**
127
+ * None
128
+ */
129
+ class Mailchimp_User_CannotSendCampaign extends Mailchimp_Error {}
130
+
131
+ /**
132
+ * None
133
+ */
134
+ class Mailchimp_User_MissingModuleOutbox extends Mailchimp_Error {}
135
+
136
+ /**
137
+ * None
138
+ */
139
+ class Mailchimp_User_ModuleAlreadyPurchased extends Mailchimp_Error {}
140
+
141
+ /**
142
+ * None
143
+ */
144
+ class Mailchimp_User_ModuleNotPurchased extends Mailchimp_Error {}
145
+
146
+ /**
147
+ * None
148
+ */
149
+ class Mailchimp_User_NotEnoughCredit extends Mailchimp_Error {}
150
+
151
+ /**
152
+ * None
153
+ */
154
+ class Mailchimp_MC_InvalidPayment extends Mailchimp_Error {}
155
+
156
+ /**
157
+ * None
158
+ */
159
+ class Mailchimp_List_DoesNotExist extends Mailchimp_Error {}
160
+
161
+ /**
162
+ * None
163
+ */
164
+ class Mailchimp_List_InvalidInterestFieldType extends Mailchimp_Error {}
165
+
166
+ /**
167
+ * None
168
+ */
169
+ class Mailchimp_List_InvalidOption extends Mailchimp_Error {}
170
+
171
+ /**
172
+ * None
173
+ */
174
+ class Mailchimp_List_InvalidUnsubMember extends Mailchimp_Error {}
175
+
176
+ /**
177
+ * None
178
+ */
179
+ class Mailchimp_List_InvalidBounceMember extends Mailchimp_Error {}
180
+
181
+ /**
182
+ * None
183
+ */
184
+ class Mailchimp_List_AlreadySubscribed extends Mailchimp_Error {}
185
+
186
+ /**
187
+ * None
188
+ */
189
+ class Mailchimp_List_NotSubscribed extends Mailchimp_Error {}
190
+
191
+ /**
192
+ * None
193
+ */
194
+ class Mailchimp_List_InvalidImport extends Mailchimp_Error {}
195
+
196
+ /**
197
+ * None
198
+ */
199
+ class Mailchimp_MC_PastedList_Duplicate extends Mailchimp_Error {}
200
+
201
+ /**
202
+ * None
203
+ */
204
+ class Mailchimp_MC_PastedList_InvalidImport extends Mailchimp_Error {}
205
+
206
+ /**
207
+ * None
208
+ */
209
+ class Mailchimp_Email_AlreadySubscribed extends Mailchimp_Error {}
210
+
211
+ /**
212
+ * None
213
+ */
214
+ class Mailchimp_Email_AlreadyUnsubscribed extends Mailchimp_Error {}
215
+
216
+ /**
217
+ * None
218
+ */
219
+ class Mailchimp_Email_NotExists extends Mailchimp_Error {}
220
+
221
+ /**
222
+ * None
223
+ */
224
+ class Mailchimp_Email_NotSubscribed extends Mailchimp_Error {}
225
+
226
+ /**
227
+ * None
228
+ */
229
+ class Mailchimp_List_MergeFieldRequired extends Mailchimp_Error {}
230
+
231
+ /**
232
+ * None
233
+ */
234
+ class Mailchimp_List_CannotRemoveEmailMerge extends Mailchimp_Error {}
235
+
236
+ /**
237
+ * None
238
+ */
239
+ class Mailchimp_List_Merge_InvalidMergeID extends Mailchimp_Error {}
240
+
241
+ /**
242
+ * None
243
+ */
244
+ class Mailchimp_List_TooManyMergeFields extends Mailchimp_Error {}
245
+
246
+ /**
247
+ * None
248
+ */
249
+ class Mailchimp_List_InvalidMergeField extends Mailchimp_Error {}
250
+
251
+ /**
252
+ * None
253
+ */
254
+ class Mailchimp_List_InvalidInterestGroup extends Mailchimp_Error {}
255
+
256
+ /**
257
+ * None
258
+ */
259
+ class Mailchimp_List_TooManyInterestGroups extends Mailchimp_Error {}
260
+
261
+ /**
262
+ * None
263
+ */
264
+ class Mailchimp_Campaign_DoesNotExist extends Mailchimp_Error {}
265
+
266
+ /**
267
+ * None
268
+ */
269
+ class Mailchimp_Campaign_StatsNotAvailable extends Mailchimp_Error {}
270
+
271
+ /**
272
+ * None
273
+ */
274
+ class Mailchimp_Campaign_InvalidAbsplit extends Mailchimp_Error {}
275
+
276
+ /**
277
+ * None
278
+ */
279
+ class Mailchimp_Campaign_InvalidContent extends Mailchimp_Error {}
280
+
281
+ /**
282
+ * None
283
+ */
284
+ class Mailchimp_Campaign_InvalidOption extends Mailchimp_Error {}
285
+
286
+ /**
287
+ * None
288
+ */
289
+ class Mailchimp_Campaign_InvalidStatus extends Mailchimp_Error {}
290
+
291
+ /**
292
+ * None
293
+ */
294
+ class Mailchimp_Campaign_NotSaved extends Mailchimp_Error {}
295
+
296
+ /**
297
+ * None
298
+ */
299
+ class Mailchimp_Campaign_InvalidSegment extends Mailchimp_Error {}
300
+
301
+ /**
302
+ * None
303
+ */
304
+ class Mailchimp_Campaign_InvalidRss extends Mailchimp_Error {}
305
+
306
+ /**
307
+ * None
308
+ */
309
+ class Mailchimp_Campaign_InvalidAuto extends Mailchimp_Error {}
310
+
311
+ /**
312
+ * None
313
+ */
314
+ class Mailchimp_MC_ContentImport_InvalidArchive extends Mailchimp_Error {}
315
+
316
+ /**
317
+ * None
318
+ */
319
+ class Mailchimp_Campaign_BounceMissing extends Mailchimp_Error {}
320
+
321
+ /**
322
+ * None
323
+ */
324
+ class Mailchimp_Campaign_InvalidTemplate extends Mailchimp_Error {}
325
+
326
+ /**
327
+ * None
328
+ */
329
+ class Mailchimp_Invalid_EcommOrder extends Mailchimp_Error {}
330
+
331
+ /**
332
+ * None
333
+ */
334
+ class Mailchimp_Absplit_UnknownError extends Mailchimp_Error {}
335
+
336
+ /**
337
+ * None
338
+ */
339
+ class Mailchimp_Absplit_UnknownSplitTest extends Mailchimp_Error {}
340
+
341
+ /**
342
+ * None
343
+ */
344
+ class Mailchimp_Absplit_UnknownTestType extends Mailchimp_Error {}
345
+
346
+ /**
347
+ * None
348
+ */
349
+ class Mailchimp_Absplit_UnknownWaitUnit extends Mailchimp_Error {}
350
+
351
+ /**
352
+ * None
353
+ */
354
+ class Mailchimp_Absplit_UnknownWinnerType extends Mailchimp_Error {}
355
+
356
+ /**
357
+ * None
358
+ */
359
+ class Mailchimp_Absplit_WinnerNotSelected extends Mailchimp_Error {}
360
+
361
+ /**
362
+ * None
363
+ */
364
+ class Mailchimp_Invalid_Analytics extends Mailchimp_Error {}
365
+
366
+ /**
367
+ * None
368
+ */
369
+ class Mailchimp_Invalid_DateTime extends Mailchimp_Error {}
370
+
371
+ /**
372
+ * None
373
+ */
374
+ class Mailchimp_Invalid_Email extends Mailchimp_Error {}
375
+
376
+ /**
377
+ * None
378
+ */
379
+ class Mailchimp_Invalid_SendType extends Mailchimp_Error {}
380
+
381
+ /**
382
+ * None
383
+ */
384
+ class Mailchimp_Invalid_Template extends Mailchimp_Error {}
385
+
386
+ /**
387
+ * None
388
+ */
389
+ class Mailchimp_Invalid_TrackingOptions extends Mailchimp_Error {}
390
+
391
+ /**
392
+ * None
393
+ */
394
+ class Mailchimp_Invalid_Options extends Mailchimp_Error {}
395
+
396
+ /**
397
+ * None
398
+ */
399
+ class Mailchimp_Invalid_Folder extends Mailchimp_Error {}
400
+
401
+ /**
402
+ * None
403
+ */
404
+ class Mailchimp_Invalid_URL extends Mailchimp_Error {}
405
+
406
+ /**
407
+ * None
408
+ */
409
+ class Mailchimp_Module_Unknown extends Mailchimp_Error {}
410
+
411
+ /**
412
+ * None
413
+ */
414
+ class Mailchimp_MonthlyPlan_Unknown extends Mailchimp_Error {}
415
+
416
+ /**
417
+ * None
418
+ */
419
+ class Mailchimp_Order_TypeUnknown extends Mailchimp_Error {}
420
+
421
+ /**
422
+ * None
423
+ */
424
+ class Mailchimp_Invalid_PagingLimit extends Mailchimp_Error {}
425
+
426
+ /**
427
+ * None
428
+ */
429
+ class Mailchimp_Invalid_PagingStart extends Mailchimp_Error {}
430
+
431
+ /**
432
+ * None
433
+ */
434
+ class Mailchimp_Max_Size_Reached extends Mailchimp_Error {}
435
+
436
+ /**
437
+ * None
438
+ */
439
+ class Mailchimp_MC_SearchException extends Mailchimp_Error {}
440
+
441
+ /**
442
+ * None
443
+ */
444
+ class Mailchimp_Goal_SaveFailed extends Mailchimp_Error {}
445
+
446
+ /**
447
+ * None
448
+ */
449
+ class Mailchimp_Conversation_DoesNotExist extends Mailchimp_Error {}
450
+
451
+ /**
452
+ * None
453
+ */
454
+ class Mailchimp_Conversation_ReplySaveFailed extends Mailchimp_Error {}
455
+
456
+ /**
457
+ * None
458
+ */
459
+ class Mailchimp_File_Not_Found_Exception extends Mailchimp_Error {}
460
+
461
+ /**
462
+ * None
463
+ */
464
+ class Mailchimp_Folder_Not_Found_Exception extends Mailchimp_Error {}
465
+
466
+ /**
467
+ * None
468
+ */
469
+ class Mailchimp_Folder_Exists_Exception extends Mailchimp_Error {}
470
+
471
+
includes/externals/mailchimp/Mailchimp/Folders.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Folders {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Add a new folder to file campaigns, autoresponders, or templates in
10
+ * @param string $name
11
+ * @param string $type
12
+ * @return associative_array with a single value:
13
+ * - folder_id int the folder_id of the newly created folder.
14
+ */
15
+ public function add($name, $type) {
16
+ $_params = array("name" => $name, "type" => $type);
17
+ return $this->master->call('folders/add', $_params);
18
+ }
19
+
20
+ /**
21
+ * Delete a campaign, autoresponder, or template folder. Note that this will simply make whatever was in the folder appear unfiled, no other data is removed
22
+ * @param int $fid
23
+ * @param string $type
24
+ * @return associative_array with a single entry:
25
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
26
+ */
27
+ public function del($fid, $type) {
28
+ $_params = array("fid" => $fid, "type" => $type);
29
+ return $this->master->call('folders/del', $_params);
30
+ }
31
+
32
+ /**
33
+ * List all the folders of a certain type
34
+ * @param string $type
35
+ * @return array structs for each folder, including:
36
+ * - folder_id int Folder Id for the given folder, this can be used in the campaigns/list() function to filter on.
37
+ * - name string Name of the given folder
38
+ * - date_created string The date/time the folder was created
39
+ * - type string The type of the folders being returned, just to make sure you know.
40
+ * - cnt int number of items in the folder.
41
+ */
42
+ public function getList($type) {
43
+ $_params = array("type" => $type);
44
+ return $this->master->call('folders/list', $_params);
45
+ }
46
+
47
+ /**
48
+ * Update the name of a folder for campaigns, autoresponders, or templates
49
+ * @param int $fid
50
+ * @param string $name
51
+ * @param string $type
52
+ * @return associative_array with a single entry:
53
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
54
+ */
55
+ public function update($fid, $name, $type) {
56
+ $_params = array("fid" => $fid, "name" => $name, "type" => $type);
57
+ return $this->master->call('folders/update', $_params);
58
+ }
59
+
60
+ }
61
+
62
+
includes/externals/mailchimp/Mailchimp/Gallery.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Gallery {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Return a section of the image gallery
10
+ * @param associative_array $opts
11
+ * - type string optional the gallery type to return - images or files - default to images
12
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
13
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
14
+ * - sort_by string optional field to sort by - one of size, time, name - defaults to time
15
+ * - sort_dir string optional field to sort by - one of asc, desc - defaults to desc
16
+ * - search_term string optional a term to search for in names
17
+ * - folder_id int optional to return files that are in a specific folder. id returned by the list-folders call
18
+ * @return associative_array the matching gallery items
19
+ * - total int the total matching items
20
+ * - data array structs for each item included in the set, including:
21
+ * - id int the id of the file
22
+ * - name string the file name
23
+ * - time string the creation date for the item
24
+ * - size int the file size in bytes
25
+ * - full string the url to the actual item in the gallery
26
+ * - thumb string a url for a thumbnail that can be used to represent the item, generally an image thumbnail or an icon for a file type
27
+ */
28
+ public function getList($opts=array()) {
29
+ $_params = array("opts" => $opts);
30
+ return $this->master->call('gallery/list', $_params);
31
+ }
32
+
33
+ /**
34
+ * Return a list of the folders available to the file gallery
35
+ * @param associative_array $opts
36
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
37
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
38
+ * - search_term string optional a term to search for in names
39
+ * @return associative_array the matching gallery folders
40
+ * - total int the total matching folders
41
+ * - data array structs for each folder included in the set, including:
42
+ * - id int the id of the folder
43
+ * - name string the file name
44
+ * - file_count int the number of files in the folder
45
+ */
46
+ public function listFolders($opts=array()) {
47
+ $_params = array("opts" => $opts);
48
+ return $this->master->call('gallery/list-folders', $_params);
49
+ }
50
+
51
+ /**
52
+ * Adds a folder to the file gallery
53
+ * @param string $name
54
+ * @return associative_array the new data for the created folder
55
+ * - data.id int the id of the new folder
56
+ */
57
+ public function addFolder($name) {
58
+ $_params = array("name" => $name);
59
+ return $this->master->call('gallery/add-folder', $_params);
60
+ }
61
+
62
+ /**
63
+ * Remove a folder
64
+ * @param int $folder_id
65
+ * @return boolean true/false for success/failure
66
+ */
67
+ public function removeFolder($folder_id) {
68
+ $_params = array("folder_id" => $folder_id);
69
+ return $this->master->call('gallery/remove-folder', $_params);
70
+ }
71
+
72
+ /**
73
+ * Add a file to a folder
74
+ * @param int $file_id
75
+ * @param int $folder_id
76
+ * @return boolean true/false for success/failure
77
+ */
78
+ public function addFileToFolder($file_id, $folder_id) {
79
+ $_params = array("file_id" => $file_id, "folder_id" => $folder_id);
80
+ return $this->master->call('gallery/add-file-to-folder', $_params);
81
+ }
82
+
83
+ /**
84
+ * Remove a file from a folder
85
+ * @param int $file_id
86
+ * @param int $folder_id
87
+ * @return boolean true/false for success/failure
88
+ */
89
+ public function removeFileFromFolder($file_id, $folder_id) {
90
+ $_params = array("file_id" => $file_id, "folder_id" => $folder_id);
91
+ return $this->master->call('gallery/remove-file-from-folder', $_params);
92
+ }
93
+
94
+ /**
95
+ * Remove all files from a folder (Note that the files are not deleted, they are only removed from the folder)
96
+ * @param int $folder_id
97
+ * @return boolean true/false for success/failure
98
+ */
99
+ public function removeAllFilesFromFolder($folder_id) {
100
+ $_params = array("folder_id" => $folder_id);
101
+ return $this->master->call('gallery/remove-all-files-from-folder', $_params);
102
+ }
103
+
104
+ }
105
+
106
+
includes/externals/mailchimp/Mailchimp/Goal.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Goal {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Retrieve goal event data for a particular list member. Note: only unique events are returned. If a user triggers
10
+ a particular event multiple times, you will still only receive one entry for that event.
11
+ * @param string $list_id
12
+ * @param associative_array $email
13
+ * - email string an email address
14
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
15
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
16
+ * @param int $start
17
+ * @param int $limit
18
+ * @return associative_array Event data and metadata
19
+ * - data array An array of goal data structs for the specified list member in the following format
20
+ * - event string The URL or name of the event that was triggered
21
+ * - last_visited_at string A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
22
+ * - total int The total number of events that match your criteria.
23
+ */
24
+ public function events($list_id, $email, $start=0, $limit=25) {
25
+ $_params = array("list_id" => $list_id, "email" => $email, "start" => $start, "limit" => $limit);
26
+ return $this->master->call('goal/events', $_params);
27
+ }
28
+
29
+ /**
30
+ * This allows programmatically trigger goal event collection without the use of front-end code.
31
+ * @param string $list_id
32
+ * @param associative_array $email
33
+ * - email string an email address
34
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
35
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
36
+ * @param string $campaign_id
37
+ * @param string $event
38
+ * @return associative_array Event data for the submitted event
39
+ * - event string The URL or name of the event that was triggered
40
+ * - last_visited_at string A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
41
+ */
42
+ public function recordEvent($list_id, $email, $campaign_id, $event) {
43
+ $_params = array("list_id" => $list_id, "email" => $email, "campaign_id" => $campaign_id, "event" => $event);
44
+ return $this->master->call('goal/record-event', $_params);
45
+ }
46
+
47
+ }
48
+
49
+
includes/externals/mailchimp/Mailchimp/Helper.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Helper {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Retrieve lots of account information including payments made, plan info, some account stats, installed modules,
10
+ contact info, and more. No private information like Credit Card numbers is available.
11
+ * @param array $exclude
12
+ * @return associative_array containing the details for the account tied to this API Key
13
+ * - username string The company name associated with the account
14
+ * - user_id string The Account user unique id (for building some links)
15
+ * - is_trial bool Whether the Account is in Trial mode (can only send campaigns to less than 100 emails)
16
+ * - is_approved bool Whether the Account has been approved for purchases
17
+ * - has_activated bool Whether the Account has been activated
18
+ * - timezone string The timezone for the Account - default is "US/Eastern"
19
+ * - plan_type string Plan Type - "monthly", "payasyougo", or "free"
20
+ * - plan_low int <em>only for Monthly plans</em> - the lower tier for list size
21
+ * - plan_high int <em>only for Monthly plans</em> - the upper tier for list size
22
+ * - plan_start_date string <em>only for Monthly plans</em> - the start date for a monthly plan
23
+ * - emails_left int <em>only for Free and Pay-as-you-go plans</em> emails credits left for the account
24
+ * - pending_monthly bool Whether the account is finishing Pay As You Go credits before switching to a Monthly plan
25
+ * - first_payment string date of first payment
26
+ * - last_payment string date of most recent payment
27
+ * - times_logged_in int total number of times the account has been logged into via the web
28
+ * - last_login string date/time of last login via the web
29
+ * - affiliate_link string Monkey Rewards link for our Affiliate program
30
+ * - industry string the user's selected industry
31
+ * - contact associative_array Contact details for the account
32
+ * - fname string First Name
33
+ * - lname string Last Name
34
+ * - email string Email Address
35
+ * - company string Company Name
36
+ * - address1 string Address Line 1
37
+ * - address2 string Address Line 2
38
+ * - city string City
39
+ * - state string State or Province
40
+ * - zip string Zip or Postal Code
41
+ * - country string Country name
42
+ * - url string Website URL
43
+ * - phone string Phone number
44
+ * - fax string Fax number
45
+ * - modules array a struct for each addon module installed in the account
46
+ * - id string An internal module id
47
+ * - name string The module name
48
+ * - added string The date the module was added
49
+ * - data associative_array Any extra data associated with this module as key=>value pairs
50
+ * - orders array a struct for each order for the account
51
+ * - order_id int The order id
52
+ * - type string The order type - either "monthly" or "credits"
53
+ * - amount double The order amount
54
+ * - date string The order date
55
+ * - credits_used double The total credits used
56
+ * - rewards associative_array Rewards details for the account including credits & inspections earned, number of referrals, referral details, and rewards used
57
+ * - referrals_this_month int the total number of referrals this month
58
+ * - notify_on string whether or not we notify the user when rewards are earned
59
+ * - notify_email string the email address address used for rewards notifications
60
+ * - credits associative_array Email credits earned:
61
+ * - this_month int credits earned this month
62
+ * - total_earned int credits earned all time
63
+ * - remaining int credits remaining
64
+ * - inspections associative_array Inbox Inspections earned:
65
+ * - this_month int credits earned this month
66
+ * - total_earned int credits earned all time
67
+ * - remaining int credits remaining
68
+ * - referrals array a struct for each referral, including:
69
+ * - name string the name of the account
70
+ * - email string the email address associated with the account
71
+ * - signup_date string the signup date for the account
72
+ * - type string the source for the referral
73
+ * - applied array a struct for each applied rewards, including:
74
+ * - value int the number of credits user
75
+ * - date string the date applied
76
+ * - order_id int the order number credits were applied to
77
+ * - order_desc string the order description
78
+ * - integrations array a struct for each connected integrations that can be used with campaigns, including:
79
+ * - id int an internal id for the integration
80
+ * - name string the integration name
81
+ * - list_id string either "_any_" when globally accessible or the list id it's valid for use against
82
+ * - user_id string if applicable, the user id for the integrated system
83
+ * - account string if applicable, the user/account name for the integrated system
84
+ * - profiles array For Facebook, users/page that can be posted to.
85
+ * - id string the user or page id
86
+ * - name string the user or page name
87
+ * - is_page bool whether this is a user or a page
88
+ */
89
+ public function accountDetails($exclude=array()) {
90
+ $_params = array("exclude" => $exclude);
91
+ return $this->master->call('helper/account-details', $_params);
92
+ }
93
+
94
+ /**
95
+ * Retrieve minimal data for all Campaigns a member was sent
96
+ * @param associative_array $email
97
+ * - email string an email address
98
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
99
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
100
+ * @param associative_array $options
101
+ * - list_id string optional A list_id to limit the campaigns to
102
+ * @return array an array of structs containing campaign data for each matching campaign (ordered by send time ascending), including:
103
+ * - id string the campaign unique id
104
+ * - title string the campaign's title
105
+ * - subject string the campaign's subject
106
+ * - send_time string the time the campaign was sent
107
+ * - type string the campaign type
108
+ */
109
+ public function campaignsForEmail($email, $options=null) {
110
+ $_params = array("email" => $email, "options" => $options);
111
+ return $this->master->call('helper/campaigns-for-email', $_params);
112
+ }
113
+
114
+ /**
115
+ * Return the current Chimp Chatter messages for an account.
116
+ * @return array An array of structs containing data for each chatter message
117
+ * - message string The chatter message
118
+ * - type string The type of the message - one of lists:new-subscriber, lists:unsubscribes, lists:profile-updates, campaigns:facebook-likes, campaigns:facebook-comments, campaigns:forward-to-friend, lists:imports, or campaigns:inbox-inspections
119
+ * - url string a url into the web app that the message could link to, if applicable
120
+ * - list_id string the list_id a message relates to, if applicable. Deleted lists will return -DELETED-
121
+ * - campaign_id string the list_id a message relates to, if applicable. Deleted campaigns will return -DELETED-
122
+ * - update_time string The date/time the message was last updated
123
+ */
124
+ public function chimpChatter() {
125
+ $_params = array();
126
+ return $this->master->call('helper/chimp-chatter', $_params);
127
+ }
128
+
129
+ /**
130
+ * Have HTML content auto-converted to a text-only format. You can send: plain HTML, an existing Campaign Id, or an existing Template Id. Note that this will <strong>not</strong> save anything to or update any of your lists, campaigns, or templates.
131
+ It's also not just Lynx and is very fine tuned for our template layouts - your mileage may vary.
132
+ * @param string $type
133
+ * @param associative_array $content
134
+ * - html string optional a single string value,
135
+ * - cid string a valid Campaign Id
136
+ * - user_template_id string the id of a user template
137
+ * - base_template_id string the id of a built in base/basic template
138
+ * - gallery_template_id string the id of a built in gallery template
139
+ * - url string a valid & public URL to pull html content from
140
+ * @return associative_array the content pass in converted to text.
141
+ * - text string the converted html
142
+ */
143
+ public function generateText($type, $content) {
144
+ $_params = array("type" => $type, "content" => $content);
145
+ return $this->master->call('helper/generate-text', $_params);
146
+ }
147
+
148
+ /**
149
+ * Send your HTML content to have the CSS inlined and optionally remove the original styles.
150
+ * @param string $html
151
+ * @param bool $strip_css
152
+ * @return associative_array with a "html" key
153
+ * - html string Your HTML content with all CSS inlined, just like if we sent it.
154
+ */
155
+ public function inlineCss($html, $strip_css=false) {
156
+ $_params = array("html" => $html, "strip_css" => $strip_css);
157
+ return $this->master->call('helper/inline-css', $_params);
158
+ }
159
+
160
+ /**
161
+ * Retrieve minimal List data for all lists a member is subscribed to.
162
+ * @param associative_array $email
163
+ * - email string an email address
164
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
165
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
166
+ * @return array An array of structs with info on the list_id the member is subscribed to.
167
+ * - id string the list unique id
168
+ * - web_id int the id referenced in web interface urls
169
+ * - name string the list name
170
+ */
171
+ public function listsForEmail($email) {
172
+ $_params = array("email" => $email);
173
+ return $this->master->call('helper/lists-for-email', $_params);
174
+ }
175
+
176
+ /**
177
+ * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
178
+ than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
179
+ string back that will explain our view on what is going on.
180
+ * @return associative_array a with a "msg" key
181
+ * - msg string containing "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
182
+ */
183
+ public function ping() {
184
+ $_params = array();
185
+ return $this->master->call('helper/ping', $_params);
186
+ }
187
+
188
+ /**
189
+ * Search all campaigns for the specified query terms
190
+ * @param string $query
191
+ * @param int $offset
192
+ * @param string $snip_start
193
+ * @param string $snip_end
194
+ * @return associative_array containing the total matches and current results
195
+ * - total int total campaigns matching
196
+ * - results array matching campaigns and snippets
197
+ * - snippet string the matching snippet for the campaign
198
+ * - campaign associative_array the matching campaign's details - will return same data as single campaign from campaigns/list()
199
+ */
200
+ public function searchCampaigns($query, $offset=0, $snip_start=null, $snip_end=null) {
201
+ $_params = array("query" => $query, "offset" => $offset, "snip_start" => $snip_start, "snip_end" => $snip_end);
202
+ return $this->master->call('helper/search-campaigns', $_params);
203
+ }
204
+
205
+ /**
206
+ * Search account wide or on a specific list using the specified query terms
207
+ * @param string $query
208
+ * @param string $id
209
+ * @param int $offset
210
+ * @return associative_array An array of both exact matches and partial matches over a full search
211
+ * - exact_matches associative_array containing the exact email address matches and current results
212
+ * - total int total members matching
213
+ * - members array each entry will be struct matching the data format for a single member as returned by lists/member-info()
214
+ * - full_search associative_array containing the total matches and current results
215
+ * - total int total members matching
216
+ * - members array each entry will be struct matching the data format for a single member as returned by lists/member-info()
217
+ */
218
+ public function searchMembers($query, $id=null, $offset=0) {
219
+ $_params = array("query" => $query, "id" => $id, "offset" => $offset);
220
+ return $this->master->call('helper/search-members', $_params);
221
+ }
222
+
223
+ /**
224
+ * Retrieve all domain verification records for an account
225
+ * @return array structs for each domain verification has been attempted for
226
+ * - domain string the verified domain
227
+ * - status string the status of the verification - either "verified" or "pending"
228
+ * - email string the email address used for verification - "pre-existing" if we automatically backfilled it at some point
229
+ */
230
+ public function verifiedDomains() {
231
+ $_params = array();
232
+ return $this->master->call('helper/verified-domains', $_params);
233
+ }
234
+
235
+ }
236
+
237
+
includes/externals/mailchimp/Mailchimp/Lists.php ADDED
@@ -0,0 +1,904 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Lists {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Get all email addresses that complained about a campaign sent to a list
10
+ * @param string $id
11
+ * @param int $start
12
+ * @param int $limit
13
+ * @param string $since
14
+ * @return associative_array the total of all reports and the specific reports reports this page
15
+ * - total int the total number of matching abuse reports
16
+ * - data array structs for the actual data for each reports, including:
17
+ * - date string date+time the abuse report was received and processed
18
+ * - email string the email address that reported abuse
19
+ * - campaign_id string the unique id for the campaign that report was made against
20
+ * - type string an internal type generally specifying the originating mail provider - may not be useful outside of filling report views
21
+ */
22
+ public function abuseReports($id, $start=0, $limit=500, $since=null) {
23
+ $_params = array("id" => $id, "start" => $start, "limit" => $limit, "since" => $since);
24
+ return $this->master->call('lists/abuse-reports', $_params);
25
+ }
26
+
27
+ /**
28
+ * Access up to the previous 180 days of daily detailed aggregated activity stats for a given list. Does not include AutoResponder activity.
29
+ * @param string $id
30
+ * @return array of structs containing daily values, each containing:
31
+ */
32
+ public function activity($id) {
33
+ $_params = array("id" => $id);
34
+ return $this->master->call('lists/activity', $_params);
35
+ }
36
+
37
+ /**
38
+ * Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you
39
+ only run this method as a POST request, and <em>not</em> a GET request. Maximum batch sizes vary based on the amount of data in each record,
40
+ though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
41
+ * @param string $id
42
+ * @param array $batch
43
+ * - email associative_array a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Provide multiples and we'll use the first we see in this same order.
44
+ * - email string an email address
45
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
46
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
47
+ * - email_type string for the email type option (html or text)
48
+ * - merge_vars associative_array data for the various list specific and special merge vars documented in lists/subscribe
49
+ * @param boolean $double_optin
50
+ * @param boolean $update_existing
51
+ * @param boolean $replace_interests
52
+ * @return associative_array struct of result counts and associated data
53
+ * - add_count int Number of email addresses that were successfully added
54
+ * - adds array array of structs for each add
55
+ * - email string the email address added
56
+ * - euid string the email unique id
57
+ * - leid string the list member's truly unique id
58
+ * - update_count int Number of email addresses that were successfully updated
59
+ * - updates array array of structs for each update
60
+ * - email string the email address added
61
+ * - euid string the email unique id
62
+ * - leid string the list member's truly unique id
63
+ * - error_count int Number of email addresses that failed during addition/updating
64
+ * - errors array array of error structs including:
65
+ * - email string whatever was passed in the batch record's email parameter
66
+ * - email string the email address added
67
+ * - euid string the email unique id
68
+ * - leid string the list member's truly unique id
69
+ * - code int the error code
70
+ * - error string the full error message
71
+ * - row associative_array the row from the batch that caused the error
72
+ */
73
+ public function batchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
74
+ $_params = array("id" => $id, "batch" => $batch, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests);
75
+ return $this->master->call('lists/batch-subscribe', $_params);
76
+ }
77
+
78
+ /**
79
+ * Unsubscribe a batch of email addresses from a list
80
+ * @param string $id
81
+ * @param array $batch
82
+ * - email string an email address
83
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
84
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
85
+ * @param boolean $delete_member
86
+ * @param boolean $send_goodbye
87
+ * @param boolean $send_notify
88
+ * @return array Array of structs containing results and any errors that occurred
89
+ * - success_count int Number of email addresses that were successfully removed
90
+ * - error_count int Number of email addresses that failed during addition/updating
91
+ * - errors array array of error structs including:
92
+ * - email string whatever was passed in the batch record's email parameter
93
+ * - email string the email address added
94
+ * - euid string the email unique id
95
+ * - leid string the list member's truly unique id
96
+ * - code int the error code
97
+ * - error string the full error message
98
+ */
99
+ public function batchUnsubscribe($id, $batch, $delete_member=false, $send_goodbye=true, $send_notify=false) {
100
+ $_params = array("id" => $id, "batch" => $batch, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
101
+ return $this->master->call('lists/batch-unsubscribe', $_params);
102
+ }
103
+
104
+ /**
105
+ * Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by <a href="http://user-agent-string.info" target="_blank">user-agent-string.info</a>
106
+ * @param string $id
107
+ * @return associative_array the desktop and mobile user agents in use on the list
108
+ * - desktop associative_array desktop user agents and percentages
109
+ * - penetration double the percent of desktop clients in use
110
+ * - clients array array of structs for each client including:
111
+ * - client string the common name for the client
112
+ * - icon string a url to an image representing this client
113
+ * - percent string percent of list using the client
114
+ * - members string total members using the client
115
+ * - mobile associative_array mobile user agents and percentages
116
+ * - penetration double the percent of mobile clients in use
117
+ * - clients array array of structs for each client including:
118
+ * - client string the common name for the client
119
+ * - icon string a url to an image representing this client
120
+ * - percent string percent of list using the client
121
+ * - members string total members using the client
122
+ */
123
+ public function clients($id) {
124
+ $_params = array("id" => $id);
125
+ return $this->master->call('lists/clients', $_params);
126
+ }
127
+
128
+ /**
129
+ * Access the Growth History by Month in aggregate or for a given list.
130
+ * @param string $id
131
+ * @return array array of structs containing months and growth data
132
+ * - month string The Year and Month in question using YYYY-MM format
133
+ * - existing int number of existing subscribers to start the month
134
+ * - imports int number of subscribers imported during the month
135
+ * - optins int number of subscribers who opted-in during the month
136
+ */
137
+ public function growthHistory($id=null) {
138
+ $_params = array("id" => $id);
139
+ return $this->master->call('lists/growth-history', $_params);
140
+ }
141
+
142
+ /**
143
+ * Get the list of interest groupings for a given list, including the label, form information, and included groups for each
144
+ * @param string $id
145
+ * @param bool $counts
146
+ * @return array array of structs of the interest groupings for the list
147
+ * - id int The id for the Grouping
148
+ * - name string Name for the Interest groups
149
+ * - form_field string Gives the type of interest group: checkbox,radio,select
150
+ * - groups array Array structs of the grouping options (interest groups) including:
151
+ * - bit string the bit value - not really anything to be done with this
152
+ * - name string the name of the group
153
+ * - display_order string the display order of the group, if set
154
+ * - subscribers int total number of subscribers who have this group if "counts" is true. otherwise empty
155
+ */
156
+ public function interestGroupings($id, $counts=false) {
157
+ $_params = array("id" => $id, "counts" => $counts);
158
+ return $this->master->call('lists/interest-groupings', $_params);
159
+ }
160
+
161
+ /**
162
+ * Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first
163
+ group will automatically turn them on.
164
+ * @param string $id
165
+ * @param string $group_name
166
+ * @param int $grouping_id
167
+ * @return associative_array with a single entry:
168
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
169
+ */
170
+ public function interestGroupAdd($id, $group_name, $grouping_id=null) {
171
+ $_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
172
+ return $this->master->call('lists/interest-group-add', $_params);
173
+ }
174
+
175
+ /**
176
+ * Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
177
+ * @param string $id
178
+ * @param string $group_name
179
+ * @param int $grouping_id
180
+ * @return associative_array with a single entry:
181
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
182
+ */
183
+ public function interestGroupDel($id, $group_name, $grouping_id=null) {
184
+ $_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
185
+ return $this->master->call('lists/interest-group-del', $_params);
186
+ }
187
+
188
+ /**
189
+ * Change the name of an Interest Group
190
+ * @param string $id
191
+ * @param string $old_name
192
+ * @param string $new_name
193
+ * @param int $grouping_id
194
+ * @return associative_array with a single entry:
195
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
196
+ */
197
+ public function interestGroupUpdate($id, $old_name, $new_name, $grouping_id=null) {
198
+ $_params = array("id" => $id, "old_name" => $old_name, "new_name" => $new_name, "grouping_id" => $grouping_id);
199
+ return $this->master->call('lists/interest-group-update', $_params);
200
+ }
201
+
202
+ /**
203
+ * Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first
204
+ grouping will automatically turn them on.
205
+ * @param string $id
206
+ * @param string $name
207
+ * @param string $type
208
+ * @param array $groups
209
+ * @return associative_array with a single entry:
210
+ * - id int the new grouping id if the request succeeds, otherwise an error will be thrown
211
+ */
212
+ public function interestGroupingAdd($id, $name, $type, $groups) {
213
+ $_params = array("id" => $id, "name" => $name, "type" => $type, "groups" => $groups);
214
+ return $this->master->call('lists/interest-grouping-add', $_params);
215
+ }
216
+
217
+ /**
218
+ * Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
219
+ * @param int $grouping_id
220
+ * @return associative_array with a single entry:
221
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
222
+ */
223
+ public function interestGroupingDel($grouping_id) {
224
+ $_params = array("grouping_id" => $grouping_id);
225
+ return $this->master->call('lists/interest-grouping-del', $_params);
226
+ }
227
+
228
+ /**
229
+ * Update an existing Interest Grouping
230
+ * @param int $grouping_id
231
+ * @param string $name
232
+ * @param string $value
233
+ * @return associative_array with a single entry:
234
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
235
+ */
236
+ public function interestGroupingUpdate($grouping_id, $name, $value) {
237
+ $_params = array("grouping_id" => $grouping_id, "name" => $name, "value" => $value);
238
+ return $this->master->call('lists/interest-grouping-update', $_params);
239
+ }
240
+
241
+ /**
242
+ * Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address
243
+ * @param string $id
244
+ * @return array array of locations
245
+ * - country string the country name
246
+ * - cc string the ISO 3166 2 digit country code
247
+ * - percent double the percent of subscribers in the country
248
+ * - total double the total number of subscribers in the country
249
+ */
250
+ public function locations($id) {
251
+ $_params = array("id" => $id);
252
+ return $this->master->call('lists/locations', $_params);
253
+ }
254
+
255
+ /**
256
+ * Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to, etc.)
257
+ * @param string $id
258
+ * @param array $emails
259
+ * - email string an email address - for new subscribers obviously this should be used
260
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
261
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
262
+ * @return associative_array of data and success/error counts
263
+ * - success_count int the number of subscribers successfully found on the list
264
+ * - error_count int the number of subscribers who were not found on the list
265
+ * - errors array array of error structs including:
266
+ * - email string whatever was passed in the email parameter
267
+ * - email string the email address added
268
+ * - euid string the email unique id
269
+ * - leid string the list member's truly unique id
270
+ * - error string the error message
271
+ * - code string the error code
272
+ * - data array an array of structs where each activity record has:
273
+ * - email string whatever was passed in the email parameter
274
+ * - email string the email address added
275
+ * - euid string the email unique id
276
+ * - leid string the list member's truly unique id
277
+ * - activity array an array of structs containing the activity, including:
278
+ * - action string The action name, one of: open, click, bounce, unsub, abuse, sent, queued, ecomm, mandrill_send, mandrill_hard_bounce, mandrill_soft_bounce, mandrill_open, mandrill_click, mandrill_spam, mandrill_unsub, mandrill_reject
279
+ * - timestamp string The date+time of the action (GMT)
280
+ * - url string For click actions, the url clicked, otherwise this is empty
281
+ * - type string If there's extra bounce, unsub, etc data it will show up here.
282
+ * - campaign_id string The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list)
283
+ * - campaign_data associative_array If not deleted, the campaigns/list data for the campaign
284
+ */
285
+ public function memberActivity($id, $emails) {
286
+ $_params = array("id" => $id, "emails" => $emails);
287
+ return $this->master->call('lists/member-activity', $_params);
288
+ }
289
+
290
+ /**
291
+ * Get all the information for particular members of a list
292
+ * @param string $id
293
+ * @param array $emails
294
+ * - email string an email address - for new subscribers obviously this should be used
295
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
296
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
297
+ * @return associative_array of data and success/error counts
298
+ * - success_count int the number of subscribers successfully found on the list
299
+ * - error_count int the number of subscribers who were not found on the list
300
+ * - errors array array of error structs including:
301
+ * - email associative_array whatever was passed in the email parameter
302
+ * - email string the email address added
303
+ * - euid string the email unique id
304
+ * - leid string the list member's truly unique id
305
+ * - error string the error message
306
+ * - data array array of structs for each valid list member
307
+ * - id string The unique id (euid) for this email address on an account
308
+ * - email string The email address associated with this record
309
+ * - email_type string The type of emails this customer asked to get: html or text
310
+ * - merges associative_array a struct containing a key for each merge tags and the data for those tags for this email address, plus:
311
+ * - GROUPINGS array if Interest groupings are enabled, this will exist with structs for each grouping:
312
+ * - id int the grouping id
313
+ * - name string the interest group name
314
+ * - groups array structs for each group in the grouping
315
+ * - name string the group name
316
+ * - interested bool whether the member has this group selected
317
+ * - status string The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned
318
+ * - ip_signup string IP Address this address signed up from. This may be blank if single optin is used.
319
+ * - timestamp_signup string The date+time the double optin was initiated. This may be blank if single optin is used.
320
+ * - ip_opt string IP Address this address opted in from.
321
+ * - timestamp_opt string The date+time the optin completed
322
+ * - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
323
+ * - campaign_id string If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned.
324
+ * - lists array An array of structs for the other lists this member belongs to
325
+ * - id string the list id
326
+ * - status string the members status on that list
327
+ * - timestamp string The date+time this email address entered it's current status
328
+ * - info_changed string The last time this record was changed. If the record is old enough, this may be blank.
329
+ * - web_id int The Member id used in our web app, allows you to create a link directly to it
330
+ * - leid int The Member id used in our web app, allows you to create a link directly to it
331
+ * - list_id string The list id the for the member record being returned
332
+ * - list_name string The list name the for the member record being returned
333
+ * - language string if set/detected, a language code from <a href="http://kb.mailchimp.com/article/can-i-see-what-languages-my-subscribers-use#code" target="_blank">here</a>
334
+ * - is_gmonkey bool Whether the member is a <a href="http://mailchimp.com/features/golden-monkeys/" target="_blank">Golden Monkey</a> or not.
335
+ * - geo associative_array the geographic information if we have it. including:
336
+ * - latitude string the latitude
337
+ * - longitude string the longitude
338
+ * - gmtoff string GMT offset
339
+ * - dstoff string GMT offset during daylight savings (if DST not observered, will be same as gmtoff)
340
+ * - timezone string the timezone we've place them in
341
+ * - cc string 2 digit ISO-3166 country code
342
+ * - region string generally state, province, or similar
343
+ * - clients associative_array the client we've tracked the address as using with two keys:
344
+ * - name string the common name of the client
345
+ * - icon_url string a url representing a path to an icon representing this client
346
+ * - static_segments array structs for each static segments the member is a part of including:
347
+ * - id int the segment id
348
+ * - name string the name given to the segment
349
+ * - added string the date the member was added
350
+ * - notes array structs for each note entered for this member. For each note:
351
+ * - id int the note id
352
+ * - note string the text entered
353
+ * - created string the date the note was created
354
+ * - updated string the date the note was last updated
355
+ * - created_by_name string the name of the user who created the note. This can change as users update their profile.
356
+ */
357
+ public function memberInfo($id, $emails) {
358
+ $_params = array("id" => $id, "emails" => $emails);
359
+ return $this->master->call('lists/member-info', $_params);
360
+ }
361
+
362
+ /**
363
+ * Get all of the list members for a list that are of a particular status and potentially matching a segment. This will cause locking, so don't run multiples at once. Are you trying to get a dump including lots of merge
364
+ data or specific members of a list? If so, checkout the <a href="/export/1.0/list.func.php">List Export API</a>
365
+ * @param string $id
366
+ * @param string $status
367
+ * @param associative_array $opts
368
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
369
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
370
+ * - sort_field string optional the data field to sort by - mergeX (1-30), your custom merge tags, "email", "rating","last_update_time", or "optin_time" - invalid fields will be ignored
371
+ * - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
372
+ * - segment associative_array a properly formatted segment that works with campaigns/segment-test
373
+ * @return associative_array of the total records matched and limited list member data for this page
374
+ * - total int the total matching records
375
+ * - data array structs for each member as returned by member-info
376
+ */
377
+ public function members($id, $status='subscribed', $opts=array()) {
378
+ $_params = array("id" => $id, "status" => $status, "opts" => $opts);
379
+ return $this->master->call('lists/members', $_params);
380
+ }
381
+
382
+ /**
383
+ * Add a new merge tag to a given list
384
+ * @param string $id
385
+ * @param string $tag
386
+ * @param string $name
387
+ * @param associative_array $options
388
+ * - field_type string optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl, zip, birthday - defaults to text
389
+ * - req boolean optional indicates whether the field is required - defaults to false
390
+ * - public boolean optional indicates whether the field is displayed in public - defaults to true
391
+ * - show boolean optional indicates whether the field is displayed in the app's list member view - defaults to true
392
+ * - order int The order this merge tag should be displayed in - this will cause existing values to be reset so this fits
393
+ * - default_value string optional the default value for the field. See lists/subscribe() for formatting info. Defaults to blank - max 255 bytes
394
+ * - helptext string optional the help text to be used with some newer forms. Defaults to blank - max 255 bytes
395
+ * - choices array optional kind of - an array of strings to use as the choices for radio and dropdown type fields
396
+ * - dateformat string optional only valid for birthday and date fields. For birthday type, must be "MM/DD" (default) or "DD/MM". For date type, must be "MM/DD/YYYY" (default) or "DD/MM/YYYY". Any other values will be converted to the default.
397
+ * - phoneformat string optional "US" is the default - any other value will cause them to be unformatted (international)
398
+ * - defaultcountry string optional the <a href="http://www.iso.org/iso/english_country_names_and_code_elements" target="_blank">ISO 3166 2 digit character code</a> for the default country. Defaults to "US". Anything unrecognized will be converted to the default.
399
+ * @return associative_array the full data for the new merge var, just like merge-vars returns
400
+ * - name string Name/description of the merge field
401
+ * - req bool Denotes whether the field is required (true) or not (false)
402
+ * - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
403
+ * - public bool Whether or not this field is visible to list subscribers
404
+ * - show bool Whether the field is displayed in thelist dashboard
405
+ * - order string The order this field displays in on forms
406
+ * - default string The default value for this field
407
+ * - helptext string The helptext for this field
408
+ * - size string The width of the field to be used
409
+ * - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
410
+ * - choices array the options available for radio and dropdown field types
411
+ * - id int an unchanging id for the merge var
412
+ */
413
+ public function mergeVarAdd($id, $tag, $name, $options=array()) {
414
+ $_params = array("id" => $id, "tag" => $tag, "name" => $name, "options" => $options);
415
+ return $this->master->call('lists/merge-var-add', $_params);
416
+ }
417
+
418
+ /**
419
+ * Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well!
420
+ Note that on large lists this method may seem a bit slower than calls you typically make.
421
+ * @param string $id
422
+ * @param string $tag
423
+ * @return associative_array with a single entry:
424
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
425
+ */
426
+ public function mergeVarDel($id, $tag) {
427
+ $_params = array("id" => $id, "tag" => $tag);
428
+ return $this->master->call('lists/merge-var-del', $_params);
429
+ }
430
+
431
+ /**
432
+ * Completely resets all data stored in a merge var on a list. All data is removed and this action can not be undone.
433
+ * @param string $id
434
+ * @param string $tag
435
+ * @return associative_array with a single entry:
436
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
437
+ */
438
+ public function mergeVarReset($id, $tag) {
439
+ $_params = array("id" => $id, "tag" => $tag);
440
+ return $this->master->call('lists/merge-var-reset', $_params);
441
+ }
442
+
443
+ /**
444
+ * Sets a particular merge var to the specified value for every list member. Only merge var ids 1 - 30 may be modified this way. This is generally a dirty method
445
+ unless you're fixing data since you should probably be using default_values and/or conditional content. as with lists/merge-var-reset(), this can not be undone.
446
+ * @param string $id
447
+ * @param string $tag
448
+ * @param string $value
449
+ * @return associative_array with a single entry:
450
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
451
+ */
452
+ public function mergeVarSet($id, $tag, $value) {
453
+ $_params = array("id" => $id, "tag" => $tag, "value" => $value);
454
+ return $this->master->call('lists/merge-var-set', $_params);
455
+ }
456
+
457
+ /**
458
+ * Update most parameters for a merge tag on a given list. You cannot currently change the merge type
459
+ * @param string $id
460
+ * @param string $tag
461
+ * @param associative_array $options
462
+ * @return associative_array the full data for the new merge var, just like merge-vars returns
463
+ * - name string Name/description of the merge field
464
+ * - req bool Denotes whether the field is required (true) or not (false)
465
+ * - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
466
+ * - public bool Whether or not this field is visible to list subscribers
467
+ * - show bool Whether the field is displayed in thelist dashboard
468
+ * - order string The order this field to displays in on forms
469
+ * - default string The default value for this field
470
+ * - helptext string The helptext for this field
471
+ * - size string The width of the field to be used
472
+ * - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
473
+ * - choices array the options available for radio and dropdown field types
474
+ * - id int an unchanging id for the merge var
475
+ */
476
+ public function mergeVarUpdate($id, $tag, $options) {
477
+ $_params = array("id" => $id, "tag" => $tag, "options" => $options);
478
+ return $this->master->call('lists/merge-var-update', $_params);
479
+ }
480
+
481
+ /**
482
+ * Get the list of merge tags for a given list, including their name, tag, and required setting
483
+ * @param array $id
484
+ * @return associative_array of data and success/error counts
485
+ * - success_count int the number of subscribers successfully found on the list
486
+ * - error_count int the number of subscribers who were not found on the list
487
+ * - data array of structs for the merge tags on each list
488
+ * - id string the list id
489
+ * - name string the list name
490
+ * - merge_vars array of structs for each merge var
491
+ * - name string Name of the merge field
492
+ * - req bool Denotes whether the field is required (true) or not (false)
493
+ * - field_type string The "data type" of this merge var. One of the options accepted by field_type in lists/merge-var-add
494
+ * - public bool Whether or not this field is visible to list subscribers
495
+ * - show bool Whether the list owner has this field displayed on their list dashboard
496
+ * - order string The order the list owner has set this field to display in
497
+ * - default string The default value the list owner has set for this field
498
+ * - helptext string The helptext for this field
499
+ * - size string The width of the field to be used
500
+ * - tag string The merge tag that's used for forms and lists/subscribe() and listUpdateMember()
501
+ * - choices array For radio and dropdown field types, an array of the options available
502
+ * - id int an unchanging id for the merge var
503
+ * - errors array of error structs
504
+ * - id string the passed list id that failed
505
+ * - code int the resulting error code
506
+ * - msg string the resulting error message
507
+ */
508
+ public function mergeVars($id) {
509
+ $_params = array("id" => $id);
510
+ return $this->master->call('lists/merge-vars', $_params);
511
+ }
512
+
513
+ /**
514
+ * Retrieve all of Segments for a list.
515
+ * @param string $id
516
+ * @param string $type
517
+ * @return associative_array with 2 keys:
518
+ * - static array of structs with data for each segment
519
+ * - id int the id of the segment
520
+ * - name string the name for the segment
521
+ * - created_date string the date+time the segment was created
522
+ * - last_update string the date+time the segment was last updated (add or del)
523
+ * - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
524
+ * - saved array of structs with data for each segment
525
+ * - id int the id of the segment
526
+ * - name string the name for the segment
527
+ * - segment_opts string same match+conditions struct typically used
528
+ * - segment_text string a textual description of the segment match/conditions
529
+ * - created_date string the date+time the segment was created
530
+ * - last_update string the date+time the segment was last updated (add or del)
531
+ */
532
+ public function segments($id, $type=null) {
533
+ $_params = array("id" => $id, "type" => $type);
534
+ return $this->master->call('lists/segments', $_params);
535
+ }
536
+
537
+ /**
538
+ * Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
539
+ to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
540
+ When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
541
+ options), though performance may degrade at that point. Saved Segments (called "auto-updating" in the app) are essentially just the match+conditions typically
542
+ used.
543
+ * @param string $id
544
+ * @param associative_array $opts
545
+ * - type string either "static" or "saved"
546
+ * - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
547
+ * - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
548
+ * - match string "any" or "all"
549
+ * - conditions array structs for each condition, just like campaigns/segment-test
550
+ * @return associative_array with a single entry:
551
+ * - id int the id of the new segment, otherwise an error will be thrown.
552
+ */
553
+ public function segmentAdd($id, $opts) {
554
+ $_params = array("id" => $id, "opts" => $opts);
555
+ return $this->master->call('lists/segment-add', $_params);
556
+ }
557
+
558
+ /**
559
+ * Delete a segment. Note that this will, of course, remove any member affiliations with any static segments deleted
560
+ * @param string $id
561
+ * @param int $seg_id
562
+ * @return associative_array with a single entry:
563
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
564
+ */
565
+ public function segmentDel($id, $seg_id) {
566
+ $_params = array("id" => $id, "seg_id" => $seg_id);
567
+ return $this->master->call('lists/segment-del', $_params);
568
+ }
569
+
570
+ /**
571
+ * Allows one to test their segmentation rules before creating a campaign using them - this is no different from campaigns/segment-test() and will eventually replace it.
572
+ For the time being, the crazy segmenting condition documentation will continue to live over there.
573
+ * @param string $list_id
574
+ * @param associative_array $options
575
+ * @return associative_array with a single entry:
576
+ * - total int The total number of subscribers matching your segmentation options
577
+ */
578
+ public function segmentTest($list_id, $options) {
579
+ $_params = array("list_id" => $list_id, "options" => $options);
580
+ return $this->master->call('lists/segment-test', $_params);
581
+ }
582
+
583
+ /**
584
+ * Update an existing segment. The list and type can not be changed.
585
+ * @param string $id
586
+ * @param int $seg_id
587
+ * @param associative_array $opts
588
+ * - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
589
+ * - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
590
+ * - match string "any" or "all"
591
+ * - conditions array structs for each condition, just like campaigns/segment-test
592
+ * @return associative_array with a single entry:
593
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
594
+ */
595
+ public function segmentUpdate($id, $seg_id, $opts) {
596
+ $_params = array("id" => $id, "seg_id" => $seg_id, "opts" => $opts);
597
+ return $this->master->call('lists/segment-update', $_params);
598
+ }
599
+
600
+ /**
601
+ * Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
602
+ to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
603
+ When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
604
+ options), though performance may degrade at that point.
605
+ * @param string $id
606
+ * @param string $name
607
+ * @return associative_array with a single entry:
608
+ * - id int the id of the new segment, otherwise an error will be thrown.
609
+ */
610
+ public function staticSegmentAdd($id, $name) {
611
+ $_params = array("id" => $id, "name" => $name);
612
+ return $this->master->call('lists/static-segment-add', $_params);
613
+ }
614
+
615
+ /**
616
+ * Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
617
+ * @param string $id
618
+ * @param int $seg_id
619
+ * @return associative_array with a single entry:
620
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
621
+ */
622
+ public function staticSegmentDel($id, $seg_id) {
623
+ $_params = array("id" => $id, "seg_id" => $seg_id);
624
+ return $this->master->call('lists/static-segment-del', $_params);
625
+ }
626
+
627
+ /**
628
+ * Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
629
+ in order to be included - this <strong>will not</strong> subscribe them to the list!
630
+ * @param string $id
631
+ * @param int $seg_id
632
+ * @param array $batch
633
+ * - email string an email address
634
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
635
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
636
+ * @return associative_array an array with the results of the operation
637
+ * - success_count int the total number of successful updates (will include members already in the segment)
638
+ * - errors array structs for each error including:
639
+ * - email string whatever was passed in the email parameter
640
+ * - email string the email address added
641
+ * - euid string the email unique id
642
+ * - leid string the list member's truly unique id
643
+ * - code string the error code
644
+ * - error string the full error message
645
+ */
646
+ public function staticSegmentMembersAdd($id, $seg_id, $batch) {
647
+ $_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
648
+ return $this->master->call('lists/static-segment-members-add', $_params);
649
+ }
650
+
651
+ /**
652
+ * Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
653
+ in order to be removed - this <strong>will not</strong> unsubscribe them from the list!
654
+ * @param string $id
655
+ * @param int $seg_id
656
+ * @param array $batch
657
+ * - email string an email address
658
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
659
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
660
+ * @return associative_array an array with the results of the operation
661
+ * - success_count int the total number of successful removals
662
+ * - error_count int the total number of unsuccessful removals
663
+ * - errors array structs for each error including:
664
+ * - email string whatever was passed in the email parameter
665
+ * - email string the email address added
666
+ * - euid string the email unique id
667
+ * - leid string the list member's truly unique id
668
+ * - code string the error code
669
+ * - error string the full error message
670
+ */
671
+ public function staticSegmentMembersDel($id, $seg_id, $batch) {
672
+ $_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
673
+ return $this->master->call('lists/static-segment-members-del', $_params);
674
+ }
675
+
676
+ /**
677
+ * Resets a static segment - removes <strong>all</strong> members from the static segment. Note: does not actually affect list member data
678
+ * @param string $id
679
+ * @param int $seg_id
680
+ * @return associative_array with a single entry:
681
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
682
+ */
683
+ public function staticSegmentReset($id, $seg_id) {
684
+ $_params = array("id" => $id, "seg_id" => $seg_id);
685
+ return $this->master->call('lists/static-segment-reset', $_params);
686
+ }
687
+
688
+ /**
689
+ * Retrieve all of the Static Segments for a list.
690
+ * @param string $id
691
+ * @param boolean $get_counts
692
+ * @param int $start
693
+ * @param int $limit
694
+ * @return array an of structs with data for each static segment
695
+ * - id int the id of the segment
696
+ * - name string the name for the segment
697
+ * - member_count int the total number of subscribed members currently in a segment
698
+ * - created_date string the date+time the segment was created
699
+ * - last_update string the date+time the segment was last updated (add or del)
700
+ * - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
701
+ */
702
+ public function staticSegments($id, $get_counts=true, $start=0, $limit=null) {
703
+ $_params = array("id" => $id, "get_counts" => $get_counts, "start" => $start, "limit" => $limit);
704
+ return $this->master->call('lists/static-segments', $_params);
705
+ }
706
+
707
+ /**
708
+ * Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
709
+ * @param string $id
710
+ * @param array $email
711
+ * - email string an email address - for new subscribers obviously this should be used
712
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
713
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
714
+ * @param array $merge_vars
715
+ * - new-email string set this to change the email address. This is only respected on calls using update_existing or when passed to lists/update.
716
+ * - groupings array of Interest Grouping structs. Each should contain:
717
+ * - id int Grouping "id" from lists/interest-groupings (either this or name must be present) - this id takes precedence and can't change (unlike the name)
718
+ * - name string Grouping "name" from lists/interest-groupings (either this or id must be present)
719
+ * - groups array an array of valid group names for this grouping.
720
+ * - optin_ip string Set the Opt-in IP field. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must not be a private IP address.
721
+ * - optin_time string Set the Opt-in Time field. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must be a valid date. Use - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" to be safe. Generally, though, anything strtotime() understands we'll understand - <a href="http://us2.php.net/strtotime" target="_blank">http://us2.php.net/strtotime</a>
722
+ * - mc_location associative_array Set the member's geographic location either by optin_ip or geo data.
723
+ * - latitude string use the specified latitude (longitude must exist for this to work)
724
+ * - longitude string use the specified longitude (latitude must exist for this to work)
725
+ * - anything string if this (or any other key exists here) we'll try to use the optin ip. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks.
726
+ * - mc_language string Set the member's language preference. Supported codes are fully case-sensitive and can be found <a href="http://kb.mailchimp.com/article/can-i-see-what-languages-my-subscribers-use#code" target="_new">here</a>.
727
+ * - mc_notes array of structs for managing notes - it may contain:
728
+ * - note string the note to set. this is required unless you're deleting a note
729
+ * - id int the note id to operate on. not including this (or using an invalid id) causes a new note to be added
730
+ * - action string if the "id" key exists and is valid, an "update" key may be set to "append" (default), "prepend", "replace", or "delete" to handle how we should update existing notes. "delete", obviously, will only work with a valid "id" - passing that along with "note" and an invalid "id" is wrong and will be ignored.
731
+ * @param string $email_type
732
+ * @param bool $double_optin
733
+ * @param bool $update_existing
734
+ * @param bool $replace_interests
735
+ * @param bool $send_welcome
736
+ * @return array the ids for this subscriber
737
+ * - email string the email address added
738
+ * - euid string the email unique id
739
+ * - leid string the list member's truly unique id
740
+ */
741
+ public function subscribe($id, $email, $merge_vars=null, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
742
+ $_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests, "send_welcome" => $send_welcome);
743
+ return $this->master->call('lists/subscribe', $_params);
744
+ }
745
+
746
+ /**
747
+ * Unsubscribe the given email address from the list
748
+ * @param string $id
749
+ * @param array $email
750
+ * - email string an email address
751
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
752
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
753
+ * @param boolean $delete_member
754
+ * @param boolean $send_goodbye
755
+ * @param boolean $send_notify
756
+ * @return array with a single entry:
757
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
758
+ */
759
+ public function unsubscribe($id, $email, $delete_member=false, $send_goodbye=true, $send_notify=true) {
760
+ $_params = array("id" => $id, "email" => $email, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
761
+ return $this->master->call('lists/unsubscribe', $_params);
762
+ }
763
+
764
+ /**
765
+ * Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users,
766
+ consider using lists/batch-subscribe() with the update_existing and possible replace_interests parameter.
767
+ * @param string $id
768
+ * @param associative_array $email
769
+ * - email string an email address
770
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
771
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
772
+ * @param array $merge_vars
773
+ * @param string $email_type
774
+ * @param boolean $replace_interests
775
+ * @return associative_array the ids for this subscriber
776
+ * - email string the email address added
777
+ * - euid string the email unique id
778
+ * - leid string the list member's truly unique id
779
+ */
780
+ public function updateMember($id, $email, $merge_vars, $email_type='', $replace_interests=true) {
781
+ $_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "replace_interests" => $replace_interests);
782
+ return $this->master->call('lists/update-member', $_params);
783
+ }
784
+
785
+ /**
786
+ * Add a new Webhook URL for the given list
787
+ * @param string $id
788
+ * @param string $url
789
+ * @param associative_array $actions
790
+ * - subscribe bool optional as subscribes occur, defaults to true
791
+ * - unsubscribe bool optional as subscribes occur, defaults to true
792
+ * - profile bool optional as profile updates occur, defaults to true
793
+ * - cleaned bool optional as emails are cleaned from the list, defaults to true
794
+ * - upemail bool optional when subscribers change their email address, defaults to true
795
+ * - campaign bool option when a campaign is sent or canceled, defaults to true
796
+ * @param associative_array $sources
797
+ * - user bool optional user/subscriber initiated actions, defaults to true
798
+ * - admin bool optional admin actions in our web app, defaults to true
799
+ * - api bool optional actions that happen via API calls, defaults to false
800
+ * @return associative_array with a single entry:
801
+ * - id int the id of the new webhook, otherwise an error will be thrown.
802
+ */
803
+ public function webhookAdd($id, $url, $actions=array(), $sources=array()) {
804
+ $_params = array("id" => $id, "url" => $url, "actions" => $actions, "sources" => $sources);
805
+ return $this->master->call('lists/webhook-add', $_params);
806
+ }
807
+
808
+ /**
809
+ * Delete an existing Webhook URL from a given list
810
+ * @param string $id
811
+ * @param string $url
812
+ * @return associative_array with a single entry:
813
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
814
+ */
815
+ public function webhookDel($id, $url) {
816
+ $_params = array("id" => $id, "url" => $url);
817
+ return $this->master->call('lists/webhook-del', $_params);
818
+ }
819
+
820
+ /**
821
+ * Return the Webhooks configured for the given list
822
+ * @param string $id
823
+ * @return array of structs for each webhook
824
+ * - url string the URL for this Webhook
825
+ * - actions associative_array the possible actions and whether they are enabled
826
+ * - subscribe bool triggered when subscribes happen
827
+ * - unsubscribe bool triggered when unsubscribes happen
828
+ * - profile bool triggered when profile updates happen
829
+ * - cleaned bool triggered when a subscriber is cleaned (bounced) from a list
830
+ * - upemail bool triggered when a subscriber's email address is changed
831
+ * - campaign bool triggered when a campaign is sent or canceled
832
+ * - sources associative_array the possible sources and whether they are enabled
833
+ * - user bool whether user/subscriber triggered actions are returned
834
+ * - admin bool whether admin (manual, in-app) triggered actions are returned
835
+ * - api bool whether api triggered actions are returned
836
+ */
837
+ public function webhooks($id) {
838
+ $_params = array("id" => $id);
839
+ return $this->master->call('lists/webhooks', $_params);
840
+ }
841
+
842
+ /**
843
+ * Retrieve all of the lists defined for your user account
844
+ * @param associative_array $filters
845
+ * - list_id string optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching
846
+ * - list_name string optional - only lists that match this name
847
+ * - from_name string optional - only lists that have a default from name matching this
848
+ * - from_email string optional - only lists that have a default from email matching this
849
+ * - from_subject string optional - only lists that have a default from email matching this
850
+ * - created_before string optional - only show lists that were created before this date+time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
851
+ * - created_after string optional - only show lists that were created since this date+time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
852
+ * - exact boolean optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
853
+ * @param int $start
854
+ * @param int $limit
855
+ * @param string $sort_field
856
+ * @param string $sort_dir
857
+ * @return associative_array result of the operation including valid data and any errors
858
+ * - total int the total number of lists which matched the provided filters
859
+ * - data array structs for the lists which matched the provided filters, including the following
860
+ * - id string The list id for this list. This will be used for all other list management functions.
861
+ * - web_id int The list id used in our web app, allows you to create a link directly to it
862
+ * - name string The name of the list.
863
+ * - date_created string The date that this list was created.
864
+ * - email_type_option boolean Whether or not the List supports multiple formats for emails or just HTML
865
+ * - use_awesomebar boolean Whether or not campaigns for this list use the Awesome Bar in archives by default
866
+ * - default_from_name string Default From Name for campaigns using this list
867
+ * - default_from_email string Default From Email for campaigns using this list
868
+ * - default_subject string Default Subject Line for campaigns using this list
869
+ * - default_language string Default Language for this list's forms
870
+ * - list_rating double An auto-generated activity score for the list (0 - 5)
871
+ * - subscribe_url_short string Our eepurl shortened version of this list's subscribe form (will not change)
872
+ * - subscribe_url_long string The full version of this list's subscribe form (host will vary)
873
+ * - beamer_address string The email address to use for this list's <a href="http://kb.mailchimp.com/article/how-do-i-import-a-campaign-via-email-email-beamer/">Email Beamer</a>
874
+ * - visibility string Whether this list is Public (pub) or Private (prv). Used internally for projects like <a href="http://blog.mailchimp.com/introducing-wavelength/" target="_blank">Wavelength</a>
875
+ * - stats associative_array various stats and counts for the list - many of these are cached for at least 5 minutes
876
+ * - member_count double The number of active members in the given list.
877
+ * - unsubscribe_count double The number of members who have unsubscribed from the given list.
878
+ * - cleaned_count double The number of members cleaned from the given list.
879
+ * - member_count_since_send double The number of active members in the given list since the last campaign was sent
880
+ * - unsubscribe_count_since_send double The number of members who have unsubscribed from the given list since the last campaign was sent
881
+ * - cleaned_count_since_send double The number of members cleaned from the given list since the last campaign was sent
882
+ * - campaign_count double The number of campaigns in any status that use this list
883
+ * - grouping_count double The number of Interest Groupings for this list
884
+ * - group_count double The number of Interest Groups (regardless of grouping) for this list
885
+ * - merge_var_count double The number of merge vars for this list (not including the required EMAIL one)
886
+ * - avg_sub_rate double the average number of subscribe per month for the list (empty value if we haven't calculated this yet)
887
+ * - avg_unsub_rate double the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet)
888
+ * - target_sub_rate double the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet)
889
+ * - open_rate double the average open rate per campaign for the list (empty value if we haven't calculated this yet)
890
+ * - click_rate double the average click rate per campaign for the list (empty value if we haven't calculated this yet)
891
+ * - modules array Any list specific modules installed for this list (example is SocialPro)
892
+ * - errors array structs of any errors found while loading lists - usually just from providing invalid list ids
893
+ * - param string the data that caused the failure
894
+ * - code int the error code
895
+ * - error string the error message
896
+ */
897
+ public function getList($filters=array(), $start=0, $limit=25, $sort_field='created', $sort_dir='DESC') {
898
+ $_params = array("filters" => $filters, "start" => $start, "limit" => $limit, "sort_field" => $sort_field, "sort_dir" => $sort_dir);
899
+ return $this->master->call('lists/list', $_params);
900
+ }
901
+
902
+ }
903
+
904
+
includes/externals/mailchimp/Mailchimp/Mobile.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Mobile {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ }
9
+
10
+
includes/externals/mailchimp/Mailchimp/Neapolitan.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Neapolitan {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ }
9
+
10
+
includes/externals/mailchimp/Mailchimp/Reports.php ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Reports {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Get all email addresses that complained about a given campaign
10
+ * @param string $cid
11
+ * @param associative_array $opts
12
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
13
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
14
+ * - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
15
+ * @return associative_array abuse report data for this campaign
16
+ * - total int the total reports matched
17
+ * - data array a struct for the each report, including:
18
+ * - date string date/time the abuse report was received and processed
19
+ * - member string the email address that reported abuse - will only contain email if the list or member has been removed
20
+ * - type string an internal type generally specifying the originating mail provider - may not be useful outside of filling report views
21
+ */
22
+ public function abuse($cid, $opts=array()) {
23
+ $_params = array("cid" => $cid, "opts" => $opts);
24
+ return $this->master->call('reports/abuse', $_params);
25
+ }
26
+
27
+ /**
28
+ * Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
29
+ suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
30
+ * @param string $cid
31
+ * @return array of structs for advice on the campaign's performance, each containing:
32
+ * - msg string the advice message
33
+ * - type string the "type" of the message. one of: negative, positive, or neutral
34
+ */
35
+ public function advice($cid) {
36
+ $_params = array("cid" => $cid);
37
+ return $this->master->call('reports/advice', $_params);
38
+ }
39
+
40
+ /**
41
+ * Retrieve the most recent full bounce message for a specific email address on the given campaign.
42
+ Messages over 30 days old are subject to being removed
43
+ * @param string $cid
44
+ * @param associative_array $email
45
+ * - email string an email address - this is recommended for this method
46
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
47
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
48
+ * @return associative_array the full bounce message for this email+campaign along with some extra data.
49
+ * - date string date the bounce was received and processed
50
+ * - member associative_array the member record as returned by lists/member-info()
51
+ * - message string the entire bounce message received
52
+ */
53
+ public function bounceMessage($cid, $email) {
54
+ $_params = array("cid" => $cid, "email" => $email);
55
+ return $this->master->call('reports/bounce-message', $_params);
56
+ }
57
+
58
+ /**
59
+ * Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
60
+ of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
61
+ messages over 30 days old are subject to being removed
62
+ * @param string $cid
63
+ * @param associative_array $opts
64
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
65
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
66
+ * - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
67
+ * @return associative_array data for the full bounce messages for this campaign
68
+ * - total int that total number of bounce messages for the campaign
69
+ * - data array structs containing the data for this page
70
+ * - date string date the bounce was received and processed
71
+ * - member associative_array the member record as returned by lists/member-info()
72
+ * - message string the entire bounce message received
73
+ */
74
+ public function bounceMessages($cid, $opts=array()) {
75
+ $_params = array("cid" => $cid, "opts" => $opts);
76
+ return $this->master->call('reports/bounce-messages', $_params);
77
+ }
78
+
79
+ /**
80
+ * Return the list of email addresses that clicked on a given url, and how many times they clicked
81
+ * @param string $cid
82
+ * @param int $tid
83
+ * @param associative_array $opts
84
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
85
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
86
+ * - sort_field string optional the data to sort by - "clicked" (order clicks occurred, default) or "clicks" (total number of opens). Invalid fields will fall back on the default.
87
+ * - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
88
+ * @return associative_array containing the total records matched and the specific records for this page
89
+ * - total int the total number of records matched
90
+ * - data array structs for each email addresses that click the requested url
91
+ * - member associative_array the member record as returned by lists/member-info()
92
+ * - clicks int Total number of times the URL was clicked by this email address
93
+ */
94
+ public function clickDetail($cid, $tid, $opts=array()) {
95
+ $_params = array("cid" => $cid, "tid" => $tid, "opts" => $opts);
96
+ return $this->master->call('reports/click-detail', $_params);
97
+ }
98
+
99
+ /**
100
+ * The urls tracked and their click counts for a given campaign.
101
+ * @param string $cid
102
+ * @return associative_array including:
103
+ * - total array structs for each url tracked for the full campaign
104
+ * - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
105
+ * - clicks int Number of times the specific link was clicked
106
+ * - clicks_percent double the percentage of total clicks "clicks" represents
107
+ * - unique int Number of unique people who clicked on the specific link
108
+ * - unique_percent double the percentage of unique clicks "unique" represents
109
+ * - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
110
+ * - a array if this was an absplit campaign, stat structs for the a group
111
+ * - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
112
+ * - clicks int Number of times the specific link was clicked
113
+ * - clicks_percent double the percentage of total clicks "clicks" represents
114
+ * - unique int Number of unique people who clicked on the specific link
115
+ * - unique_percent double the percentage of unique clicks "unique" represents
116
+ * - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
117
+ * - b array if this was an absplit campaign, stat structs for the b group
118
+ * - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
119
+ * - clicks int Number of times the specific link was clicked
120
+ * - clicks_percent double the percentage of total clicks "clicks" represents
121
+ * - unique int Number of unique people who clicked on the specific link
122
+ * - unique_percent double the percentage of unique clicks "unique" represents
123
+ * - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
124
+ */
125
+ public function clicks($cid) {
126
+ $_params = array("cid" => $cid);
127
+ return $this->master->call('reports/clicks', $_params);
128
+ }
129
+
130
+ /**
131
+ * Retrieve the Ecommerce Orders tracked by ecomm/order-add()
132
+ * @param string $cid
133
+ * @param associative_array $opts
134
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
135
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
136
+ * - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
137
+ * @return associative_array the total matching orders and the specific orders for the requested page
138
+ * - total int the total matching orders
139
+ * - data array structs for the actual data for each order being returned
140
+ * - store_id string the store id generated by the plugin used to uniquely identify a store
141
+ * - store_name string the store name collected by the plugin - often the domain name
142
+ * - order_id string the internal order id the store tracked this order by
143
+ * - member associative_array the member record as returned by lists/member-info() that received this campaign and is associated with this order
144
+ * - order_total double the order total
145
+ * - tax_total double the total tax for the order (if collected)
146
+ * - ship_total double the shipping total for the order (if collected)
147
+ * - order_date string the date the order was tracked - from the store if possible, otherwise the GMT time we received it
148
+ * - lines array structs containing details of the order:
149
+ * - line_num int the line number assigned to this line
150
+ * - product_id int the product id assigned to this item
151
+ * - product_name string the product name
152
+ * - product_sku string the sku for the product
153
+ * - product_category_id int the id for the product category
154
+ * - product_category_name string the product category name
155
+ * - qty double optional the quantity of the item ordered - defaults to 1
156
+ * - cost double optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
157
+ */
158
+ public function ecommOrders($cid, $opts=array()) {
159
+ $_params = array("cid" => $cid, "opts" => $opts);
160
+ return $this->master->call('reports/ecomm-orders', $_params);
161
+ }
162
+
163
+ /**
164
+ * Retrieve the eepurl stats from the web/Twitter mentions for this campaign
165
+ * @param string $cid
166
+ * @return associative_array containing tweets, retweets, clicks, and referrer related to using the campaign's eepurl
167
+ * - twitter associative_array various Twitter related stats
168
+ * - tweets int Total number of tweets seen
169
+ * - first_tweet string date and time of the first tweet seen
170
+ * - last_tweet string date and time of the last tweet seen
171
+ * - retweets int Total number of retweets seen
172
+ * - first_retweet string date and time of the first retweet seen
173
+ * - last_retweet string date and time of the last retweet seen
174
+ * - statuses array an structs for statuses recorded including:
175
+ * - status string the text of the tweet/update
176
+ * - screen_name string the screen name as recorded when first seen
177
+ * - status_id string the status id of the tweet (they are really unsigned 64 bit ints)
178
+ * - datetime string the date/time of the tweet
179
+ * - is_retweet bool whether or not this was a retweet
180
+ * - clicks associative_array stats related to click-throughs on the eepurl
181
+ * - clicks int Total number of clicks seen
182
+ * - first_click string date and time of the first click seen
183
+ * - last_click string date and time of the first click seen
184
+ * - locations array structs for geographic locations including:
185
+ * - country string the country name the click was tracked to
186
+ * - region string the region in the country the click was tracked to (if available)
187
+ * - referrers array structs for referrers, including
188
+ * - referrer string the referrer, truncated to 100 bytes
189
+ * - clicks int Total number of clicks seen from this referrer
190
+ * - first_click string date and time of the first click seen from this referrer
191
+ * - last_click string date and time of the first click seen from this referrer
192
+ */
193
+ public function eepurl($cid) {
194
+ $_params = array("cid" => $cid);
195
+ return $this->master->call('reports/eepurl', $_params);
196
+ }
197
+
198
+ /**
199
+ * Given a campaign and email address, return the entire click and open history with timestamps, ordered by time. If you need to dump the full activity for a campaign
200
+ and/or get incremental results, you should use the <a href="http://apidocs.mailchimp.com/export/1.0/campaignsubscriberactivity.func.php" targret="_new">campaignSubscriberActivity Export API method</a>,
201
+ <strong>not</strong> this, especially for large campaigns.
202
+ * @param string $cid
203
+ * @param array $emails
204
+ * - email string an email address
205
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
206
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
207
+ * @return associative_array of data and success/error counts
208
+ * - success_count int the number of subscribers successfully found on the list
209
+ * - error_count int the number of subscribers who were not found on the list
210
+ * - errors array array of error structs including:
211
+ * - email string whatever was passed in the email parameter
212
+ * - email string the email address added
213
+ * - euid string the email unique id
214
+ * - leid string the list member's truly unique id
215
+ * - msg string the error message
216
+ * - data array an array of structs where each activity record has:
217
+ * - email string whatever was passed in the email parameter
218
+ * - email string the email address added
219
+ * - euid string the email unique id
220
+ * - leid string the list member's truly unique id
221
+ * - member associative_array the member record as returned by lists/member-info()
222
+ * - activity array an array of structs containing the activity, including:
223
+ * - action string The action name - either open or click
224
+ * - timestamp string The date/time of the action (GMT)
225
+ * - url string For click actions, the url clicked, otherwise this is empty
226
+ * - ip string The IP address the activity came from
227
+ */
228
+ public function memberActivity($cid, $emails) {
229
+ $_params = array("cid" => $cid, "emails" => $emails);
230
+ return $this->master->call('reports/member-activity', $_params);
231
+ }
232
+
233
+ /**
234
+ * Retrieve the list of email addresses that did not open a given campaign
235
+ * @param string $cid
236
+ * @param associative_array $opts
237
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
238
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
239
+ * @return associative_array a total of all matching emails and the specific emails for this page
240
+ * - total int the total number of members who didn't open the campaign
241
+ * - data array structs for each campaign member matching as returned by lists/member-info()
242
+ */
243
+ public function notOpened($cid, $opts=array()) {
244
+ $_params = array("cid" => $cid, "opts" => $opts);
245
+ return $this->master->call('reports/not-opened', $_params);
246
+ }
247
+
248
+ /**
249
+ * Retrieve the list of email addresses that opened a given campaign with how many times they opened
250
+ * @param string $cid
251
+ * @param associative_array $opts
252
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
253
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
254
+ * - sort_field string optional the data to sort by - "opened" (order opens occurred, default) or "opens" (total number of opens). Invalid fields will fall back on the default.
255
+ * - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
256
+ * @return associative_array containing the total records matched and the specific records for this page
257
+ * - total int the total number of records matched
258
+ * - data array structs for the actual opens data, including:
259
+ * - member associative_array the member record as returned by lists/member-info()
260
+ * - opens int Total number of times the campaign was opened by this email address
261
+ */
262
+ public function opened($cid, $opts=array()) {
263
+ $_params = array("cid" => $cid, "opts" => $opts);
264
+ return $this->master->call('reports/opened', $_params);
265
+ }
266
+
267
+ /**
268
+ * Get the top 5 performing email domains for this campaign. Users wanting more than 5 should use campaign reports/member-activity()
269
+ or campaignEmailStatsAIMAll() and generate any additional stats they require.
270
+ * @param string $cid
271
+ * @return array domains structs for each email domains and their associated stats
272
+ * - domain string Domain name or special "Other" to roll-up stats past 5 domains
273
+ * - total_sent int Total Email across all domains - this will be the same in every row
274
+ * - emails int Number of emails sent to this domain
275
+ * - bounces int Number of bounces
276
+ * - opens int Number of opens
277
+ * - clicks int Number of clicks
278
+ * - unsubs int Number of unsubs
279
+ * - delivered int Number of deliveries
280
+ * - emails_pct int Percentage of emails that went to this domain (whole number)
281
+ * - bounces_pct int Percentage of bounces from this domain (whole number)
282
+ * - opens_pct int Percentage of opens from this domain (whole number)
283
+ * - clicks_pct int Percentage of clicks from this domain (whole number)
284
+ * - unsubs_pct int Percentage of unsubs from this domain (whole number)
285
+ */
286
+ public function domainPerformance($cid) {
287
+ $_params = array("cid" => $cid);
288
+ return $this->master->call('reports/domain-performance', $_params);
289
+ }
290
+
291
+ /**
292
+ * Retrieve the countries/regions and number of opens tracked for each. Email address are not returned.
293
+ * @param string $cid
294
+ * @return array an array of country structs where opens occurred
295
+ * - code string The ISO3166 2 digit country code
296
+ * - name string A version of the country name, if we have it
297
+ * - opens int The total number of opens that occurred in the country
298
+ * - regions array structs of data for each sub-region in the country
299
+ * - code string An internal code for the region. When this is blank, it indicates we know the country, but not the region
300
+ * - name string The name of the region, if we have one. For blank "code" values, this will be "Rest of Country"
301
+ * - opens int The total number of opens that occurred in the country
302
+ */
303
+ public function geoOpens($cid) {
304
+ $_params = array("cid" => $cid);
305
+ return $this->master->call('reports/geo-opens', $_params);
306
+ }
307
+
308
+ /**
309
+ * Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
310
+ * @param string $cid
311
+ * @return array of structs for analytics we've collected for the passed campaign.
312
+ * - visits int number of visits
313
+ * - pages int number of page views
314
+ * - new_visits int new visits recorded
315
+ * - bounces int vistors who "bounced" from your site
316
+ * - time_on_site double the total time visitors spent on your sites
317
+ * - goal_conversions int number of goals converted
318
+ * - goal_value double value of conversion in dollars
319
+ * - revenue double revenue generated by campaign
320
+ * - transactions int number of transactions tracked
321
+ * - ecomm_conversions int number Ecommerce transactions tracked
322
+ * - goals array structs containing goal names and number of conversions
323
+ * - name string the name of the goal
324
+ * - conversions int the number of conversions for the goal
325
+ */
326
+ public function googleAnalytics($cid) {
327
+ $_params = array("cid" => $cid);
328
+ return $this->master->call('reports/google-analytics', $_params);
329
+ }
330
+
331
+ /**
332
+ * Get email addresses the campaign was sent to
333
+ * @param string $cid
334
+ * @param associative_array $opts
335
+ * - status string optional the status to pull - one of 'sent', 'hard' (bounce), or 'soft' (bounce). By default, all records are returned
336
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
337
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
338
+ * @return associative_array a total of all matching emails and the specific emails for this page
339
+ * - total int the total number of members for the campaign and status
340
+ * - data array structs for each campaign member matching
341
+ * - member associative_array the member record as returned by lists/member-info()
342
+ * - status string the status of the send - one of 'sent', 'hard', 'soft'
343
+ * - absplit_group string if this was an absplit campaign, one of 'a','b', or 'winner'
344
+ * - tz_group string if this was an timewarp campaign the timezone GMT offset the member was included in
345
+ */
346
+ public function sentTo($cid, $opts=array()) {
347
+ $_params = array("cid" => $cid, "opts" => $opts);
348
+ return $this->master->call('reports/sent-to', $_params);
349
+ }
350
+
351
+ /**
352
+ * Get the URL to a customized <a href="http://eepurl.com/gKmL" target="_blank">VIP Report</a> for the specified campaign and optionally send an email to someone with links to it. Note subsequent calls will overwrite anything already set for the same campign (eg, the password)
353
+ * @param string $cid
354
+ * @param array $opts
355
+ * - to_email string optional - optional, comma delimited list of email addresses to share the report with - no value means an email will not be sent
356
+ * - theme_id int optional - either a global or a user-specific theme id. Currently this needs to be pulled out of either the Share Report or Cobranding web views by grabbing the "theme" attribute from the list presented.
357
+ * - css_url string optional - a link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) <strong>only if</strong> loaded via the "secure_url" - max 255 bytes
358
+ * @return associative_array details for the shared report, including:
359
+ * - title string The Title of the Campaign being shared
360
+ * - url string The URL to the shared report
361
+ * - secure_url string The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned
362
+ * - password string If secured, the password for the report, otherwise this field will not be returned
363
+ */
364
+ public function share($cid, $opts=array()) {
365
+ $_params = array("cid" => $cid, "opts" => $opts);
366
+ return $this->master->call('reports/share', $_params);
367
+ }
368
+
369
+ /**
370
+ * Retrieve relevant aggregate campaign statistics (opens, bounces, clicks, etc.)
371
+ * @param string $cid
372
+ * @return associative_array the statistics for this campaign
373
+ * - syntax_errors int Number of email addresses in campaign that had syntactical errors.
374
+ * - hard_bounces int Number of email addresses in campaign that hard bounced.
375
+ * - soft_bounces int Number of email addresses in campaign that soft bounced.
376
+ * - unsubscribes int Number of email addresses in campaign that unsubscribed.
377
+ * - abuse_reports int Number of email addresses in campaign that reported campaign for abuse.
378
+ * - forwards int Number of times email was forwarded to a friend.
379
+ * - forwards_opens int Number of times a forwarded email was opened.
380
+ * - opens int Number of times the campaign was opened.
381
+ * - last_open string Date of the last time the email was opened.
382
+ * - unique_opens int Number of people who opened the campaign.
383
+ * - clicks int Number of times a link in the campaign was clicked.
384
+ * - unique_clicks int Number of unique recipient/click pairs for the campaign.
385
+ * - last_click string Date of the last time a link in the email was clicked.
386
+ * - users_who_clicked int Number of unique recipients who clicked on a link in the campaign.
387
+ * - emails_sent int Number of email addresses campaign was sent to.
388
+ * - unique_likes int total number of unique likes (Facebook)
389
+ * - recipient_likes int total number of recipients who liked (Facebook) the campaign
390
+ * - facebook_likes int total number of likes (Facebook) that came from Facebook
391
+ * - industry associative_array Various rates/percentages for the account's selected industry - empty otherwise. These will vary across calls, do not use them for anything important.
392
+ * - type string the selected industry
393
+ * - open_rate float industry open rate
394
+ * - click_rate float industry click rate
395
+ * - bounce_rate float industry bounce rate
396
+ * - unopen_rate float industry unopen rate
397
+ * - unsub_rate float industry unsub rate
398
+ * - abuse_rate float industry abuse rate
399
+ * - absplit associative_array If this was an absplit campaign, stats for the A and B groups will be returned - otherwise this is empty
400
+ * - bounces_a int bounces for the A group
401
+ * - bounces_b int bounces for the B group
402
+ * - forwards_a int forwards for the A group
403
+ * - forwards_b int forwards for the B group
404
+ * - abuse_reports_a int abuse reports for the A group
405
+ * - abuse_reports_b int abuse reports for the B group
406
+ * - unsubs_a int unsubs for the A group
407
+ * - unsubs_b int unsubs for the B group
408
+ * - recipients_click_a int clicks for the A group
409
+ * - recipients_click_b int clicks for the B group
410
+ * - forwards_opens_a int opened forwards for the A group
411
+ * - forwards_opens_b int opened forwards for the B group
412
+ * - opens_a int total opens for the A group
413
+ * - opens_b int total opens for the B group
414
+ * - last_open_a string date/time of last open for the A group
415
+ * - last_open_b string date/time of last open for the BG group
416
+ * - unique_opens_a int unique opens for the A group
417
+ * - unique_opens_b int unique opens for the B group
418
+ * - timewarp array If this campaign was a Timewarp campaign, an array of structs from each timezone stats exist for. Each will contain:
419
+ * - opens int opens for this timezone
420
+ * - last_open string the date/time of the last open for this timezone
421
+ * - unique_opens int the unique opens for this timezone
422
+ * - clicks int the total clicks for this timezone
423
+ * - last_click string the date/time of the last click for this timezone
424
+ * - unique_opens int the unique clicks for this timezone
425
+ * - bounces int the total bounces for this timezone
426
+ * - total int the total number of members sent to in this timezone
427
+ * - sent int the total number of members delivered to in this timezone
428
+ * - timeseries array structs for the first 24 hours of the campaign, per-hour stats:
429
+ * - timestamp string The timestemp in Y-m-d H:00:00 format
430
+ * - emails_sent int the total emails sent during the hour
431
+ * - unique_opens int unique opens seen during the hour
432
+ * - recipients_click int unique clicks seen during the hour
433
+ */
434
+ public function summary($cid) {
435
+ $_params = array("cid" => $cid);
436
+ return $this->master->call('reports/summary', $_params);
437
+ }
438
+
439
+ /**
440
+ * Get all unsubscribed email addresses for a given campaign
441
+ * @param string $cid
442
+ * @param associative_array $opts
443
+ * - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
444
+ * - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
445
+ * @return associative_array a total of all unsubscribed emails and the specific members for this page
446
+ * - total int the total number of unsubscribes for the campaign
447
+ * - data array structs for the email addresses that unsubscribed
448
+ * - member string the member that unsubscribed as returned by lists/member-info()
449
+ * - reason string the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
450
+ * - reason_text string if the reason is OTHER, the text entered.
451
+ */
452
+ public function unsubscribes($cid, $opts=array()) {
453
+ $_params = array("cid" => $cid, "opts" => $opts);
454
+ return $this->master->call('reports/unsubscribes', $_params);
455
+ }
456
+
457
+ }
458
+
459
+
includes/externals/mailchimp/Mailchimp/Templates.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Templates {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Create a new user template, <strong>NOT</strong> campaign content. These templates can then be applied while creating campaigns.
10
+ * @param string $name
11
+ * @param string $html
12
+ * @param int $folder_id
13
+ * @return associative_array with a single element:
14
+ * - template_id int the new template id, otherwise an error is thrown.
15
+ */
16
+ public function add($name, $html, $folder_id=null) {
17
+ $_params = array("name" => $name, "html" => $html, "folder_id" => $folder_id);
18
+ return $this->master->call('templates/add', $_params);
19
+ }
20
+
21
+ /**
22
+ * Delete (deactivate) a user template
23
+ * @param int $template_id
24
+ * @return associative_array with a single entry:
25
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
26
+ */
27
+ public function del($template_id) {
28
+ $_params = array("template_id" => $template_id);
29
+ return $this->master->call('templates/del', $_params);
30
+ }
31
+
32
+ /**
33
+ * Pull details for a specific template to help support editing
34
+ * @param int $template_id
35
+ * @param string $type
36
+ * @return associative_array info to be used when editing
37
+ * - default_content associative_array the default content broken down into the named editable sections for the template - dependant upon template, so not documented
38
+ * - sections associative_array the valid editable section names - dependant upon template, so not documented
39
+ * - source string the full source of the template as if you exported it via our template editor
40
+ * - preview string similar to the source, but the rendered version of the source from our popup preview
41
+ */
42
+ public function info($template_id, $type='user') {
43
+ $_params = array("template_id" => $template_id, "type" => $type);
44
+ return $this->master->call('templates/info', $_params);
45
+ }
46
+
47
+ /**
48
+ * Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created.
49
+ * @param associative_array $types
50
+ * - user boolean Custom templates for this user account. Defaults to true.
51
+ * - gallery boolean Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false.
52
+ * - base boolean Our "start from scratch" extremely basic templates. Defaults to false. As of the 9.0 update, "base" templates are no longer available via the API because they are now all saved Drag & Drop templates.
53
+ * @param associative_array $filters
54
+ * - category string optional for Gallery templates only, limit to a specific template category
55
+ * - folder_id string user templates, limit to this folder_id
56
+ * - include_inactive boolean user templates are not deleted, only set inactive. defaults to false.
57
+ * - inactive_only boolean only include inactive user templates. defaults to false.
58
+ * - include_drag_and_drop boolean Include templates created and saved using the new Drag & Drop editor. <strong>Note:</strong> You will not be able to edit or create new drag & drop templates via this API. This is useful only for creating a new campaign based on a drag & drop template.
59
+ * @return associative_array for each type
60
+ * - user array matching user templates, if requested.
61
+ * - id int Id of the template
62
+ * - name string Name of the template
63
+ * - layout string General description of the layout of the template
64
+ * - category string The category for the template, if there is one.
65
+ * - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
66
+ * - date_created string The date/time the template was created
67
+ * - active boolean whether or not the template is active and available for use.
68
+ * - edit_source boolean Whether or not you are able to edit the source of a template.
69
+ * - folder_id boolean if it's in one, the folder id
70
+ * - gallery array matching gallery templates, if requested.
71
+ * - id int Id of the template
72
+ * - name string Name of the template
73
+ * - layout string General description of the layout of the template
74
+ * - category string The category for the template, if there is one.
75
+ * - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
76
+ * - date_created string The date/time the template was created
77
+ * - active boolean whether or not the template is active and available for use.
78
+ * - edit_source boolean Whether or not you are able to edit the source of a template.
79
+ * - base array matching base templates, if requested. (Will always be empty as of 9.0)
80
+ */
81
+ public function getList($types=array(), $filters=array()) {
82
+ $_params = array("types" => $types, "filters" => $filters);
83
+ return $this->master->call('templates/list', $_params);
84
+ }
85
+
86
+ /**
87
+ * Undelete (reactivate) a user template
88
+ * @param int $template_id
89
+ * @return associative_array with a single entry:
90
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
91
+ */
92
+ public function undel($template_id) {
93
+ $_params = array("template_id" => $template_id);
94
+ return $this->master->call('templates/undel', $_params);
95
+ }
96
+
97
+ /**
98
+ * Replace the content of a user template, <strong>NOT</strong> campaign content.
99
+ * @param int $template_id
100
+ * @param associative_array $values
101
+ * - name string the name for the template - names must be unique and a max of 50 bytes
102
+ * - html string a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
103
+ * - folder_id int the folder to put this template in - 0 or a blank values will remove it from a folder.
104
+ * @return associative_array with a single entry:
105
+ * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
106
+ */
107
+ public function update($template_id, $values) {
108
+ $_params = array("template_id" => $template_id, "values" => $values);
109
+ return $this->master->call('templates/update', $_params);
110
+ }
111
+
112
+ }
113
+
114
+
includes/externals/mailchimp/Mailchimp/Users.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Users {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Invite a user to your account
10
+ * @param string $email
11
+ * @param string $role
12
+ * @param string $msg
13
+ * @return associative_array the method completion status
14
+ * - status string The status (success) of the call if it completed. Otherwise an error is thrown.
15
+ */
16
+ public function invite($email, $role='viewer', $msg='') {
17
+ $_params = array("email" => $email, "role" => $role, "msg" => $msg);
18
+ return $this->master->call('users/invite', $_params);
19
+ }
20
+
21
+ /**
22
+ * Resend an invite a user to your account. Note, if the same address has been invited multiple times, this will simpy re-send the most recent invite
23
+ * @param string $email
24
+ * @return associative_array the method completion status
25
+ * - status string The status (success) of the call if it completed. Otherwise an error is thrown.
26
+ */
27
+ public function inviteResend($email) {
28
+ $_params = array("email" => $email);
29
+ return $this->master->call('users/invite-resend', $_params);
30
+ }
31
+
32
+ /**
33
+ * Revoke an invitation sent to a user to your account. Note, if the same address has been invited multiple times, this will simpy revoke the most recent invite
34
+ * @param string $email
35
+ * @return associative_array the method completion status
36
+ * - status string The status (success) of the call if it completed. Otherwise an error is thrown.
37
+ */
38
+ public function inviteRevoke($email) {
39
+ $_params = array("email" => $email);
40
+ return $this->master->call('users/invite-revoke', $_params);
41
+ }
42
+
43
+ /**
44
+ * Retrieve the list of pending users invitations have been sent for.
45
+ * @return array structs for each invitation, including:
46
+ * - email string the email address the invitation was sent to
47
+ * - role string the role that will be assigned if they accept
48
+ * - sent_at string the time the invitation was sent. this will change if it's resent.
49
+ * - expiration string the expiration time for the invitation. this will change if it's resent.
50
+ * - msg string the welcome message included with the invitation
51
+ */
52
+ public function invites() {
53
+ $_params = array();
54
+ return $this->master->call('users/invites', $_params);
55
+ }
56
+
57
+ /**
58
+ * Revoke access for a specified login
59
+ * @param string $username
60
+ * @return associative_array the method completion status
61
+ * - status string The status (success) of the call if it completed. Otherwise an error is thrown.
62
+ */
63
+ public function loginRevoke($username) {
64
+ $_params = array("username" => $username);
65
+ return $this->master->call('users/login-revoke', $_params);
66
+ }
67
+
68
+ /**
69
+ * Retrieve the list of active logins.
70
+ * @return array structs for each user, including:
71
+ * - id int the login id for this login
72
+ * - username string the username used to log in
73
+ * - name string a display name for the account - empty first/last names will return the username
74
+ * - email string the email tied to the account used for passwords resets and the ilk
75
+ * - role string the role assigned to the account
76
+ * - avatar string if available, the url for the login's avatar
77
+ * - global_user_id int the globally unique user id for the user account connected to
78
+ * - dc_unique_id string the datacenter unique id for the user account connected to, like helper/account-details
79
+ */
80
+ public function logins() {
81
+ $_params = array();
82
+ return $this->master->call('users/logins', $_params);
83
+ }
84
+
85
+ /**
86
+ * Retrieve the profile for the login owning the provided API Key
87
+ * @return associative_array the current user's details, including:
88
+ * - id int the login id for this login
89
+ * - username string the username used to log in
90
+ * - name string a display name for the account - empty first/last names will return the username
91
+ * - email string the email tied to the account used for passwords resets and the ilk
92
+ * - role string the role assigned to the account
93
+ * - avatar string if available, the url for the login's avatar
94
+ * - global_user_id int the globally unique user id for the user account connected to
95
+ * - dc_unique_id string the datacenter unique id for the user account connected to, like helper/account-details
96
+ * - account_name string The name of the account to which the API key belongs
97
+ */
98
+ public function profile() {
99
+ $_params = array();
100
+ return $this->master->call('users/profile', $_params);
101
+ }
102
+
103
+ }
104
+
105
+
includes/externals/mailchimp/Mailchimp/Vip.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mailchimp_Vip {
4
+ public function __construct(Mailchimp $master) {
5
+ $this->master = $master;
6
+ }
7
+
8
+ /**
9
+ * Retrieve all Activity (opens/clicks) for VIPs over the past 10 days
10
+ * @return array structs for each activity recorded.
11
+ * - action string The action taken - either "open" or "click"
12
+ * - timestamp string The datetime the action occurred in GMT
13
+ * - url string IF the action is a click, the url that was clicked
14
+ * - unique_id string The campaign_id of the List the Member appears on
15
+ * - title string The campaign title
16
+ * - list_name string The name of the List the Member appears on
17
+ * - list_id string The id of the List the Member appears on
18
+ * - email string The email address of the member
19
+ * - fname string IF a FNAME merge field exists on the list, that value for the member
20
+ * - lname string IF a LNAME merge field exists on the list, that value for the member
21
+ * - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
22
+ * - member_since string the datetime the member was added and/or confirmed
23
+ * - geo associative_array the geographic information if we have it. including:
24
+ * - latitude string the latitude
25
+ * - longitude string the longitude
26
+ * - gmtoff string GMT offset
27
+ * - dstoff string GMT offset during daylight savings (if DST not observered, will be same as gmtoff
28
+ * - timezone string the timezone we've place them in
29
+ * - cc string 2 digit ISO-3166 country code
30
+ * - region string generally state, province, or similar
31
+ */
32
+ public function activity() {
33
+ $_params = array();
34
+ return $this->master->call('vip/activity', $_params);
35
+ }
36
+
37
+ /**
38
+ * Add VIPs (previously called Golden Monkeys)
39
+ * @param string $id
40
+ * @param array $emails
41
+ * - email string an email address - for new subscribers obviously this should be used
42
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
43
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
44
+ * @return associative_array of data and success/error counts
45
+ * - success_count int the number of successful adds
46
+ * - error_count int the number of unsuccessful adds
47
+ * - errors array array of error structs including:
48
+ * - email associative_array whatever was passed in the email parameter
49
+ * - email string the email address added
50
+ * - euid string the email unique id
51
+ * - leid string the list member's truly unique id
52
+ * - code string the error code
53
+ * - error string the error message
54
+ * - data array array of structs for each member added
55
+ * - email associative_array whatever was passed in the email parameter
56
+ * - email string the email address added
57
+ * - euid string the email unique id
58
+ * - leid string the list member's truly unique id
59
+ */
60
+ public function add($id, $emails) {
61
+ $_params = array("id" => $id, "emails" => $emails);
62
+ return $this->master->call('vip/add', $_params);
63
+ }
64
+
65
+ /**
66
+ * Remove VIPs - this does not affect list membership
67
+ * @param string $id
68
+ * @param array $emails
69
+ * - email string an email address - for new subscribers obviously this should be used
70
+ * - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
71
+ * - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
72
+ * @return associative_array of data and success/error counts
73
+ * - success_count int the number of successful deletions
74
+ * - error_count int the number of unsuccessful deletions
75
+ * - errors array array of error structs including:
76
+ * - email associative_array whatever was passed in the email parameter
77
+ * - email string the email address
78
+ * - euid string the email unique id
79
+ * - leid string the list member's truly unique id
80
+ * - code string the error code
81
+ * - msg string the error message
82
+ * - data array array of structs for each member deleted
83
+ * - email associative_array whatever was passed in the email parameter
84
+ * - email string the email address
85
+ * - euid string the email unique id
86
+ * - leid string the list member's truly unique id
87
+ */
88
+ public function del($id, $emails) {
89
+ $_params = array("id" => $id, "emails" => $emails);
90
+ return $this->master->call('vip/del', $_params);
91
+ }
92
+
93
+ /**
94
+ * Retrieve all Golden Monkey(s) for an account
95
+ * @return array structs for each Golden Monkey, including:
96
+ * - list_id string The id of the List the Member appears on
97
+ * - list_name string The name of the List the Member appears on
98
+ * - email string The email address of the member
99
+ * - fname string IF a FNAME merge field exists on the list, that value for the member
100
+ * - lname string IF a LNAME merge field exists on the list, that value for the member
101
+ * - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
102
+ * - member_since string the datetime the member was added and/or confirmed
103
+ */
104
+ public function members() {
105
+ $_params = array();
106
+ return $this->master->call('vip/members', $_params);
107
+ }
108
+
109
+ }
110
+
111
+
includes/funcs.inc.php CHANGED
@@ -1,27 +1,26 @@
1
  <?php
2
  /**
3
- * Loads functions created by the s2Member plugin.
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
15
- * @since 3.0
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
- exit ("Do not access this file directly.");
19
  /*
20
  Include all of the functions that came with this plugin.
21
  */
22
- if (is_dir ($ws_plugin__s2member_temp_dir = dirname (__FILE__) . "/functions"))
23
- foreach (scandir ($ws_plugin__s2member_temp_dir) as $ws_plugin__s2member_temp_s)
24
- if (preg_match ("/\.php$/", $ws_plugin__s2member_temp_s) && $ws_plugin__s2member_temp_s !== "index.php")
25
- include_once $ws_plugin__s2member_temp_dir . "/" . $ws_plugin__s2member_temp_s;
26
- unset($ws_plugin__s2member_temp_dir, $ws_plugin__s2member_temp_s);
27
- ?>
1
  <?php
2
  /**
3
+ * Loads functions created by the s2Member plugin.
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
15
+ * @since 3.0
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME']))
18
+ exit ('Do not access this file directly.');
19
  /*
20
  Include all of the functions that came with this plugin.
21
  */
22
+ if(is_dir($ws_plugin__s2member_temp_dir = dirname(__FILE__).'/functions'))
23
+ foreach(scandir($ws_plugin__s2member_temp_dir) as $ws_plugin__s2member_temp_s)
24
+ if(preg_match('/\.php$/', $ws_plugin__s2member_temp_s) && $ws_plugin__s2member_temp_s !== 'index.php')
25
+ include_once $ws_plugin__s2member_temp_dir.'/'.$ws_plugin__s2member_temp_s;
26
+ unset($ws_plugin__s2member_temp_dir, $ws_plugin__s2member_temp_s);
 
includes/menu-pages/api-ops.inc.php CHANGED
@@ -56,8 +56,8 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
56
 
57
  echo '<div class="ws-menu-page-section ws-plugin--s2member-signup-notifications-section">' . "\n";
58
  echo '<h3>Signup Notification URLs (optional)</h3>' . "\n";
59
- echo '<p>If you use affiliate software, or have back-office routines that need to be notified whenever a new Subscription is created, you\'ll want to read this section. This is marked `Signup`, because the URLs that you list below, will be notified each time a "new", "paying" Member signs up. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not. This Notification will only be triggered once for each Member. Signup Notifications are sent right after a "new", "paying" Member signs up successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, this Notification is triggered anytime a "new", "paying" Member signs up through your Payment Gateway, even if you provided them with something for free <em>(e.g. even if no money is being transacted)</em>.</p>' . "\n";
60
- echo '<p>This Notification will NOT be processed for Free Subscribers that register without going through your Payment Gateway at all (e.g. they simply register on-site; and there is no checkout whatsoever). This Notification will NOT be processed when an "existing" User/Member pays for a new Subscription <em>(see: Modification Notifications for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, this Notification will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Payment Notifications for that scenario)</em>.') . '</p>' . "\n";
61
  echo '<p>Please note, this feature is not to be confused with the PayPal IPN service. PayPal IPN <em>(and other service integrations)</em> are already built into s2Member. They remain active at all times. These Signup Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
62
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/building-an-api-notification-handler/" target="_blank" rel="external">Building An API Notification Handler</a>.</p>'."\n";
63
  do_action("ws_plugin__s2member_during_api_ops_page_during_left_sections_during_signup_notifications", get_defined_vars ());
@@ -102,7 +102,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
102
  {
103
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
104
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
105
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
106
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
107
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
108
  echo '</ul>' . "\n";
@@ -312,7 +312,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
312
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong><br />' . "\n";
313
  echo '<em>These are ONLY included with payments that occur during checkout. They will NOT be provided with any future recurring payments.</em>'."\n";
314
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
315
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
316
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
317
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
318
  echo '</ul>' . "\n";
@@ -381,7 +381,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
381
  echo '<div class="ws-menu-page-section ws-plugin--s2member-modification-notifications-section">' . "\n";
382
  echo '<h3>Modification Notification URLs (optional)</h3>' . "\n";
383
  echo '<p>If you use affiliate software, or have back-office routines that need to be notified each time a new Subscription is created by an "existing" User/Member, or an "existing" Member modifies their paid Subscription terms, you\'ll want to read this section. This is marked `Modification`, because the URLs that you list below, will be notified each time an "existing" User/Member <em>(even if they are/were a Free Subscriber)</em> signs up for a paid Subscription <em>(i.e. a Modification takes place against an existing account within WordPress)</em>, or an "existing" Member modifies their paid Subscription terms <em>(again, a Modification takes places against an existing account within WordPress)</em>. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
384
- echo '<p>Modification Notifications are sent right after a Member signs up and/or modifies billing terms successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, this Notification is triggered, even if you provided them with something for free <em>(e.g. even if no money is being transacted)</em>.</p>' . "\n";
385
  echo '<p>This Notification will NOT be processed for "new" Users/Members <em>(see: Signup Notifications for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, this Notification will NOT be processed for Independent Custom Capability purchases <em>(see: Payment Notifications for that scenario)</em>.') . '</p>' . "\n";
386
  echo '<p>Please note, this feature is not to be confused with the PayPal IPN service. PayPal IPN <em>(and other service integrations)</em> are already built into s2Member. They remain active at all times. These Modification Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
387
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/building-an-api-notification-handler/" target="_blank" rel="external">Building An API Notification Handler</a>.</p>'."\n";
@@ -433,7 +433,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
433
  {
434
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
435
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
436
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
437
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
438
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
439
  echo '</ul>' . "\n";
@@ -852,7 +852,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_api_ops"))
852
  {
853
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
854
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
855
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
856
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
857
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
858
  echo '</ul>' . "\n";
56
 
57
  echo '<div class="ws-menu-page-section ws-plugin--s2member-signup-notifications-section">' . "\n";
58
  echo '<h3>Signup Notification URLs (optional)</h3>' . "\n";
59
+ echo '<p>If you use affiliate software, or have back-office routines that need to be notified whenever a new Subscription is created, you\'ll want to read this section. This is marked `Signup`, because the URLs that you list below, will be notified each time a "new", "paying" Member signs up. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not. This Notification will only be triggered once for each Member. Signup Notifications are sent right after a "new", "paying" Member signs up successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, this Notification is triggered anytime a "new", "paying" Member signs up through your Payment Gateway, even if you provided them with something for free <em>(i.e. even if no money is being transacted)</em>.</p>' . "\n";
60
+ echo '<p>This Notification will NOT be processed for Free Subscribers that register without going through your Payment Gateway at all (i.e. they simply register on-site; and there is no checkout whatsoever). This Notification will NOT be processed when an "existing" User/Member pays for a new Subscription <em>(see: Modification Notifications for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, this Notification will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Payment Notifications for that scenario)</em>.') . '</p>' . "\n";
61
  echo '<p>Please note, this feature is not to be confused with the PayPal IPN service. PayPal IPN <em>(and other service integrations)</em> are already built into s2Member. They remain active at all times. These Signup Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
62
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/building-an-api-notification-handler/" target="_blank" rel="external">Building An API Notification Handler</a>.</p>'."\n";
63
  do_action("ws_plugin__s2member_during_api_ops_page_during_left_sections_during_signup_notifications", get_defined_vars ());
102
  {
103
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
104
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
105
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
106
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
107
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
108
  echo '</ul>' . "\n";
312
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong><br />' . "\n";
313
  echo '<em>These are ONLY included with payments that occur during checkout. They will NOT be provided with any future recurring payments.</em>'."\n";
314
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
315
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
316
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
317
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
318
  echo '</ul>' . "\n";
381
  echo '<div class="ws-menu-page-section ws-plugin--s2member-modification-notifications-section">' . "\n";
382
  echo '<h3>Modification Notification URLs (optional)</h3>' . "\n";
383
  echo '<p>If you use affiliate software, or have back-office routines that need to be notified each time a new Subscription is created by an "existing" User/Member, or an "existing" Member modifies their paid Subscription terms, you\'ll want to read this section. This is marked `Modification`, because the URLs that you list below, will be notified each time an "existing" User/Member <em>(even if they are/were a Free Subscriber)</em> signs up for a paid Subscription <em>(i.e. a Modification takes place against an existing account within WordPress)</em>, or an "existing" Member modifies their paid Subscription terms <em>(again, a Modification takes places against an existing account within WordPress)</em>. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
384
+ echo '<p>Modification Notifications are sent right after a Member signs up and/or modifies billing terms successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, this Notification is triggered, even if you provided them with something for free <em>(i.e. even if no money is being transacted)</em>.</p>' . "\n";
385
  echo '<p>This Notification will NOT be processed for "new" Users/Members <em>(see: Signup Notifications for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, this Notification will NOT be processed for Independent Custom Capability purchases <em>(see: Payment Notifications for that scenario)</em>.') . '</p>' . "\n";
386
  echo '<p>Please note, this feature is not to be confused with the PayPal IPN service. PayPal IPN <em>(and other service integrations)</em> are already built into s2Member. They remain active at all times. These Modification Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
387
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/building-an-api-notification-handler/" target="_blank" rel="external">Building An API Notification Handler</a>.</p>'."\n";
433
  {
434
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
435
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
436
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
437
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
438
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
439
  echo '</ul>' . "\n";
852
  {
853
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
854
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
855
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
856
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
857
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
858
  echo '</ul>' . "\n";
includes/menu-pages/down-ops.inc.php CHANGED
@@ -603,7 +603,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_down_ops"))
603
  echo '<td style="padding-top:0;">'."\n";
604
  echo '<ul class="ws-menu-page-li-margins">'."\n";
605
  echo '<li><code>download="file.zip"</code> Location of the file, relative to the <code>/'.esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])).'/</code> directory; or, relative to the root of your Amazon S3 Bucket, when applicable.</li>'."\n";
606
- echo '<li><code>download_key="no"</code> Defaults to <code>no</code>. If <code>download_key="1|on|yes|true|ip-forever|universal"</code>, s2Member will return a URL with an s2Member-generated File Download Key. You don\'t need to generate the File Download Key yourself, s2Member does it for you. If you set <code>download_key="ip-forever"</code>, the File Download Key that s2Member generates will last forever, for a specific IP Address; otherwise, by default, all File Download Keys expire after 24 hours automatically. If you set <code>download_key="universal"</code>, s2Member will generate a File Download Key that is good for anyone/everyone forever, with NO restrictions on who/where/when a file is accessed <em>(e.g. be careful with this one)</em>.</li>'."\n";
607
  echo '<li><code>stream="no"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>stream="1|on|yes|true"</code>, s2Member will return a URL containing a parameter/directive, which forces the File Download to take place over the RTMP protocol if at all possible. This ONLY works when/if s2Member is configured to run with both Amazon S3/CloudFront. Please note however, it\'s better to use the example code provided in the section above, regarding: <code>JW Player and the RTMP Protocol</code>. Also note, if <code>get_streamer_json="1|on|yes|true"</code>, s2Member will automatically force <code>stream="yes"</code> for you.</li>'."\n";
608
  echo '<li><code>inline=""</code> Defaults to <code>[empty]</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>inline="1|on|yes|true"</code>, s2Member will serve the file inline, instead of as an actual File Download. If empty, s2Member will look at your <code>Inline File Extensions</code> configuration above, and serve the file inline; if, and only if, its extension matches one found in your configuration. By default, s2Member serves all files as attachments <em>(i.e. downloads)</em>, except in the case of the <code>[s2Stream /]</code> Shortcode where this defaults to <code>yes</code>. Please read the section above regarding <code>Inline File Extensions</code> for further details. Also note, this Shortcode Attribute does NOTHING for files served via Amazon CloudFront. See the tech-notes listed in the Amazon CloudFront section for further details and workarounds.</li>'."\n";
609
  echo '<li><code>storage=""</code> Defaults to <code>[empty]</code>. If <code>storage="local|s3|cf"</code>, s2Member will serve the file from a specific source location, based on the value of this Shortcode Attribute. For example, if you\'ve configured Amazon S3 and/or CloudFront; but, there are a few files that you want to upload locally to the <code>/'.esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])).'/</code> directory; you can force s2Member to serve a file from local storage by setting <code>storage="local"</code> explicitly.</li>'."\n";
603
  echo '<td style="padding-top:0;">'."\n";
604
  echo '<ul class="ws-menu-page-li-margins">'."\n";
605
  echo '<li><code>download="file.zip"</code> Location of the file, relative to the <code>/'.esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])).'/</code> directory; or, relative to the root of your Amazon S3 Bucket, when applicable.</li>'."\n";
606
+ echo '<li><code>download_key="no"</code> Defaults to <code>no</code>. If <code>download_key="1|on|yes|true|ip-forever|universal"</code>, s2Member will return a URL with an s2Member-generated File Download Key. You don\'t need to generate the File Download Key yourself, s2Member does it for you. If you set <code>download_key="ip-forever"</code>, the File Download Key that s2Member generates will last forever, for a specific IP Address; otherwise, by default, all File Download Keys expire after 24 hours automatically. If you set <code>download_key="universal"</code>, s2Member will generate a File Download Key that is good for anyone/everyone forever, with NO restrictions on who/where/when a file is accessed <em>(i.e. be careful with this one)</em>.</li>'."\n";
607
  echo '<li><code>stream="no"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>stream="1|on|yes|true"</code>, s2Member will return a URL containing a parameter/directive, which forces the File Download to take place over the RTMP protocol if at all possible. This ONLY works when/if s2Member is configured to run with both Amazon S3/CloudFront. Please note however, it\'s better to use the example code provided in the section above, regarding: <code>JW Player and the RTMP Protocol</code>. Also note, if <code>get_streamer_json="1|on|yes|true"</code>, s2Member will automatically force <code>stream="yes"</code> for you.</li>'."\n";
608
  echo '<li><code>inline=""</code> Defaults to <code>[empty]</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>inline="1|on|yes|true"</code>, s2Member will serve the file inline, instead of as an actual File Download. If empty, s2Member will look at your <code>Inline File Extensions</code> configuration above, and serve the file inline; if, and only if, its extension matches one found in your configuration. By default, s2Member serves all files as attachments <em>(i.e. downloads)</em>, except in the case of the <code>[s2Stream /]</code> Shortcode where this defaults to <code>yes</code>. Please read the section above regarding <code>Inline File Extensions</code> for further details. Also note, this Shortcode Attribute does NOTHING for files served via Amazon CloudFront. See the tech-notes listed in the Amazon CloudFront section for further details and workarounds.</li>'."\n";
609
  echo '<li><code>storage=""</code> Defaults to <code>[empty]</code>. If <code>storage="local|s3|cf"</code>, s2Member will serve the file from a specific source location, based on the value of this Shortcode Attribute. For example, if you\'ve configured Amazon S3 and/or CloudFront; but, there are a few files that you want to upload locally to the <code>/'.esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])).'/</code> directory; you can force s2Member to serve a file from local storage by setting <code>storage="local"</code> explicitly.</li>'."\n";
includes/menu-pages/els-ops.inc.php CHANGED
@@ -1,419 +1,466 @@
1
  <?php
2
  /**
3
- * Menu page for the s2Member plugin (List Server Options page).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Menu_Pages
15
- * @since 3.0
16
- */
17
  if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
18
  exit("Do not access this file directly.");
19
 
20
  if(!class_exists("c_ws_plugin__s2member_menu_page_els_ops"))
 
 
 
 
 
 
 
 
21
  {
22
- /**
23
- * Menu page for the s2Member plugin (List Server Options page).
24
- *
25
- * @package s2Member\Menu_Pages
26
- * @since 110531
27
- */
28
- class c_ws_plugin__s2member_menu_page_els_ops
29
- {
30
- public function __construct()
31
- {
32
- echo '<div class="wrap ws-menu-page">'."\n";
33
-
34
- echo '<div class="ws-menu-page-toolbox">'."\n";
35
- c_ws_plugin__s2member_menu_pages_tb::display ();
36
- echo '</div>'."\n";
37
-
38
- echo '<h2>API / List Servers</h2>'."\n";
39
-
40
- echo '<table class="ws-menu-page-table">'."\n";
41
- echo '<tbody class="ws-menu-page-table-tbody">'."\n";
42
- echo '<tr class="ws-menu-page-table-tr">'."\n";
43
- echo '<td class="ws-menu-page-table-l">'."\n";
44
-
45
- echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">'."\n";
46
- echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")).'" />'."\n";
47
-
48
- do_action("ws_plugin__s2member_during_els_ops_page_before_left_sections", get_defined_vars());
49
-
50
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_mailchimp", true, get_defined_vars()))
51
- {
52
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_mailchimp", get_defined_vars());
53
-
54
- echo '<div class="ws-menu-page-group" title="MailChimp Integration">'."\n";
55
-
56
- echo '<div class="ws-menu-page-section ws-plugin--s2member-mailchimp-section">'."\n";
57
- echo '<a href="http://www.s2member.com/mailchimp" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/mailchimp-stamp.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>'."\n";
58
- echo '<h3>MailChimp List Server Integration (optional)</h3>'."\n";
59
- echo '<p>s2Member can be integrated with MailChimp. MailChimp is an email marketing service. MailChimp makes it easy to send email newsletters to your Customers, manage your MailChimp subscriber lists, and track campaign performance. Although s2Member can be integrated with almost ANY list server, we highly recommend MailChimp; because of their <a href="http://www.s2member.com/mailchimp-api-docs" target="_blank" rel="external">powerful API for MailChimp services</a>. In future versions of s2Member, we plan to build additional features into s2Member that work with, and extend MailChimp services.</p>'."\n";
60
- echo '<p>For now, we\'ve covered the basics. You can have your Members automatically subscribed to your MailChimp marketing lists <em>(e.g. newsletters / auto-responders)</em>. You\'ll need a <a href="http://www.s2member.com/mailchimp" target="_blank" rel="external">MailChimp account</a>, a <a href="http://www.s2member.com/mailchimp-api-key" target="_blank" rel="external">MailChimp API Key</a>, and your <a href="#" onclick="alert(\'To obtain your MailChimp List ID(s), log into your MailChimp account and click the Lists tab. Now click the (View) button, for the List(s) you want to integrate with s2Member. Then, click the (Settings) link. At the bottom of the (Settings) page, for each list; you\\\'ll find a Unique List ID.\'); return false;">MailChimp List IDs</a>.</p>'."\n";
61
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_mailchimp", get_defined_vars());
62
-
63
- echo '<table class="form-table">'."\n";
64
- echo '<tbody>'."\n";
65
- echo '<tr>'."\n";
66
-
67
- echo '<th>'."\n";
68
- echo '<label for="ws-plugin--s2member-mailchimp-api-key">'."\n";
69
- echo 'MailChimp API Key:'."\n";
70
- echo '</label>'."\n";
71
- echo '</th>'."\n";
72
-
73
- echo '</tr>'."\n";
74
- echo '<tr>'."\n";
75
-
76
- echo '<td>'."\n";
77
- echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_mailchimp_api_key" id="ws-plugin--s2member-mailchimp-api-key" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]).'" /><br />'."\n";
78
- echo 'Once you have a MailChimp account, you\'ll need to <a href="http://www.s2member.com/mailchimp-api-key" target="_blank" rel="external">add an API Key</a>.'."\n";
79
- echo '</td>'."\n";
80
-
81
- echo '</tr>'."\n";
82
-
83
- for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
84
- {
85
- echo '<tr>'."\n";
86
-
87
- echo '<th>'."\n";
88
- echo '<label for="ws-plugin--s2member-level'.$n.'-mailchimp-list-ids">'."\n";
89
- echo 'List ID(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
90
- echo '</label>'."\n";
91
- echo '</th>'."\n";
92
-
93
- echo '</tr>'."\n";
94
- echo '<tr>'."\n";
95
-
96
- echo '<td>'."\n";
97
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_mailchimp_list_ids" id="ws-plugin--s2member-level'.$n.'-mailchimp-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_mailchimp_list_ids"]).'" /><br />'."\n";
98
- echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these List IDs.<br />'."\n";
99
- echo 'Ex: <code>4a44fRio5d, 434ksvviEdf, 8834jsdf923, ee9djfs4jel3</code><br />'."\n";
100
- echo 'Or: <code>4a44fRio5d::Group Title::Group|Another Group</code>'."\n";
101
- echo '</td>'."\n";
102
-
103
- echo '</tr>'."\n";
104
- }
105
-
106
- echo '</tbody>'."\n";
107
- echo '</table>'."\n";
108
-
109
- echo '<div class="ws-menu-page-hr"></div>'."\n";
110
-
111
- echo '<div class="info" style="margin-bottom:0;">'."\n";
112
- echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during MailChimp processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
113
- echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
114
- echo '</div>'."\n";
115
-
116
- echo '</div>'."\n";
117
-
118
- echo '</div>'."\n";
119
-
120
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_mailchimp", get_defined_vars());
121
- }
122
 
123
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_getresponse", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars()))
124
- {
125
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_getresponse", get_defined_vars());
126
 
127
- echo '<div class="ws-menu-page-group" title="GetResponse Integration">'."\n";
128
 
129
- echo '<div class="ws-menu-page-section ws-plugin--s2member-getresponse-section">'."\n";
130
- echo '<a href="http://www.s2member.com/r/getresponse/" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/getresponse-logo.png" class="ws-menu-page-right" style="width:256px; height:89px; border:0;" alt="." /></a>'."\n";
131
- echo '<h3>GetResponse List Server Integration (optional)</h3>'."\n";
132
- echo '<p>s2Member can be integrated with GetResponse. GetResponse is a complete email marketing solution. It provides turnkey newsletter publishing and hosting features, as well as unlimited autoresponders to deliver information to your subscribers and convert them to paying customers.</p>'."\n";
133
- echo '<p>You can have your Members automatically subscribed to your GetResponse marketing lists <em>(e.g. newsletters / auto-responders)</em>. You\'ll need a <a href="http://www.s2member.com/r/getresponse" target="_blank" rel="external">GetResponse account</a>, a <a href="http://www.s2member.com/r/getresponse-api-key" target="_blank" rel="external">GetResponse API Key</a>, and your <a href="http://www.s2member.com/r/getresponse-campaigns-list" target="_blank" rel="external" onclick="alert(\'To obtain your GetResponse Campaign Token(s), log into your GetResponse account and navigate to your entire list of Campaigns. In the left-hand column you\\\'ll find a list of Unique Campaign Tokens.\\n\\nPlease click OK and we\\\'ll take you there now :-)\');">GetResponse Campaign Tokens</a>.</p>'."\n";
134
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_getresponse", get_defined_vars());
135
 
136
- echo '<table class="form-table">'."\n";
137
- echo '<tbody>'."\n";
138
- echo '<tr>'."\n";
139
 
140
- echo '<th>'."\n";
141
- echo '<label for="ws-plugin--s2member-getresponse-api-key">'."\n";
142
- echo 'GetResponse API Key:'."\n";
143
- echo '</label>'."\n";
144
- echo '</th>'."\n";
145
 
146
- echo '</tr>'."\n";
147
- echo '<tr>'."\n";
148
-
149
- echo '<td>'."\n";
150
- echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_getresponse_api_key" id="ws-plugin--s2member-getresponse-api-key" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["getresponse_api_key"]).'" /><br />'."\n";
151
- echo 'Once you have a GetResponse account, you\'ll need to login; then <a href="http://www.s2member.com/r/getresponse-api-key" target="_blank" rel="external">get your API Key</a>.'."\n";
152
- echo '</td>'."\n";
153
-
154
- echo '</tr>'."\n";
155
-
156
- for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
157
- {
158
- echo '<tr>'."\n";
159
-
160
- echo '<th>'."\n";
161
- echo '<label for="ws-plugin--s2member-level'.$n.'-getresponse-list-ids">'."\n";
162
- echo 'Campaign Token(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
163
- echo '</label>'."\n";
164
- echo '</th>'."\n";
165
-
166
- echo '</tr>'."\n";
167
- echo '<tr>'."\n";
168
-
169
- echo '<td>'."\n";
170
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_getresponse_list_ids" id="ws-plugin--s2member-level'.$n.'-getresponse-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_getresponse_list_ids"]).'" /><br />'."\n";
171
- echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these Campaign Tokens.<br />'."\n";
172
- echo 'Ex: <code>4ksdX</code> or <code>4ksdX, koeeXs, ggjXk, aakSc</code>'."\n";
173
- echo '</td>'."\n";
174
-
175
- echo '</tr>'."\n";
176
- }
177
-
178
- echo '</tbody>'."\n";
179
- echo '</table>'."\n";
180
-
181
- echo '<div class="ws-menu-page-hr"></div>'."\n";
182
-
183
- echo '<div class="info" style="margin-bottom:0;">'."\n";
184
- echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during GetResponse processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
185
- echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
186
- echo '</div>'."\n";
187
 
188
- echo '</div>'."\n";
189
 
190
- echo '</div>'."\n";
 
 
 
 
 
191
 
192
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_getresponse", get_defined_vars());
193
- }
 
194
 
195
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_aweber", true, get_defined_vars()))
196
- {
197
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_aweber", get_defined_vars());
 
 
198
 
199
- echo '<div class="ws-menu-page-group" title="AWeber Integration">'."\n";
 
200
 
201
- echo '<div class="ws-menu-page-section ws-plugin--s2member-aweber-section">'."\n";
202
- echo '<a href="http://www.s2member.com/aweber" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/aweber-logo.png" class="ws-menu-page-right ws-menu-page-bordered" style="width:125px; height:125px; border:0;" alt="." /></a>'."\n";
203
- echo '<h3>AWeber List Server Integration (optional)</h3>'."\n";
204
- echo '<p>s2Member can be integrated with AWeber. AWeber is an email marketing service. Whether you\'re looking to get your first email campaign off the ground, or you\'re a seasoned veteran who wants to dig into advanced tools like detailed email web analytics, activity based segmentation, geo-targeting and broadcast split-testing, AWeber\'s got just what you need to make email marketing work for you.</p>'."\n";
205
- echo '<p>You can have your Members automatically subscribed to your AWeber marketing lists <em>(e.g. newsletters / auto-responders)</em>. You\'ll need an <a href="http://www.s2member.com/aweber" target="_blank" rel="external">AWeber account</a> and your <a href="#" onclick="alert(\'To obtain your AWeber List ID(s), log into your AWeber account. Click on the Lists tab. On that page you\\\'ll find a Unique List ID associated with each of your lists. AWeber sometimes refers to this as a List Name instead of a List ID.\'); return false;">AWeber List IDs</a>. You will ALSO need to configure a <a href="http://www.s2member.com/kb/aweber-email-parser-for-s2member/" target="_blank" rel="external">Custom Email Parser</a> inside your AWeber account.</p>'."\n";
206
- echo '<p>Log into AWeber, and go to <em>My Lists -› Email Parser</em>. If you like, choose the PayPal Parser <em>(even if you\'re not using PayPal as your Payment Gateway)</em>. You can safely ignore the additional instructions they provide. s2Member just needs the PayPal box checked, and that\'s all. Or, even better, integrate <a href="http://www.s2member.com/kb/aweber-email-parser-for-s2member/" target="_blank" rel="external">s2Member\'s Custom Email Parser</a> for AWeber, which <strong>will improve reliability</strong> and flexibility.</p>'."\n";
207
- echo '<p><em><strong>AWeber Tip:</strong> If you want your Members to be subscribed to multiple AWeber List IDs at the same time, instead of comma-delimiting those List IDs here; we suggest a single List ID in your s2Member integration; then use <a href="https://help.aweber.com/entries/21696463-Can-I-Add-Subscribers-to-More-Than-One-List-At-Once-" target="_blank" rel="external">AWeber Automation Rules</a> for this. Automation Rules can also reduce the number of email confirmation notices that Members receive.</em></p>'."\n";
208
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_aweber", get_defined_vars());
209
 
210
- echo '<table class="form-table">'."\n";
211
- echo '<tbody>'."\n";
 
212
 
213
- for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
214
- {
215
- echo '<tr>'."\n";
216
 
217
- echo '<th>'."\n";
218
- echo '<label for="ws-plugin--s2member-level'.$n.'-aweber-list-ids">'."\n";
219
- echo 'List ID(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
220
- echo '</label>'."\n";
221
- echo '</th>'."\n";
222
 
223
- echo '</tr>'."\n";
224
- echo '<tr>'."\n";
 
225
 
226
- echo '<td>'."\n";
227
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_aweber_list_ids" id="ws-plugin--s2member-level'.$n.'-aweber-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_aweber_list_ids"]).'" /><br />'."\n";
228
- echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these List IDs.<br />'."\n";
229
- echo 'Ex: <code>mylist, anotherlist</code> — See also: <a href="https://help.aweber.com/entries/21696463-Can-I-Add-Subscribers-to-More-Than-One-List-At-Once-" target="_blank" rel="external">Automation Rules</a>'."\n";
230
- echo '</td>'."\n";
231
 
232
- echo '</tr>'."\n";
233
- }
234
 
235
- echo '</tbody>'."\n";
236
- echo '</table>'."\n";
 
 
 
 
237
 
238
- echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
 
239
 
240
- echo '<div class="info" style="margin-bottom:0;">'."\n";
241
- echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during AWeber processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
242
- echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
243
- echo '</div>'."\n";
244
 
245
- echo '</div>'."\n";
 
 
 
246
 
247
- echo '</div>'."\n";
248
 
249
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_aweber", get_defined_vars());
250
- }
251
 
252
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_opt_in", true, get_defined_vars()))
253
- {
254
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_opt_in", get_defined_vars());
 
 
255
 
256
- echo '<div class="ws-menu-page-group" title="Registration / Double Opt-In Box?">'."\n";
257
 
258
- echo '<div class="ws-menu-page-section ws-plugin--s2member-opt-in-section">'."\n";
259
- echo '<h3>Double Opt-In Checkbox Field (optional)</h3>'."\n";
260
- echo '<p>A Double Opt-In Checkbox will ONLY be displayed, if you\'ve integrated one <em>or more</em> List Servers. See also: <a href="http://www.s2member.com/kb/double-opt-in-checkbox/" target="_blank" rel="external">this KB article</a>.</p>'."\n";
261
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_opt_in", get_defined_vars());
262
-
263
- echo '<table class="form-table">'."\n";
264
- echo '<tbody>'."\n";
265
- echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '').'>'."\n";
266
-
267
- echo '<th>'."\n";
268
- echo '<label for="ws-plugin--s2member-custom-reg-opt-in-label">'."\n";
269
- echo 'Double Opt-In Checkbox Label:'."\n";
270
- echo '</label>'."\n";
271
- echo '</th>'."\n";
272
-
273
- echo '</tr>'."\n";
274
- echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '').'>'."\n";
275
-
276
- echo '<td>'."\n";
277
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_custom_reg_opt_in_label" id="ws-plugin--s2member-custom-reg-opt-in-label" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]).'" /><br />'."\n";
278
- echo 'Example: <code><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? 'checked' : 'unchecked').'.png" class="ws-plugin--s2member-custom-reg-opt-in-label-prev-img ws-menu-page-img-16" style="vertical-align:middle;" alt="" /> Your Label will appear next to a Checkbox.</code>'."\n";
279
- echo '</td>'."\n";
280
-
281
- echo '</tr>'."\n";
282
- echo '<tr>'."\n";
283
-
284
- echo '<th>'."\n";
285
- echo '<label for="ws-plugin--s2member-custom-reg-opt-in">'."\n";
286
- echo 'Require Double Opt-In Checkbox?'."\n";
287
- echo '</label>'."\n";
288
- echo '</th>'."\n";
289
-
290
- echo '</tr>'."\n";
291
- echo '<tr>'."\n";
292
-
293
- echo '<td>'."\n";
294
- echo '<select name="ws_plugin__s2member_custom_reg_opt_in" id="ws-plugin--s2member-custom-reg-opt-in">'."\n";
295
- echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? ' selected="selected"' : '').'>Yes (the Box MUST be checked — checked by default)</option>'."\n";
296
- echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 2) ? ' selected="selected"' : '').'>Yes (the Box MUST be checked — unchecked by default)</option>'."\n";
297
- echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' selected="selected"' : '').'>No (disable — do NOT display or require the Checkbox)</option>'."\n";
298
- echo '</select><br />'."\n";
299
- echo 'An email confirmation will NOT be sent to the User, unless the Box is checked, or you\'ve disabled the Box; by choosing <code>No</code>.'."\n";
300
- echo '</td>'."\n";
301
-
302
- echo '</tr>'."\n";
303
- echo '</tbody>'."\n";
304
- echo '</table>'."\n";
305
- echo '</div>'."\n";
306
 
307
- echo '</div>'."\n";
 
 
308
 
309
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_opt_in", get_defined_vars());
310
- }
 
 
 
311
 
312
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_opt_out", true, get_defined_vars()))
313
- {
314
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_opt_out", get_defined_vars());
315
 
316
- echo '<div class="ws-menu-page-group" title="Automate Un-Subscribe/Opt-Outs?">'."\n";
 
 
 
317
 
318
- echo '<div class="ws-menu-page-section ws-plugin--s2member-opt-out-section">'."\n";
319
- echo '<h3>Automate Un-Subscribe/Opt-Out Removals (optional)</h3>'."\n";
320
- echo '<p>s2Member can automatically <em>(and silently)</em> remove Users/Members from the List Servers you\'ve configured above. s2Member is also capable of automating this, based on your own personal configuration preferences. Below, you can choose which Events you consider grounds for List Removal. It is also important to point out that s2Member will ONLY remove Users/Members from the Lists you\'ve configured at the Level the User/Member is or was at during the time of the Event. For example, if a Level #1 Member is deleted, they will ONLY be removed from the List(s) you\'ve configured at Level #1. If an account is upgraded from Level #1 to Level #2, they will ONLY be removed from the List(s) you\'ve configured at Level #1. Of course, all of this is based on the configuration below.</p>'."\n";
321
- echo '<p><em><strong>*Regarding AWeber*</strong> these will NOT work for AWeber until you <a href="http://www.s2member.com/aweber-notification-email" target="_blank" rel="external">add a Notification Email</a> to your AWeber account matching the "EMail From Address" configured in <code>s2Member -› General Options -› EMail Configuration</code>. Which is currently set to: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]).'</code>. This is a required step if you want s2Member to be authenticated when it emails List Removal requests to AWeber.</em></p>'."\n";
322
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_opt_out", get_defined_vars());
323
 
324
- echo '<table class="form-table">'."\n";
325
- echo '<tbody>'."\n";
326
- echo '<tr>'."\n";
327
 
328
- echo '<th>'."\n";
329
- echo '<label for="ws-plugin--s2member-custom-reg-auto-opt-outs">'."\n";
330
- echo 'Process List Removals Automatically? (choose events)'."\n";
331
- echo '</label>'."\n";
332
- echo '</th>'."\n";
333
 
334
- echo '</tr>'."\n";
335
- echo '<tr>'."\n";
 
336
 
337
- echo '<td>'."\n";
338
- echo '<div class="ws-menu-page-scrollbox" style="height:150px;">'."\n";
339
- echo '<input type="hidden" name="ws_plugin__s2member_custom_reg_auto_opt_outs[]" value="update-signal" />'."\n";
340
- foreach(array("removal-deletion" => "<strong>Anytime a User is deleted (including manual deletions)</strong>", "ipn-refund-reversal-deletion" => "&#9492;&#9472; Anytime s2Member deletes an account because of a Refund/Reversal.", "(ipn|auto-eot)-cancellation-expiration-deletion" => "&#9492;&#9472; Anytime s2Member deletes an account because of a Cancellation/Expiration.", "modification" => "<strong>Anytime a User's Role changes (including manual changes)</strong>", "ipn-refund-reversal-demotion" => "&#9492;&#9472; Anytime s2Member demotes an account because of a Refund/Reversal.", "(ipn|auto-eot)-cancellation-expiration-demotion" => "&#9492;&#9472; Anytime s2Member demotes an account because of a Cancellation/Expiration.", "(rtn|ipn)-upgrade-downgrade" => "&#9492;&#9472; Anytime s2Member changes a User's Role after a paid Subscr. Modification.") as $ws_plugin__s2member_temp_s_value => $ws_plugin__s2member_temp_s_label)
341
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_auto_opt_outs[]" id="ws-plugin--s2member-custom-reg-auto-opt-outs-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'" value="'.esc_attr($ws_plugin__s2member_temp_s_value).'"'.((in_array($ws_plugin__s2member_temp_s_value, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"])) ? ' checked="checked"' : '').' /> <label for="ws-plugin--s2member-custom-reg-auto-opt-outs-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'">'.$ws_plugin__s2member_temp_s_label.'</label><br />'."\n";
342
- echo '</div>'."\n";
343
- echo '</td>'."\n";
344
 
345
- echo '</tr>'."\n";
346
- echo '<tr>'."\n";
347
 
348
- echo '<th>'."\n";
349
- echo '<label for="ws-plugin--s2member-custom-reg-auto-opt-out-transitions">'."\n";
350
- echo 'Also Process List Transitions Automatically?'."\n";
351
- echo '</label>'."\n";
352
- echo '</th>'."\n";
353
 
354
- echo '</tr>'."\n";
355
- echo '<tr>'."\n";
 
 
356
 
357
- echo '<td>'."\n";
358
- echo '<select name="ws_plugin__s2member_custom_reg_auto_opt_out_transitions" id="ws-plugin--s2member-custom-reg-auto-opt-out-transitions">'."\n";
359
- echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"]) ? ' selected="selected"' : '').'>No (do NOT transition mailing list subscribers automatically)</option>'."\n";
360
- echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "1") ? ' selected="selected"' : '').'>Yes (automatically transition, if able to remove from a previous list)</option>'."\n";
361
- echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "2") ? ' selected="selected"' : '').'>Yes (always automatically transition, even if NOT removed from a previous list)</option>'."\n";
362
- echo '</select><br />'."\n";
363
- echo '<em><strong>*Transitions*</strong> When/if s2Member automatically removes a Member from Lists at their current Level# (based on your configuration in the previous section), this setting tells s2Member that it should <strong>also</strong> transition the Member to any Lists you\'ve configured at the new Access Level# (i.e. Role) they are being changed to. For example, if a Member is demoted from Level #1 to Level #0, do you want s2Member to add them to the Level #0 List(s) after it removes them from the Level #1 List(s)?</em><br /><br />'."\n";
364
- echo '<em><strong>*If removed from a previous list, or NOT?*</strong> You can choose your preference above. When/if s2Member automatically transitions a mailing list subscriber, it will first try to remove the subscriber from a previous mailing list. If s2Member is able to remove the subscriber from a previous list before the transition takes place, s2Member will then make an attempt (based on your configuration) to transition the subscriber to a new/different list silently (e.g. without a new confirmation email being sent out). If s2Member is NOT able to remove a subscriber from a previous list, it can (if configured to do so) still transition a subscriber to a new list, by sending the subscriber a new email confirmation letter (e.g. this is NOT silent, because you absolutely NEED the subscriber\'s permission in this case).</em><br /><br />'."\n";
365
- echo '<em><strong>*Seamless with MailChimp*</strong> If enabled, Automatic List Transitions work seamlessly with MailChimp. Automatic List Transitions also work with GetResponse/AWeber, but GetResponse/AWeber will ALWAYS send the User/Member a new confirmation email, asking them to confirm changes to their mailing list subscription with you. Work is underway to improve this aspect of s2Member\'s integration with GetResponse/AWeber in a future release. Ideally, a Customer would be transitioned silently behind the scene with GetResponse/AWeber too, when appropriate.</em>'."\n";
366
- echo '</td>'."\n";
367
-
368
- echo '</tr>'."\n";
369
- echo '</tbody>'."\n";
370
- echo '</table>'."\n";
371
- echo '</div>'."\n";
372
 
373
- echo '</div>'."\n";
 
 
 
374
 
375
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_opt_out", get_defined_vars());
376
- }
377
 
378
- if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_other_methods", true, get_defined_vars()))
379
- {
380
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_other_methods", get_defined_vars());
381
 
382
- echo '<div class="ws-menu-page-group" title="Other List Server Integration Methods">'."\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
- echo '<div class="ws-menu-page-section ws-plugin--s2member-other-methods-section">'."\n";
385
- echo '<h3>Other List Server Integrations (there\'s always a way)</h3>'."\n";
386
- echo '<p>Check the s2Member API Notifications panel. You\'ll find additional layers of automation available through the use of the `Signup`, `Registration`, `Payment`, `EOT/Deletion`, `Refund/Reversal`, and `Specific Post/Page` Notifications that are available to you through the s2Member API. These make it possible to integrate with 3rd party applications; like list servers, affiliate programs, and other back-office routines; in more advanced ways. You will probably need to get help from a web developer though. s2Member API Notifications require some light PHP scripting by someone familiar with web service connections.</p>'."\n";
387
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_other_methods", get_defined_vars());
388
- echo '</div>'."\n";
389
 
390
- echo '</div>'."\n";
 
 
 
 
391
 
392
- do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_other_methods", get_defined_vars());
393
- }
394
 
395
- do_action("ws_plugin__s2member_during_els_ops_page_after_left_sections", get_defined_vars());
 
 
396
 
397
- echo '<div class="ws-menu-page-hr"></div>'."\n";
398
 
399
- echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>'."\n";
400
 
401
- echo '</form>'."\n";
402
 
403
- echo '</td>'."\n";
404
 
405
- echo '<td class="ws-menu-page-table-r">'."\n";
406
- c_ws_plugin__s2member_menu_pages_rs::display();
407
- echo '</td>'."\n";
408
 
409
- echo '</tr>'."\n";
410
- echo '</tbody>'."\n";
411
- echo '</table>'."\n";
412
 
413
- echo '</div>'."\n";
414
- }
415
- }
416
  }
417
-
418
- new c_ws_plugin__s2member_menu_page_els_ops();
419
- ?>
1
  <?php
2
  /**
3
+ * Menu page for the s2Member plugin (List Server Options page).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Menu_Pages
15
+ * @since 3.0
16
+ */
17
  if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
18
  exit("Do not access this file directly.");
19
 
20
  if(!class_exists("c_ws_plugin__s2member_menu_page_els_ops"))
21
+ {
22
+ /**
23
+ * Menu page for the s2Member plugin (List Server Options page).
24
+ *
25
+ * @package s2Member\Menu_Pages
26
+ * @since 110531
27
+ */
28
+ class c_ws_plugin__s2member_menu_page_els_ops
29
  {
30
+ public function __construct()
31
+ {
32
+ echo '<div class="wrap ws-menu-page">'."\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ echo '<div class="ws-menu-page-toolbox">'."\n";
35
+ c_ws_plugin__s2member_menu_pages_tb::display();
36
+ echo '</div>'."\n";
37
 
38
+ echo '<h2>API / List Servers</h2>'."\n";
39
 
40
+ echo '<table class="ws-menu-page-table">'."\n";
41
+ echo '<tbody class="ws-menu-page-table-tbody">'."\n";
42
+ echo '<tr class="ws-menu-page-table-tr">'."\n";
43
+ echo '<td class="ws-menu-page-table-l">'."\n";
 
 
44
 
45
+ echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">'."\n";
46
+ echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")).'" />'."\n";
 
47
 
48
+ do_action("ws_plugin__s2member_during_els_ops_page_before_left_sections", get_defined_vars());
 
 
 
 
49
 
50
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_mailchimp", TRUE, get_defined_vars()))
51
+ {
52
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_mailchimp", get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ echo '<div class="ws-menu-page-group" title="MailChimp Integration">'."\n";
55
 
56
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-mailchimp-section">'."\n";
57
+ echo '<a href="http://www.s2member.com/mailchimp" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/mailchimp-stamp.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>'."\n";
58
+ echo '<h3>MailChimp List Server Integration (optional)</h3>'."\n";
59
+ echo '<p>s2Member can be integrated with MailChimp. MailChimp is an email marketing service. MailChimp makes it easy to send email newsletters to your Customers, manage your MailChimp subscriber lists, and track campaign performance. Although s2Member can be integrated with almost ANY list server, we highly recommend MailChimp; because of their <a href="http://www.s2member.com/mailchimp-api-docs" target="_blank" rel="external">powerful API for MailChimp services</a>. In future versions of s2Member, we plan to build additional features into s2Member that work with, and extend MailChimp services.</p>'."\n";
60
+ echo '<p>For now, we\'ve covered the basics. You can have your Members automatically subscribed to your MailChimp marketing lists <em>(i.e. newsletters / auto-responders)</em>. You\'ll need a <a href="http://www.s2member.com/mailchimp" target="_blank" rel="external">MailChimp account</a>, a <a href="http://www.s2member.com/mailchimp-api-key" target="_blank" rel="external">MailChimp API Key</a>, and your <a href="#" onclick="alert(\'To obtain your MailChimp List ID(s), log into your MailChimp account and click the Lists tab. Now click the (View) button, for the List(s) you want to integrate with s2Member. Then, click the (Settings) link. At the bottom of the (Settings) page, for each list; you\\\'ll find a Unique List ID.\'); return false;">MailChimp List IDs</a>.</p>'."\n";
61
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_mailchimp", get_defined_vars());
62
 
63
+ echo '<table class="form-table">'."\n";
64
+ echo '<tbody>'."\n";
65
+ echo '<tr>'."\n";
66
 
67
+ echo '<th>'."\n";
68
+ echo '<label for="ws-plugin--s2member-mailchimp-api-key">'."\n";
69
+ echo 'MailChimp API Key:'."\n";
70
+ echo '</label>'."\n";
71
+ echo '</th>'."\n";
72
 
73
+ echo '</tr>'."\n";
74
+ echo '<tr>'."\n";
75
 
76
+ echo '<td>'."\n";
77
+ echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_mailchimp_api_key" id="ws-plugin--s2member-mailchimp-api-key" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]).'" /><br />'."\n";
78
+ echo 'Once you have a MailChimp account, you\'ll need to <a href="http://www.s2member.com/mailchimp-api-key" target="_blank" rel="external">add an API Key</a>.'."\n";
79
+ echo '</td>'."\n";
 
 
 
 
80
 
81
+ echo '</tr>'."\n";
82
+ echo '</tbody>'."\n";
83
+ echo '</table>'."\n";
84
 
85
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
86
 
87
+ echo '<table class="form-table">'."\n";
88
+ echo '<tbody>'."\n";
 
 
 
89
 
90
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
91
+ {
92
+ echo '<tr>'."\n";
93
 
94
+ echo '<th>'."\n";
95
+ echo '<label for="ws-plugin--s2member-level'.$n.'-mailchimp-list-ids">'."\n";
96
+ echo 'List ID(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
97
+ echo '</label>'."\n";
98
+ echo '</th>'."\n";
99
 
100
+ echo '</tr>'."\n";
101
+ echo '<tr>'."\n";
102
 
103
+ echo '<td>'."\n";
104
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_mailchimp_list_ids" id="ws-plugin--s2member-level'.$n.'-mailchimp-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_mailchimp_list_ids"]).'" /><br />'."\n";
105
+ echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these List IDs.<br />'."\n";
106
+ echo 'Ex: <code>4a44fRio5d, 434ksvviEdf, 8834jsdf923, ee9djfs4jel3</code><br />'."\n";
107
+ echo 'Or: <code>4a44fRio5d::Group Title::Group|Another Group</code>'."\n";
108
+ echo '</td>'."\n";
109
 
110
+ echo '</tr>'."\n";
111
+ }
112
+ echo '</tbody>'."\n";
113
+ echo '</table>'."\n";
114
 
115
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
 
116
 
117
+ echo '<div class="info" style="margin-bottom:0;">'."\n";
118
+ echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during MailChimp processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
119
+ echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
120
+ echo '</div>'."\n";
121
 
122
+ echo '</div>'."\n";
123
 
124
+ echo '</div>'."\n";
 
125
 
126
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_mailchimp", get_defined_vars());
127
+ }
128
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_getresponse", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars()))
129
+ {
130
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_getresponse", get_defined_vars());
131
 
132
+ echo '<div class="ws-menu-page-group" title="GetResponse Integration">'."\n";
133
 
134
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-getresponse-section">'."\n";
135
+ echo '<a href="http://www.s2member.com/r/getresponse/" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/getresponse-logo.png" class="ws-menu-page-right" style="width:256px; height:89px; border:0;" alt="." /></a>'."\n";
136
+ echo '<h3>GetResponse List Server Integration (optional)</h3>'."\n";
137
+ echo '<p>s2Member can be integrated with GetResponse. GetResponse is a complete email marketing solution. It provides turnkey newsletter publishing and hosting features, as well as unlimited autoresponders to deliver information to your subscribers and convert them to paying customers.</p>'."\n";
138
+ echo '<p>You can have your Members automatically subscribed to your GetResponse marketing lists <em>(i.e. newsletters / auto-responders)</em>. You\'ll need a <a href="http://www.s2member.com/r/getresponse" target="_blank" rel="external">GetResponse account</a>, a <a href="http://www.s2member.com/r/getresponse-api-key" target="_blank" rel="external">GetResponse API Key</a>, and your <a href="http://www.s2member.com/r/getresponse-campaigns-list" target="_blank" rel="external" onclick="alert(\'To obtain your GetResponse Campaign Token(s), log into your GetResponse account and navigate to your entire list of Campaigns. In the left-hand column you\\\'ll find a list of Unique Campaign Tokens.\\n\\nPlease click OK and we\\\'ll take you there now :-)\');">GetResponse Campaign Tokens</a>.</p>'."\n";
139
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_getresponse", get_defined_vars());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
+ echo '<table class="form-table">'."\n";
142
+ echo '<tbody>'."\n";
143
+ echo '<tr>'."\n";
144
 
145
+ echo '<th>'."\n";
146
+ echo '<label for="ws-plugin--s2member-getresponse-api-key">'."\n";
147
+ echo 'GetResponse API Key:'."\n";
148
+ echo '</label>'."\n";
149
+ echo '</th>'."\n";
150
 
151
+ echo '</tr>'."\n";
152
+ echo '<tr>'."\n";
 
153
 
154
+ echo '<td>'."\n";
155
+ echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_getresponse_api_key" id="ws-plugin--s2member-getresponse-api-key" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["getresponse_api_key"]).'" /><br />'."\n";
156
+ echo 'Once you have a GetResponse account, you\'ll need to login; then <a href="http://www.s2member.com/r/getresponse-api-key" target="_blank" rel="external">get your API Key</a>.'."\n";
157
+ echo '</td>'."\n";
158
 
159
+ echo '</tr>'."\n";
160
+ echo '</tbody>'."\n";
161
+ echo '</table>'."\n";
 
 
162
 
163
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
164
 
165
+ echo '<table class="form-table">'."\n";
166
+ echo '<tbody>'."\n";
 
 
 
167
 
168
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
169
+ {
170
+ echo '<tr>'."\n";
171
 
172
+ echo '<th>'."\n";
173
+ echo '<label for="ws-plugin--s2member-level'.$n.'-getresponse-list-ids">'."\n";
174
+ echo 'Campaign Token(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
175
+ echo '</label>'."\n";
176
+ echo '</th>'."\n";
 
 
177
 
178
+ echo '</tr>'."\n";
179
+ echo '<tr>'."\n";
180
 
181
+ echo '<td>'."\n";
182
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_getresponse_list_ids" id="ws-plugin--s2member-level'.$n.'-getresponse-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_getresponse_list_ids"]).'" /><br />'."\n";
183
+ echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these Campaign Tokens.<br />'."\n";
184
+ echo 'Ex: <code>4ksdX</code> or <code>4ksdX, koeeXs, ggjXk, aakSc</code>'."\n";
185
+ echo '</td>'."\n";
186
 
187
+ echo '</tr>'."\n";
188
+ }
189
+ echo '</tbody>'."\n";
190
+ echo '</table>'."\n";
191
 
192
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
+ echo '<div class="info" style="margin-bottom:0;">'."\n";
195
+ echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during GetResponse processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
196
+ echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
197
+ echo '</div>'."\n";
198
 
199
+ echo '</div>'."\n";
 
200
 
201
+ echo '</div>'."\n";
 
 
202
 
203
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_getresponse", get_defined_vars());
204
+ }
205
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_aweber", TRUE, get_defined_vars()))
206
+ {
207
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_aweber", get_defined_vars());
208
+
209
+ echo '<div class="ws-menu-page-group" title="AWeber Integration">'."\n";
210
+
211
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-aweber-section">'."\n";
212
+ echo '<a href="http://www.s2member.com/aweber" target="_blank"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/aweber-logo.png" class="ws-menu-page-right ws-menu-page-bordered" style="width:125px; height:125px; border:0;" alt="." /></a>'."\n";
213
+ echo '<h3>AWeber List Server Integration (optional)</h3>'."\n";
214
+ echo '<p>s2Member can be integrated with AWeber. AWeber is an email marketing service. Whether you\'re looking to get your first email campaign off the ground, or you\'re a seasoned veteran who wants to dig into advanced tools like detailed email web analytics, activity based segmentation, geo-targeting and broadcast split-testing, AWeber\'s got just what you need to make email marketing work for you. You can have your Members automatically subscribed to your AWeber marketing lists <em>(i.e. newsletters / auto-responders)</em>. You\'ll need an <a href="http://www.s2member.com/aweber" target="_blank" rel="external">AWeber account</a> and your <a href="#" onclick="alert(\'To obtain your AWeber List ID(s), log into your AWeber account. Click on the Lists tab. On that page you\\\'ll find a Unique List ID associated with each of your lists. AWeber sometimes refers to this as a List Name instead of a List ID.\'); return false;">AWeber List IDs</a>. You will ALSO need either an API Authorization Code (if you choose the API option below); or a <a href="http://www.s2member.com/kb/aweber-email-parser-for-s2member/" target="_blank" rel="external">Custom Email Parser</a> for the s2Member application.</p>'."\n";
215
+ echo '<p><em><strong>AWeber Tip:</strong> If you want your Members to be subscribed to multiple AWeber List IDs at the same time, instead of comma-delimiting those List IDs here; we suggest a single List ID in your s2Member integration; then use <a href="https://help.aweber.com/entries/21696463-Can-I-Add-Subscribers-to-More-Than-One-List-At-Once-" target="_blank" rel="external">AWeber Automation Rules</a> for this. Automation Rules can also reduce the number of email confirmation notices that Members receive.</em></p>'."\n";
216
+ echo '<p><em><strong>AWeber Tip:</strong> This company is known to have a policy of rejecting role-based email addresses like: <code>admin@</code> or <code>webmaster@</code>. Therefore, if you integrate AWeber it is suggested that you configure s2Member to Force Personal Emails. Please see: <code>s2Member ⥱ General Options ⥱ Registration/Profile Fields &amp; Options</code>.</em></p>'."\n";
217
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_aweber", get_defined_vars());
218
+
219
+ echo '<table class="form-table">'."\n";
220
+ echo '<tbody>'."\n";
221
+ echo '<tr>'."\n";
222
+
223
+ echo '<th>'."\n";
224
+ echo '<label for="ws-plugin--s2member-aweber-api-type">'."\n";
225
+ echo 'AWeber API Method (Please Choose):'."\n";
226
+ echo '</label>'."\n";
227
+ echo '</th>'."\n";
228
+
229
+ echo '</tr>'."\n";
230
+ echo '<tr>'."\n";
231
+
232
+ echo '<td>'."\n";
233
+ echo '<select name="ws_plugin__s2member_aweber_api_type" id="ws-plugin--s2member-aweber-api-type">'."\n";
234
+ echo '<option value="api"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["aweber_api_type"] === "api") ? ' selected="selected"' : '').'>API (recommended for a more robust integration)</option>'."\n";
235
+ echo '<option value="email"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["aweber_api_type"] === "email") ? ' selected="selected"' : '').'>Email (less reliable; requires an Email Parser)</option>'."\n";
236
+ echo '</select><br />'."\n";
237
+ echo 'Starting w/ s2Member™ v141005+, you can now integrate with AWeber\'s API (recommended) instead of through an Email Parser.'."\n";
238
+ echo '</td>'."\n";
239
+
240
+ echo '</tr>'."\n";
241
+ echo '<tr>'."\n";
242
+
243
+ echo '<th>'."\n";
244
+ echo '<label for="ws-plugin--s2member-aweber-api-key">'."\n";
245
+ echo 'AWeber API Authorization Code (Required for API Integration):<br />'."\n";
246
+ echo '<small>If you choose <code>API</code> above, you MUST fill this in please.</small>'."\n";
247
+ echo '</label>'."\n";
248
+ echo '</th>'."\n";
249
+
250
+ echo '</tr>'."\n";
251
+ echo '<tr>'."\n";
252
+
253
+ echo '<td>'."\n";
254
+ echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_aweber_api_key" id="ws-plugin--s2member-aweber-api-key" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["aweber_api_key"]).'" /><br />'."\n";
255
+ echo 'Once you have an AWeber account, <a href="http://www.s2member.com/r/aweber-api-key" target="_blank" rel="external">click here to get the Authorization Code</a> needed by s2Member.'."\n";
256
+ echo '</td>'."\n";
257
+
258
+ echo '</tr>'."\n";
259
+ echo '</tbody>'."\n";
260
+ echo '</table>'."\n";
261
+
262
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
263
+
264
+ echo '<table class="form-table">'."\n";
265
+ echo '<tbody>'."\n";
266
+
267
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
268
+ {
269
+ echo '<tr>'."\n";
270
+
271
+ echo '<th>'."\n";
272
+ echo '<label for="ws-plugin--s2member-level'.$n.'-aweber-list-ids">'."\n";
273
+ echo 'List ID(s) for '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' (comma-delimited):'."\n";
274
+ echo '</label>'."\n";
275
+ echo '</th>'."\n";
276
+
277
+ echo '</tr>'."\n";
278
+ echo '<tr>'."\n";
279
+
280
+ echo '<td>'."\n";
281
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_aweber_list_ids" id="ws-plugin--s2member-level'.$n.'-aweber-list-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_aweber_list_ids"]).'" /><br />'."\n";
282
+ echo 'New '.(($n === 0) ? 'Free Subscribers' : 'Level #'.$n.' Members').' will be subscribed to these List IDs.<br />'."\n";
283
+ echo 'Ex: <code>mylist, anotherlist</code> — See also: <a href="https://help.aweber.com/entries/21696463-Can-I-Add-Subscribers-to-More-Than-One-List-At-Once-" target="_blank" rel="external">Automation Rules</a>'."\n";
284
+ echo '</td>'."\n";
285
+
286
+ echo '</tr>'."\n";
287
+ }
288
+ echo '</tbody>'."\n";
289
+ echo '</table>'."\n";
290
+
291
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
292
+
293
+ echo '<div class="info" style="margin-bottom:0;">'."\n";
294
+ echo '<p style="font-size:110%; margin-top:0;"><span>We HIGHLY recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during AWeber processing. See: <a href="'.esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")).'">Log Files (Debug)</a>.</span></p>'."\n";
295
+ echo '<p style="font-size:110%; margin-bottom:0;"><span class="ws-menu-page-error">However, it is VERY IMPORTANT to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We STRONGLY suggest that logging be disabled on a live site (for security reasons).</span></p>'."\n";
296
+ echo '</div>'."\n";
297
+
298
+ echo '</div>'."\n";
299
+
300
+ echo '</div>'."\n";
301
+
302
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_aweber", get_defined_vars());
303
+ }
304
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_opt_in", TRUE, get_defined_vars()))
305
+ {
306
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_opt_in", get_defined_vars());
307
+
308
+ echo '<div class="ws-menu-page-group" title="Registration / Double Opt-In Box?">'."\n";
309
+
310
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-opt-in-section">'."\n";
311
+ echo '<h3>Double Opt-In Checkbox Field (optional)</h3>'."\n";
312
+ echo '<p>A Double Opt-In Checkbox will ONLY be displayed, if you\'ve integrated one <em>or more</em> List Servers. See also: <a href="http://www.s2member.com/kb/double-opt-in-checkbox/" target="_blank" rel="external">this KB article</a>.</p>'."\n";
313
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_opt_in", get_defined_vars());
314
+
315
+ echo '<table class="form-table">'."\n";
316
+ echo '<tbody>'."\n";
317
+ echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '').'>'."\n";
318
+
319
+ echo '<th>'."\n";
320
+ echo '<label for="ws-plugin--s2member-custom-reg-opt-in-label">'."\n";
321
+ echo 'Double Opt-In Checkbox Label:'."\n";
322
+ echo '</label>'."\n";
323
+ echo '</th>'."\n";
324
+
325
+ echo '</tr>'."\n";
326
+ echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '').'>'."\n";
327
+
328
+ echo '<td>'."\n";
329
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_custom_reg_opt_in_label" id="ws-plugin--s2member-custom-reg-opt-in-label" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]).'" /><br />'."\n";
330
+ echo 'Example: <code><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/images/'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? 'checked' : 'unchecked').'.png" class="ws-plugin--s2member-custom-reg-opt-in-label-prev-img ws-menu-page-img-16" style="vertical-align:middle;" alt="" /> Your Label will appear next to a Checkbox.</code>'."\n";
331
+ echo '</td>'."\n";
332
+
333
+ echo '</tr>'."\n";
334
+ echo '<tr>'."\n";
335
+
336
+ echo '<th>'."\n";
337
+ echo '<label for="ws-plugin--s2member-custom-reg-opt-in">'."\n";
338
+ echo 'Require Double Opt-In Checkbox?'."\n";
339
+ echo '</label>'."\n";
340
+ echo '</th>'."\n";
341
+
342
+ echo '</tr>'."\n";
343
+ echo '<tr>'."\n";
344
+
345
+ echo '<td>'."\n";
346
+ echo '<select name="ws_plugin__s2member_custom_reg_opt_in" id="ws-plugin--s2member-custom-reg-opt-in">'."\n";
347
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? ' selected="selected"' : '').'>Yes (the Box MUST be checked — checked by default)</option>'."\n";
348
+ echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 2) ? ' selected="selected"' : '').'>Yes (the Box MUST be checked — unchecked by default)</option>'."\n";
349
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' selected="selected"' : '').'>No (disable — do NOT display or require the Checkbox)</option>'."\n";
350
+ echo '</select><br />'."\n";
351
+ echo 'An email confirmation will NOT be sent to the User, unless the Box is checked, or you\'ve disabled the Box; by choosing <code>No</code>.'."\n";
352
+ echo '</td>'."\n";
353
+
354
+ echo '</tr>'."\n";
355
+ echo '</tbody>'."\n";
356
+ echo '</table>'."\n";
357
+ echo '</div>'."\n";
358
+
359
+ echo '</div>'."\n";
360
+
361
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_opt_in", get_defined_vars());
362
+ }
363
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_opt_out", TRUE, get_defined_vars()))
364
+ {
365
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_opt_out", get_defined_vars());
366
+
367
+ echo '<div class="ws-menu-page-group" title="Automate Un-Subscribe/Opt-Outs?">'."\n";
368
+
369
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-opt-out-section">'."\n";
370
+ echo '<h3>Automate Un-Subscribe/Opt-Out Removals (optional)</h3>'."\n";
371
+ echo '<p>s2Member can automatically <em>(and silently)</em> remove Users/Members from the List Servers you\'ve configured above. s2Member is also capable of automating this, based on your own personal configuration preferences. Below, you can choose which Events you consider grounds for List Removal. It is also important to point out that s2Member will ONLY remove Users/Members from the Lists you\'ve configured at the Level the User/Member is or was at during the time of the Event. For example, if a Level #1 Member is deleted, they will ONLY be removed from the List(s) you\'ve configured at Level #1. If an account is upgraded from Level #1 to Level #2, they will ONLY be removed from the List(s) you\'ve configured at Level #1. Of course, all of this is based on the configuration below.</p>'."\n";
372
+ echo '<p><em><strong>*Regarding AWeber Email Parser Integration:*</strong> these will NOT work for AWeber until you <a href="http://www.s2member.com/aweber-notification-email" target="_blank" rel="external">add a Notification Email</a> to your AWeber account matching the "EMail From Address" configured in <code>s2Member -› General Options -› EMail Configuration</code>. Which is currently set to: <code>'.esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]).'</code>. This is a required step if you want s2Member to be authenticated when it emails List Removal requests to AWeber. Please note, this only applies to AWeber integration via "email". If you choose to integrate via the AWeber API instead (recommended) this is not necessary/applicable.</em></p>'."\n";
373
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_opt_out", get_defined_vars());
374
+
375
+ echo '<table class="form-table">'."\n";
376
+ echo '<tbody>'."\n";
377
+ echo '<tr>'."\n";
378
+
379
+ echo '<th>'."\n";
380
+ echo '<label for="ws-plugin--s2member-custom-reg-auto-opt-outs">'."\n";
381
+ echo 'Process List Removals Automatically? (choose events)'."\n";
382
+ echo '</label>'."\n";
383
+ echo '</th>'."\n";
384
+
385
+ echo '</tr>'."\n";
386
+ echo '<tr>'."\n";
387
+
388
+ echo '<td>'."\n";
389
+ echo '<div class="ws-menu-page-scrollbox" style="height:150px;">'."\n";
390
+ echo '<input type="hidden" name="ws_plugin__s2member_custom_reg_auto_opt_outs[]" value="update-signal" />'."\n";
391
+ foreach(array("removal-deletion" => "<strong>Anytime a User is deleted (including manual deletions)</strong>", "ipn-refund-reversal-deletion" => "&#9492;&#9472; Anytime s2Member deletes an account because of a Refund/Reversal.", "(ipn|auto-eot)-cancellation-expiration-deletion" => "&#9492;&#9472; Anytime s2Member deletes an account because of a Cancellation/Expiration.", "modification" => "<strong>Anytime a User's Role changes (including manual changes)</strong>", "ipn-refund-reversal-demotion" => "&#9492;&#9472; Anytime s2Member demotes an account because of a Refund/Reversal.", "(ipn|auto-eot)-cancellation-expiration-demotion" => "&#9492;&#9472; Anytime s2Member demotes an account because of a Cancellation/Expiration.", "(rtn|ipn)-upgrade-downgrade" => "&#9492;&#9472; Anytime s2Member changes a User's Role after a paid Subscr. Modification.") as $ws_plugin__s2member_temp_s_value => $ws_plugin__s2member_temp_s_label)
392
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_auto_opt_outs[]" id="ws-plugin--s2member-custom-reg-auto-opt-outs-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'" value="'.esc_attr($ws_plugin__s2member_temp_s_value).'"'.((in_array($ws_plugin__s2member_temp_s_value, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"])) ? ' checked="checked"' : '').' /> <label for="ws-plugin--s2member-custom-reg-auto-opt-outs-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'">'.$ws_plugin__s2member_temp_s_label.'</label><br />'."\n";
393
+ echo '</div>'."\n";
394
+ echo '</td>'."\n";
395
+
396
+ echo '</tr>'."\n";
397
+ echo '<tr>'."\n";
398
+
399
+ echo '<th>'."\n";
400
+ echo '<label for="ws-plugin--s2member-custom-reg-auto-opt-out-transitions">'."\n";
401
+ echo 'Also Process List Transitions Automatically?'."\n";
402
+ echo '</label>'."\n";
403
+ echo '</th>'."\n";
404
+
405
+ echo '</tr>'."\n";
406
+ echo '<tr>'."\n";
407
+
408
+ echo '<td>'."\n";
409
+ echo '<select name="ws_plugin__s2member_custom_reg_auto_opt_out_transitions" id="ws-plugin--s2member-custom-reg-auto-opt-out-transitions">'."\n";
410
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"]) ? ' selected="selected"' : '').'>No (do NOT transition mailing list subscribers automatically)</option>'."\n";
411
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "1") ? ' selected="selected"' : '').'>Yes (automatically transition, if able to remove from a previous list)</option>'."\n";
412
+ echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"] === "2") ? ' selected="selected"' : '').'>Yes (always automatically transition, even if NOT removed from a previous list)</option>'."\n";
413
+ echo '</select><br />'."\n";
414
+ echo '<em><strong>*Transitions*</strong> When/if s2Member automatically removes a Member from Lists at their current Level# (based on your configuration in the previous section), this setting tells s2Member that it should <strong>also</strong> transition the Member to any Lists you\'ve configured at the new Access Level# (i.e. Role) they are being changed to. For example, if a Member is demoted from Level #1 to Level #0, do you want s2Member to add them to the Level #0 List(s) after it removes them from the Level #1 List(s)?</em><br /><br />'."\n";
415
+ echo '<em><strong>*If removed from a previous list, or NOT?*</strong> You can choose your preference above. When/if s2Member automatically transitions a mailing list subscriber, it will first try to remove the subscriber from a previous mailing list. If s2Member is able to remove the subscriber from a previous list before the transition takes place, s2Member will then make an attempt (based on your configuration) to transition the subscriber to a new/different list silently (i.e. without a new confirmation email being sent out). If s2Member is NOT able to remove a subscriber from a previous list, it can (if configured to do so) still transition a subscriber to a new list, by sending the subscriber a new email confirmation letter (i.e. this is NOT silent, because you absolutely NEED the subscriber\'s permission in this case).</em><br /><br />'."\n";
416
+ echo '<em><strong>*Seamless with MailChimp*</strong> If enabled, Automatic List Transitions work seamlessly with MailChimp. Automatic List Transitions also work with GetResponse/AWeber, but GetResponse/AWeber may send the User/Member a new confirmation email, asking them to confirm changes to their mailing list subscription with you. Work is underway to improve this aspect of s2Member\'s integration with GetResponse/AWeber in a future release. Ideally, a Customer would be transitioned silently behind the scene with GetResponse/AWeber too, when appropriate.</em>'."\n";
417
+ echo '</td>'."\n";
418
+
419
+ echo '</tr>'."\n";
420
+ echo '</tbody>'."\n";
421
+ echo '</table>'."\n";
422
+ echo '</div>'."\n";
423
+
424
+ echo '</div>'."\n";
425
+
426
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_opt_out", get_defined_vars());
427
+ }
428
+ if(apply_filters("ws_plugin__s2member_during_els_ops_page_during_left_sections_display_other_methods", TRUE, get_defined_vars()))
429
+ {
430
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_before_other_methods", get_defined_vars());
431
 
432
+ echo '<div class="ws-menu-page-group" title="Other List Server Integration Methods">'."\n";
 
 
 
 
433
 
434
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-other-methods-section">'."\n";
435
+ echo '<h3>Other List Server Integrations (there\'s always a way)</h3>'."\n";
436
+ echo '<p>Check the s2Member API Notifications panel. You\'ll find additional layers of automation available through the use of the `Signup`, `Registration`, `Payment`, `EOT/Deletion`, `Refund/Reversal`, and `Specific Post/Page` Notifications that are available to you through the s2Member API. These make it possible to integrate with 3rd party applications; like list servers, affiliate programs, and other back-office routines; in more advanced ways. You will probably need to get help from a web developer though. s2Member API Notifications require some light PHP scripting by someone familiar with web service connections.</p>'."\n";
437
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_during_other_methods", get_defined_vars());
438
+ echo '</div>'."\n";
439
 
440
+ echo '</div>'."\n";
 
441
 
442
+ do_action("ws_plugin__s2member_during_els_ops_page_during_left_sections_after_other_methods", get_defined_vars());
443
+ }
444
+ do_action("ws_plugin__s2member_during_els_ops_page_after_left_sections", get_defined_vars());
445
 
446
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
447
 
448
+ echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>'."\n";
449
 
450
+ echo '</form>'."\n";
451
 
452
+ echo '</td>'."\n";
453
 
454
+ echo '<td class="ws-menu-page-table-r">'."\n";
455
+ c_ws_plugin__s2member_menu_pages_rs::display();
456
+ echo '</td>'."\n";
457
 
458
+ echo '</tr>'."\n";
459
+ echo '</tbody>'."\n";
460
+ echo '</table>'."\n";
461
 
462
+ echo '</div>'."\n";
463
+ }
 
464
  }
465
+ }
466
+ new c_ws_plugin__s2member_menu_page_els_ops();
 
includes/menu-pages/gen-ops.inc.php CHANGED
@@ -166,7 +166,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_gen_ops"))
166
 
167
  echo '<div class="ws-menu-page-section ws-plugin--s2member-lazy-load-section">'."\n";
168
  echo '<h3>CSS/JS Lazy Loading (Client-Side Libraries)</h3>'."\n";
169
- echo '<p>By default, s2Member will load it\'s CSS/JS libraries on every page of your site. However, you may wish to enable lazy-loading here (e.g. only load when absolutely necessary).</p>'."\n";
170
  echo '<p><em><strong>Tip:</strong> Do you need s2Member\'s CSS/JS on every page? If not, you can turn lazy-loading on. If you need s2Member\'s CSS/JS on a given Post/Page, you can insert an HTML comment into the Post/Page content like this: <code>&lt;!--s2member--&gt;</code>. If a Post/Page contains the word <code>s2member</code> or an <code>[s2*</code> Shortcode, this will automatically trigger s2Member\'s lazy-load routine (no matter what you configure here). Thus, it\'s an easy way to force s2Member to load it\'s CSS/JS on specific Posts/Pages where you deem this necessary. There is also a WordPress filter available: <code>add_filter("ws_plugin__s2member_lazy_load_css_js", "__return_true");</code> for developers; this could be incorporated into more dynamic scenarios.</em></p>'."\n";
171
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_lazy_load", get_defined_vars());
172
 
@@ -185,8 +185,8 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_gen_ops"))
185
 
186
  echo '<td>'."\n";
187
  echo '<select name="ws_plugin__s2member_lazy_load_css_js" id="ws-plugin--s2member-lazy-load-css-js">'."\n";
188
- echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["lazy_load_css_js"]) ? ' selected="selected"' : '').'>No (always load the CSS/JS libraries; e.g. on every page of the site)</option>'."\n";
189
- echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["lazy_load_css_js"]) ? ' selected="selected"' : '').'>Yes (lazy-load CSS/JS libraries; e.g. load only when absolutely necessary)</option>'."\n";
190
  echo '</select>'."\n";
191
  echo '</td>'."\n";
192
 
@@ -1081,7 +1081,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_gen_ops"))
1081
  echo '<p>Custom Fields will appear in your Standard Registration Form, and in User/Member Profiles:<br />(<a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::wp_register_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Standard Registration Form.\\n* s2Member makes this form available to logged-in Administrators, at all times (for testing purposes), regardless of configuration.'.((c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '').'\');">'.esc_html(c_ws_plugin__s2member_utils_urls::wp_register_url()).'</a>)</p>'."\n";
1082
  echo (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site()) ? '<p><em>The Main Site of a Multisite Blog Farm uses this Form. s2Member supports Custom Fields here too.<br />(<a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::wp_signup_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Multisite Registration Form.\\n* s2Member makes this form available to logged-in Super Administrators, at all times (for testing purposes), regardless of configuration.'.((c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '').'\');">'.esc_html(c_ws_plugin__s2member_utils_urls::wp_signup_url()).'</a>)</em></p>'."\n" : '';
1083
  echo (c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '<p><em><strong>BuddyPress:</strong> BuddyPress will use its own Registration Form <a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::bp_register_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your BuddyPress Registration Form.\\n* However, you will probably be redirected away from this BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.\');">here</a>.<br />s2Member can integrate your Custom Fields with BuddyPress too, please see options below.</em></p>'."\n" : '';
1084
- echo '<p><strong>Regarding registration...</strong> Custom Fields do NOT appear during repeat registration and/or checkout attempts (e.g. they do NOT appear for any user that is currently logged into the site). Please make sure that you test registration and/or checkout forms while NOT logged in (e.g. please test as a first-time customer). Existing users/members/customers may update Custom Fields by editing their Profile.</p>'."\n";
1085
 
1086
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_custom_reg_fields", get_defined_vars());
1087
 
@@ -1231,7 +1231,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_gen_ops"))
1231
  echo '<h3>Login Welcome Page (required, please customize this)</h3>'."\n";
1232
  echo '<p>Please create and/or choose an existing Page to use as the first page Members will see after logging in.</p>'."\n";
1233
  echo (c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '<p><em><strong>BuddyPress:</strong> s2Member integrates with BuddyPress. Your Login Welcome Page affects BuddyPress too.</em></p>'."\n" : '';
1234
- echo '<p><em><strong>*Tips*</strong> This special Page will be protected from public access (automatically) by s2Member. Also, please remember this option CANNOT be set to your Front Page (e.g. your Home Page), or to your Posts Page (e.g. your main Blog page). Please create a separate Page in WordPress &amp; designate it here as your Login Welcome Page.</em></p>'."\n";
1235
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/customizing-your-lwp/" target="_blank" rel="external">Customizing Your Login Welcome Page</a>.</p>'."\n";
1236
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_login_welcome_page", get_defined_vars());
1237
 
@@ -1295,8 +1295,8 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_gen_ops"))
1295
 
1296
  echo '<td>'."\n";
1297
  echo '<select name="ws_plugin__s2member_login_redirection_always_http" id="ws-plugin--s2member-login-redirection-always-http">'."\n";
1298
- echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) ? ' selected="selected"' : '').'>No, do NOT modify (use WordPress default behavior; e.g. detect URL scheme automatically)</option>'."\n";
1299
- echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) ? ' selected="selected"' : '').'>Yes, always redirect non-administrative users to non-SSL version (e.g. always use http://)</option>'."\n";
1300
  echo '</select><br />'."\n";
1301
  echo 'Recommended setting: <code>Yes</code>. This is compatible w/ <a href="http://codex.wordpress.org/Administration_Over_SSL" target="_blank" rel="external"><code>FORCE_SSL_LOGIN</code></a> and/or <a href="http://codex.wordpress.org/Administration_Over_SSL" target="_blank" rel="external"><code>FORCE_SSL_ADMIN</code></a>.'."\n";
1302
  echo '</td>'."\n";
166
 
167
  echo '<div class="ws-menu-page-section ws-plugin--s2member-lazy-load-section">'."\n";
168
  echo '<h3>CSS/JS Lazy Loading (Client-Side Libraries)</h3>'."\n";
169
+ echo '<p>By default, s2Member will load it\'s CSS/JS libraries on every page of your site. However, you may wish to enable lazy-loading here (i.e. only load when absolutely necessary).</p>'."\n";
170
  echo '<p><em><strong>Tip:</strong> Do you need s2Member\'s CSS/JS on every page? If not, you can turn lazy-loading on. If you need s2Member\'s CSS/JS on a given Post/Page, you can insert an HTML comment into the Post/Page content like this: <code>&lt;!--s2member--&gt;</code>. If a Post/Page contains the word <code>s2member</code> or an <code>[s2*</code> Shortcode, this will automatically trigger s2Member\'s lazy-load routine (no matter what you configure here). Thus, it\'s an easy way to force s2Member to load it\'s CSS/JS on specific Posts/Pages where you deem this necessary. There is also a WordPress filter available: <code>add_filter("ws_plugin__s2member_lazy_load_css_js", "__return_true");</code> for developers; this could be incorporated into more dynamic scenarios.</em></p>'."\n";
171
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_lazy_load", get_defined_vars());
172
 
185
 
186
  echo '<td>'."\n";
187
  echo '<select name="ws_plugin__s2member_lazy_load_css_js" id="ws-plugin--s2member-lazy-load-css-js">'."\n";
188
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["lazy_load_css_js"]) ? ' selected="selected"' : '').'>No (always load the CSS/JS libraries; i.e. on every page of the site)</option>'."\n";
189
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["lazy_load_css_js"]) ? ' selected="selected"' : '').'>Yes (lazy-load CSS/JS libraries; i.e. load only when absolutely necessary)</option>'."\n";
190
  echo '</select>'."\n";
191
  echo '</td>'."\n";
192
 
1081
  echo '<p>Custom Fields will appear in your Standard Registration Form, and in User/Member Profiles:<br />(<a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::wp_register_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Standard Registration Form.\\n* s2Member makes this form available to logged-in Administrators, at all times (for testing purposes), regardless of configuration.'.((c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '').'\');">'.esc_html(c_ws_plugin__s2member_utils_urls::wp_register_url()).'</a>)</p>'."\n";
1082
  echo (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site()) ? '<p><em>The Main Site of a Multisite Blog Farm uses this Form. s2Member supports Custom Fields here too.<br />(<a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::wp_signup_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Multisite Registration Form.\\n* s2Member makes this form available to logged-in Super Administrators, at all times (for testing purposes), regardless of configuration.'.((c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '').'\');">'.esc_html(c_ws_plugin__s2member_utils_urls::wp_signup_url()).'</a>)</em></p>'."\n" : '';
1083
  echo (c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '<p><em><strong>BuddyPress:</strong> BuddyPress will use its own Registration Form <a href="'.esc_attr(c_ws_plugin__s2member_utils_urls::bp_register_url()).'" target="_blank" rel="external" onclick="alert(\'s2Member will now open your BuddyPress Registration Form.\\n* However, you will probably be redirected away from this BuddyPress Registration Form ( '.c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()).' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.\');">here</a>.<br />s2Member can integrate your Custom Fields with BuddyPress too, please see options below.</em></p>'."\n" : '';
1084
+ echo '<p><strong>Regarding registration...</strong> Custom Fields do NOT appear during repeat registration and/or checkout attempts (i.e. they do NOT appear for any user that is currently logged into the site). Please make sure that you test registration and/or checkout forms while NOT logged in (i.e. please test as a first-time customer). Existing users/members/customers may update Custom Fields by editing their Profile.</p>'."\n";
1085
 
1086
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_custom_reg_fields", get_defined_vars());
1087
 
1231
  echo '<h3>Login Welcome Page (required, please customize this)</h3>'."\n";
1232
  echo '<p>Please create and/or choose an existing Page to use as the first page Members will see after logging in.</p>'."\n";
1233
  echo (c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? '<p><em><strong>BuddyPress:</strong> s2Member integrates with BuddyPress. Your Login Welcome Page affects BuddyPress too.</em></p>'."\n" : '';
1234
+ echo '<p><em><strong>*Tips*</strong> This special Page will be protected from public access (automatically) by s2Member. Also, please remember this option CANNOT be set to your Front Page (i.e. your Home Page), or to your Posts Page (i.e. your main Blog page). Please create a separate Page in WordPress &amp; designate it here as your Login Welcome Page.</em></p>'."\n";
1235
  echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/customizing-your-lwp/" target="_blank" rel="external">Customizing Your Login Welcome Page</a>.</p>'."\n";
1236
  do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_login_welcome_page", get_defined_vars());
1237
 
1295
 
1296
  echo '<td>'."\n";
1297
  echo '<select name="ws_plugin__s2member_login_redirection_always_http" id="ws-plugin--s2member-login-redirection-always-http">'."\n";
1298
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) ? ' selected="selected"' : '').'>No, do NOT modify (use WordPress default behavior; i.e. detect URL scheme automatically)</option>'."\n";
1299
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) ? ' selected="selected"' : '').'>Yes, always redirect non-administrative users to non-SSL version (i.e. always use http://)</option>'."\n";
1300
  echo '</select><br />'."\n";
1301
  echo 'Recommended setting: <code>Yes</code>. This is compatible w/ <a href="http://codex.wordpress.org/Administration_Over_SSL" target="_blank" rel="external"><code>FORCE_SSL_LOGIN</code></a> and/or <a href="http://codex.wordpress.org/Administration_Over_SSL" target="_blank" rel="external"><code>FORCE_SSL_ADMIN</code></a>.'."\n";
1302
  echo '</td>'."\n";
includes/menu-pages/logs.inc.php CHANGED
@@ -167,7 +167,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_logs"))
167
 
168
  echo '<div class="ws-menu-page-hr"></div>'."\n";
169
 
170
- echo '<form method="post" onsubmit="if(!confirm(\'Archive all existing log files?\n\nAll of your current log files will be archived (e.g. they will simply be renamed with an ARCHIVED tag &amp; date in their file name); and new log files will be created automatically the next time s2Member logs something on your installation.\n\nPlease click OK to confirm this action.\')) return false;">'."\n";
171
  echo '<input type="hidden" name="ws_plugin__s2member_logs_archive_start_fresh" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-logs-archive-start-fresh")).'" />'."\n";
172
  echo '<input type="submit" value="Archive All Current Log Files" class="ws-menu-page-right ws-plugin--s2member-archive-logs-start-fresh-button" style="font-size:110%; font-weight:normal; clear:right; min-width:200px;" />'."\n";
173
  echo '</form>'."\n";
167
 
168
  echo '<div class="ws-menu-page-hr"></div>'."\n";
169
 
170
+ echo '<form method="post" onsubmit="if(!confirm(\'Archive all existing log files?\n\nAll of your current log files will be archived (i.e. they will simply be renamed with an ARCHIVED tag &amp; date in their file name); and new log files will be created automatically the next time s2Member logs something on your installation.\n\nPlease click OK to confirm this action.\')) return false;">'."\n";
171
  echo '<input type="hidden" name="ws_plugin__s2member_logs_archive_start_fresh" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-logs-archive-start-fresh")).'" />'."\n";
172
  echo '<input type="submit" value="Archive All Current Log Files" class="ws-menu-page-right ws-plugin--s2member-archive-logs-start-fresh-button" style="font-size:110%; font-weight:normal; clear:right; min-width:200px;" />'."\n";
173
  echo '</form>'."\n";
includes/menu-pages/mms-ops.inc.php CHANGED
@@ -143,7 +143,7 @@ if(!class_exists("c_ws_plugin__s2member_menu_page_mms_ops"))
143
  echo '<div id="ws-plugin--s2member-mms-registration-support-package-details" style="display:none;">'."\n";
144
  echo '<p>The most important thing to do when setting up a Blog Farm with s2Member, is to add this line to your <code>/wp-config.php</code> file: <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>. This will add a default layer of security, to all Blogs within your Network, with respect to s2Member. <strong>But, before you go live</strong>, please contact <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">s2Member.com</a> for full documentation. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. You will be asked to purchase our <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">Network Support Package</a> when you need assistance in this regard.</p>'."\n";
145
  echo '<p>Multisite Blog Farms require a site owner that fully understands the potential security risks associated with Blog Farming. s2Member\'s <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">Network Support Package</a> provides you with the information you need, and priority support for anything about s2Member that you don\'t understand. In addition, our Network Support Package includes a lengthy PDF file that details a list of things affected by <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>, best practices, and other supplemental documentation focused on Blog Farms.</p>'."\n";
146
- echo '<p><em><strong>Definition of a Multisite Blog Farm:</strong> If your Network is making it possible for "Members" of your Main Site, to create and/or manage Blogs (in any way), s2Member will consider your installation to be a Multisite Blog Farm. That being said, some site owners run a Multisite Network for the purpose of maintaining their own sites. The term Multisite Blog Farm does NOT apply to a Network that hosts multiple Child Blogs, all of which are operated by a single site owner and/or a single company. Again, a Multisite Blog Farm (in the eyes of s2Member), is any Network that is making it possible for "Members" of its Main Site, to create and/or manage Blogs; where one or more of these Child Blogs is being administered by a Customer (e.g. if you offer both Membership and Blog creation, as configured below).</em></p>'."\n";
147
  echo '<p><em><strong>When NOT to run a Multisite Blog Farm:</strong> If you run a Multisite Network for the purpose of maintaining your own sites. You should NOT run a Multisite Blog Farm. You can still activate s2Member Network-wide, if you like (optional), but the advanced security considerations offered through s2Member\'s Multisite Blog Farm functionality are NOT needed in this case; because all of the Child Blogs in your Network belong to trusted Administrators (i.e. your Customers are NOT going to run Child Blogs on your Network in this case).</em></p>'."\n";
148
  echo '</div>'."\n";
149
  echo '</div>'."\n";
143
  echo '<div id="ws-plugin--s2member-mms-registration-support-package-details" style="display:none;">'."\n";
144
  echo '<p>The most important thing to do when setting up a Blog Farm with s2Member, is to add this line to your <code>/wp-config.php</code> file: <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>. This will add a default layer of security, to all Blogs within your Network, with respect to s2Member. <strong>But, before you go live</strong>, please contact <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">s2Member.com</a> for full documentation. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. You will be asked to purchase our <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">Network Support Package</a> when you need assistance in this regard.</p>'."\n";
145
  echo '<p>Multisite Blog Farms require a site owner that fully understands the potential security risks associated with Blog Farming. s2Member\'s <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")).'" target="_blank" rel="external">Network Support Package</a> provides you with the information you need, and priority support for anything about s2Member that you don\'t understand. In addition, our Network Support Package includes a lengthy PDF file that details a list of things affected by <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>, best practices, and other supplemental documentation focused on Blog Farms.</p>'."\n";
146
+ echo '<p><em><strong>Definition of a Multisite Blog Farm:</strong> If your Network is making it possible for "Members" of your Main Site, to create and/or manage Blogs (in any way), s2Member will consider your installation to be a Multisite Blog Farm. That being said, some site owners run a Multisite Network for the purpose of maintaining their own sites. The term Multisite Blog Farm does NOT apply to a Network that hosts multiple Child Blogs, all of which are operated by a single site owner and/or a single company. Again, a Multisite Blog Farm (in the eyes of s2Member), is any Network that is making it possible for "Members" of its Main Site, to create and/or manage Blogs; where one or more of these Child Blogs is being administered by a Customer (i.e. if you offer both Membership and Blog creation, as configured below).</em></p>'."\n";
147
  echo '<p><em><strong>When NOT to run a Multisite Blog Farm:</strong> If you run a Multisite Network for the purpose of maintaining your own sites. You should NOT run a Multisite Blog Farm. You can still activate s2Member Network-wide, if you like (optional), but the advanced security considerations offered through s2Member\'s Multisite Blog Farm functionality are NOT needed in this case; because all of the Child Blogs in your Network belong to trusted Administrators (i.e. your Customers are NOT going to run Child Blogs on your Network in this case).</em></p>'."\n";
148
  echo '</div>'."\n";
149
  echo '</div>'."\n";
includes/menu-pages/paypal-buttons.inc.php CHANGED
@@ -473,7 +473,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_paypal_buttons"))
473
  foreach ($ws_plugin__s2member_temp_a_singulars as $ws_plugin__s2member_temp_o)
474
  echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '">' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
475
 
476
- echo '</optgroup></select> <a href="#" onclick="alert(\'Hold down your `Ctrl` key to select multiples.\\n\\nOptional. If you include Additional Posts/Pages, Customers will still land on your Leading Post/Page; BUT, they\\\'ll ALSO have access to some Additional Posts/Pages that you\\\'ve protected. This gives you the ability to create Post/Page Packages.\\n\\nIn other words, a Customer is sold a Specific Post/Page (they\\\'ll land on your Leading Post/Page after checkout), which might contain links to some other Posts/Pages that you\\\'ve packaged together under one transaction.\\n\\nBundling Additional Posts/Pages into one Package, authenticates the Customer for access to the Additional Posts/Pages automatically (e.g. only one Access Link is needed, and s2Member generates this automatically). However, you will STILL need to design your Leading Post/Page (which is what a Customer will actually land on), with links pointing to the other Posts/Pages. This way your Customers will have clickable links to everything they\\\'ve paid for.\\n\\n*Quick Summary* s2Member sends Customers to your Leading Post/Page, and also authenticates them for access to any Additional Posts/Pages automatically. You handle it from there.\\n\\n*Tip* If there are no Posts/Pages in this menu, it\\\'s because you\\\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.\'); return false;" tabindex="-1">[?]</a></p>' . "\n";
477
 
478
  echo '<p>I want to charge: $<input type="text" autocomplete="off" id="ws-plugin--s2member-sp-amount" value="0.01" size="4" /> / <select id="ws-plugin--s2member-sp-hours">' . trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (__FILE__)) . "/templates/options/paypal-sp-hours.php"))) . '</select></p>' . "\n";
479
  echo '<p>Description: <input type="text" autocomplete="off" id="ws-plugin--s2member-sp-desc" value="Description and pricing details here." size="68" /></p>' . "\n";
@@ -557,7 +557,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_paypal_buttons"))
557
  foreach ($ws_plugin__s2member_temp_a_singulars as $ws_plugin__s2member_temp_o)
558
  echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '">' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
559
 
560
- echo '</optgroup></select> <a href="#" onclick="alert(\'Hold down your `Ctrl` key to select multiples.\\n\\nOptional. If you include Additional Posts/Pages, Customers will still land on your Leading Post/Page; BUT, they\\\'ll ALSO have access to some Additional Posts/Pages that you\\\'ve protected. This gives you the ability to create Post/Page Packages.\\n\\nIn other words, a Customer is sold a Specific Post/Page (they\\\'ll land on your Leading Post/Page after checkout), which might contain links to some other Posts/Pages that you\\\'ve packaged together under one transaction.\\n\\nBundling Additional Posts/Pages into one Package, authenticates the Customer for access to the Additional Posts/Pages automatically (e.g. only one Access Link is needed, and s2Member generates this automatically). However, you will STILL need to design your Leading Post/Page (which is what a Customer will actually land on), with links pointing to the other Posts/Pages. This way your Customers will have clickable links to everything they\\\'ve paid for.\\n\\n*Quick Summary* s2Member sends Customers to your Leading Post/Page, and also authenticates them for access to any Additional Posts/Pages automatically. You handle it from there.\\n\\n*Tip* If there are no Posts/Pages in this menu, it\\\'s because you\\\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.\'); return false;" tabindex="-1">[?]</a></p>' . "\n";
561
 
562
  echo '<p><select id="ws-plugin--s2member-sp-link-hours">' . trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (__FILE__)) . "/templates/options/paypal-sp-hours.php"))) . '</select> <input type="button" value="Generate Access Link" onclick="ws_plugin__s2member_paypalSpLinkGenerate();" /> <img id="ws-plugin--s2member-sp-link-loading" src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/ajax-loader.gif" alt="" style="display:none;" /></p>' . "\n";
563
  echo '<p id="ws-plugin--s2member-sp-link" style="display:none;"></p>' . "\n";
473
  foreach ($ws_plugin__s2member_temp_a_singulars as $ws_plugin__s2member_temp_o)
474
  echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '">' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
475
 
476
+ echo '</optgroup></select> <a href="#" onclick="alert(\'Hold down your `Ctrl` key to select multiples.\\n\\nOptional. If you include Additional Posts/Pages, Customers will still land on your Leading Post/Page; BUT, they\\\'ll ALSO have access to some Additional Posts/Pages that you\\\'ve protected. This gives you the ability to create Post/Page Packages.\\n\\nIn other words, a Customer is sold a Specific Post/Page (they\\\'ll land on your Leading Post/Page after checkout), which might contain links to some other Posts/Pages that you\\\'ve packaged together under one transaction.\\n\\nBundling Additional Posts/Pages into one Package, authenticates the Customer for access to the Additional Posts/Pages automatically (i.e. only one Access Link is needed, and s2Member generates this automatically). However, you will STILL need to design your Leading Post/Page (which is what a Customer will actually land on), with links pointing to the other Posts/Pages. This way your Customers will have clickable links to everything they\\\'ve paid for.\\n\\n*Quick Summary* s2Member sends Customers to your Leading Post/Page, and also authenticates them for access to any Additional Posts/Pages automatically. You handle it from there.\\n\\n*Tip* If there are no Posts/Pages in this menu, it\\\'s because you\\\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.\'); return false;" tabindex="-1">[?]</a></p>' . "\n";
477
 
478
  echo '<p>I want to charge: $<input type="text" autocomplete="off" id="ws-plugin--s2member-sp-amount" value="0.01" size="4" /> / <select id="ws-plugin--s2member-sp-hours">' . trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (__FILE__)) . "/templates/options/paypal-sp-hours.php"))) . '</select></p>' . "\n";
479
  echo '<p>Description: <input type="text" autocomplete="off" id="ws-plugin--s2member-sp-desc" value="Description and pricing details here." size="68" /></p>' . "\n";
557
  foreach ($ws_plugin__s2member_temp_a_singulars as $ws_plugin__s2member_temp_o)
558
  echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '">' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
559
 
560
+ echo '</optgroup></select> <a href="#" onclick="alert(\'Hold down your `Ctrl` key to select multiples.\\n\\nOptional. If you include Additional Posts/Pages, Customers will still land on your Leading Post/Page; BUT, they\\\'ll ALSO have access to some Additional Posts/Pages that you\\\'ve protected. This gives you the ability to create Post/Page Packages.\\n\\nIn other words, a Customer is sold a Specific Post/Page (they\\\'ll land on your Leading Post/Page after checkout), which might contain links to some other Posts/Pages that you\\\'ve packaged together under one transaction.\\n\\nBundling Additional Posts/Pages into one Package, authenticates the Customer for access to the Additional Posts/Pages automatically (i.e. only one Access Link is needed, and s2Member generates this automatically). However, you will STILL need to design your Leading Post/Page (which is what a Customer will actually land on), with links pointing to the other Posts/Pages. This way your Customers will have clickable links to everything they\\\'ve paid for.\\n\\n*Quick Summary* s2Member sends Customers to your Leading Post/Page, and also authenticates them for access to any Additional Posts/Pages automatically. You handle it from there.\\n\\n*Tip* If there are no Posts/Pages in this menu, it\\\'s because you\\\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.\'); return false;" tabindex="-1">[?]</a></p>' . "\n";
561
 
562
  echo '<p><select id="ws-plugin--s2member-sp-link-hours">' . trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (__FILE__)) . "/templates/options/paypal-sp-hours.php"))) . '</select> <input type="button" value="Generate Access Link" onclick="ws_plugin__s2member_paypalSpLinkGenerate();" /> <img id="ws-plugin--s2member-sp-link-loading" src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/ajax-loader.gif" alt="" style="display:none;" /></p>' . "\n";
563
  echo '<p id="ws-plugin--s2member-sp-link" style="display:none;"></p>' . "\n";
includes/menu-pages/res-ops.inc.php CHANGED
@@ -1,661 +1,670 @@
1
  <?php
2
  /**
3
- * Menu page for the s2Member plugin (Restriction Options page).
4
- *
5
- * Copyright: © 2009-2011
6
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
- * (coded in the USA)
8
- *
9
- * Released under the terms of the GNU General Public License.
10
- * You should have received a copy of the GNU General Public License,
11
- * along with this software. In the main directory, see: /licensing/
12
- * If not, see: {@link http://www.gnu.org/licenses/}.
13
- *
14
- * @package s2Member\Menu_Pages
15
- * @since 3.0
16
- */
17
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
 
20
- if (!class_exists ("c_ws_plugin__s2member_menu_page_res_ops"))
 
 
 
 
 
 
 
 
21
  {
22
- /**
23
- * Menu page for the s2Member plugin (Restriction Options page).
24
- *
25
- * @package s2Member\Menu_Pages
26
- * @since 110531
27
- */
28
- class c_ws_plugin__s2member_menu_page_res_ops
29
- {
30
- public function __construct ()
31
- {
32
- echo '<div class="wrap ws-menu-page">' . "\n";
33
-
34
- echo '<div class="ws-menu-page-toolbox">'."\n";
35
- c_ws_plugin__s2member_menu_pages_tb::display ();
36
- echo '</div>'."\n";
37
-
38
- echo '<h2>Restriction Options</h2>' . "\n";
39
-
40
- echo '<table class="ws-menu-page-table">' . "\n";
41
- echo '<tbody class="ws-menu-page-table-tbody">' . "\n";
42
- echo '<tr class="ws-menu-page-table-tr">' . "\n";
43
- echo '<td class="ws-menu-page-table-l">' . "\n";
44
-
45
- echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">' . "\n";
46
- echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-options-save")) . '" />' . "\n";
47
- echo '<input type="hidden" name="ws_plugin__s2member_configured" id="ws-plugin--s2member-configured" value="1" />' . "\n";
48
-
49
- do_action("ws_plugin__s2member_during_res_ops_page_before_left_sections", get_defined_vars ());
50
-
51
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_post_level_access", true, get_defined_vars ()))
52
- {
53
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_post_level_access", get_defined_vars ());
54
-
55
- echo '<div class="ws-menu-page-group" title="Post Access Restrictions">' . "\n";
56
-
57
- echo '<div class="ws-menu-page-section ws-plugin--s2member-post-level-access-section">' . "\n";
58
- echo '<h3>Post Level Access Restrictions (optional)</h3>' . "\n";
59
- echo '<p>Here you can specify Posts that are restricted to certain Membership Access Levels. s2Member also supports Custom <a href="http://codex.wordpress.org/Post_Types" target="_blank" rel="external">Post Types</a> here. If you have a theme or plugin installed, which has enabled Custom Post Types <em>(i.e. Music/Videos or something else)</em>, you can put the IDs for those Posts here.</p>' . "\n";
60
- echo '<p><em><strong>*Note*</strong> Protecting individual Posts, ONLY protects the Permalinks for those Posts. It is still possible for excerpts of protected content to be seen in search results generated by WordPress, feeds, and Archive views; such as your Home Page, inside a Category listing, or through other queries formulated by your theme. This is the intended functionality. Excerpts are a great way to "tease" public visitors. In other words, public visitors may have access to excerpts introduced by your theme, but any attempt to view the full Post (i.e. the Permalink) will result in an automatic redirect to your Membership Options Page; requiring registration.</em></p>' . "\n";
61
- echo '<p><em><strong>*Note*</strong> If you would like to protect many Posts at once (including Archive views), you can use Category Level Restrictions, Tag Level Restrictions, or have a look down below at s2Member\'s options for "Alternative View Protection", which deals with search results, as well as feeds.</em></p>' . "\n";
62
- echo ((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
63
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_post_level_access", get_defined_vars ());
64
-
65
- echo '<table class="form-table">' . "\n";
66
- echo '<tbody>' . "\n";
67
 
68
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
69
- {
70
- echo '<tr>' . "\n";
71
 
72
- echo '<th>' . "\n";
73
- echo '<label for="ws-plugin--s2member-level' . $n . '-posts">' . "\n";
74
- echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Posts That Require Highest Level #' . $n . ':' . "\n" : 'Posts That Require Level #' . $n . ' Or Higher:' . "\n";
75
- echo '</label>' . "\n";
76
- echo '</th>' . "\n";
77
 
78
- echo '</tr>' . "\n";
79
- echo '<tr>' . "\n";
 
 
80
 
81
- echo '<td>' . "\n";
82
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_posts" id="ws-plugin--s2member-level' . $n . '-posts" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]) . '" /><br />' . "\n";
83
- echo 'Post IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.<br />' . "\n";
84
- echo 'You can also include all Post IDs of a specific <a href="http://codex.wordpress.org/Post_Types" target="_blank" rel="external">Post Type</a>. Ex: <code>1,2,3,34,all-newspapers</code>.<br />' . "\n";
85
- echo '<em>(which protects several Post IDs, and <code>all</code> Posts of type: <code>newspaper</code>)</em>' . "\n";
86
- echo '</td>' . "\n";
87
 
88
- echo '</tr>' . "\n";
89
- }
90
 
91
- echo '</tbody>' . "\n";
92
- echo '</table>' . "\n";
93
- echo '</div>' . "\n";
94
-
95
- echo '</div>' . "\n";
96
-
97
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_post_level_access", get_defined_vars ());
98
- }
99
-
100
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_page_level_access", true, get_defined_vars ()))
101
- {
102
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_page_level_access", get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- echo '<div class="ws-menu-page-group" title="Page Access Restrictions">' . "\n";
105
 
106
- echo '<div class="ws-menu-page-section ws-plugin--s2member-page-level-access-section">' . "\n";
107
- echo '<h3>Page Level Access Restrictions (optional)</h3>' . "\n";
108
- echo '<p>Here you can specify Pages that are restricted to certain Membership Access Levels.</p>' . "\n";
109
- echo ((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Page IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
110
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_page_level_access", get_defined_vars ());
111
 
112
- echo '<table class="form-table">' . "\n";
113
- echo '<tbody>' . "\n";
114
 
115
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
116
- {
117
- echo '<tr>' . "\n";
118
 
119
- echo '<th>' . "\n";
120
- echo '<label for="ws-plugin--s2member-level' . $n . '-pages">' . "\n";
121
- echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Pages That Require Highest Level #' . $n . ':' . "\n" : 'Pages That Require Level #' . $n . ' Or Higher:' . "\n";
122
- echo '</label>' . "\n";
123
- echo '</th>' . "\n";
124
 
125
- echo '</tr>' . "\n";
126
- echo '<tr>' . "\n";
127
 
128
- echo '<td>' . "\n";
129
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_pages" id="ws-plugin--s2member-level' . $n . '-pages" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"]) . '" /><br />' . "\n";
130
- echo 'Page IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.' . "\n";
131
- echo '</td>' . "\n";
132
 
133
- echo '</tr>' . "\n";
134
- }
 
 
 
135
 
136
- echo '</tbody>' . "\n";
137
- echo '</table>' . "\n";
138
- echo '</div>' . "\n";
139
 
140
- echo '</div>' . "\n";
 
 
 
 
141
 
142
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_page_level_access", get_defined_vars ());
143
- }
144
 
145
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_tag_level_access", true, get_defined_vars ()))
146
- {
147
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_tag_level_access", get_defined_vars ());
 
 
148
 
149
- echo '<div class="ws-menu-page-group" title="Tag Access Restrictions">' . "\n";
 
150
 
151
- echo '<div class="ws-menu-page-section ws-plugin--s2member-tag-level-access-section">' . "\n";
152
- echo '<h3>Tag Level Access Restrictions (optional)</h3>' . "\n";
153
- echo '<p>Here you can specify Tags that are restricted to certain Membership Access Levels. This is very similar to Category Level Access. When you restrict access to a Tag Archive, it also restricts access to any Post having that Tag; even if a Post has other Tags. <em>*Tip*</em> ... Tags can be applied to any Post, without affecting your Category structure at all. If you\'d like to use Tags with Pages, get <a href="http://wordpress.org/extend/plugins/page-tagger/" target="_blank" rel="external">Page Tagger</a>.</p>' . "\n";
154
- echo '<p>Tags are caSe sensitive. The Tag <code>members only</code> is NOT the same as <code>Members Only</code>.</p>' . "\n";
155
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_tag_level_access", get_defined_vars ());
156
 
157
- echo '<table class="form-table">' . "\n";
158
- echo '<tbody>' . "\n";
 
 
 
159
 
160
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
161
- {
162
- echo '<tr>' . "\n";
163
 
164
- echo '<th>' . "\n";
165
- echo '<label for="ws-plugin--s2member-level' . $n . '-ptags">' . "\n";
166
- echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Tags That Require Highest Level #' . $n . ':' . "\n" : 'Tags That Require Level #' . $n . ' Or Higher:' . "\n";
167
- echo '</label>' . "\n";
168
- echo '</th>' . "\n";
169
 
170
- echo '</tr>' . "\n";
171
- echo '<tr>' . "\n";
 
 
 
172
 
173
- echo '<td>' . "\n";
174
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_ptags" id="ws-plugin--s2member-level' . $n . '-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]) . '" /><br />' . "\n";
175
- echo 'Tags in comma-delimited format. Example: ' . (($n === 0) ? '<code>free,subscribers only</code>' : '<code>members,members only</code>') . ' — or you can type: <code>all</code>.' . "\n";
176
- echo '</td>' . "\n";
177
 
178
- echo '</tr>' . "\n";
179
- }
 
 
 
180
 
181
- echo '</tbody>' . "\n";
182
- echo '</table>' . "\n";
183
- echo '</div>' . "\n";
184
 
185
- echo '</div>' . "\n";
 
 
 
 
186
 
187
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_tag_level_access", get_defined_vars ());
188
- }
189
 
190
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_category_level_access", true, get_defined_vars ()))
191
- {
192
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_category_level_access", get_defined_vars ());
193
 
194
- echo '<div class="ws-menu-page-group" title="Category Access Restrictions">' . "\n";
 
 
 
 
195
 
196
- echo '<div class="ws-menu-page-section ws-plugin--s2member-category-level-access-section">' . "\n";
197
- echo '<h3>Category Level Access Restrictions (optional)</h3>' . "\n";
198
- echo '<p>Here you can specify Categories that are restricted to certain Membership Access Levels. Category restrictions are a bit more complex. When you restrict access to a Category, it also restricts access to any child Categories it may have <em>(aka: sub-Categories)</em>. In other words, restricting a Category, protects a Category Archive, all of its child Category Archives, and any Posts contained within the Category, or its child Categories. This is a VERY powerful form of protection, so please be careful. It\'s very easy to protect too much content by accident.</p>' . "\n";
199
- echo ((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Category IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
200
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_category_level_access", get_defined_vars ());
201
 
202
- echo '<table class="form-table">' . "\n";
203
- echo '<tbody>' . "\n";
 
 
204
 
205
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
206
- {
207
- echo '<tr>' . "\n";
208
 
209
- echo '<th>' . "\n";
210
- echo '<label for="ws-plugin--s2member-level' . $n . '-catgs">' . "\n";
211
- echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Categories That Require Highest Level #' . $n . ':' . "\n" : 'Categories That Require Level #' . $n . ' Or Higher:' . "\n";
212
- echo '</label>' . "\n";
213
- echo '</th>' . "\n";
214
 
215
- echo '</tr>' . "\n";
216
- echo '<tr>' . "\n";
217
 
218
- echo '<td>' . "\n";
219
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_catgs" id="ws-plugin--s2member-level' . $n . '-catgs" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) . '" /><br />' . "\n";
220
- echo 'Category IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.' . "\n";
221
- echo '</td>' . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
- echo '</tr>' . "\n";
224
 
225
- echo '<tr>' . "\n";
226
- }
 
 
 
 
 
 
227
 
228
- echo '</tbody>' . "\n";
229
- echo '</table>' . "\n";
230
- echo '</div>' . "\n";
231
 
232
- echo '</div>' . "\n";
 
 
 
 
233
 
234
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_category_level_access", get_defined_vars ());
235
- }
236
 
237
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_uri_level_access", true, get_defined_vars ()))
238
- {
239
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_uri_level_access", get_defined_vars ());
 
240
 
241
- echo '<div class="ws-menu-page-group" title="URI Restrictions (typical w/BuddyPress)">' . "\n";
 
 
 
242
 
243
- echo '<div class="ws-menu-page-section ws-plugin--s2member-uri-level-access-section">' . "\n";
244
- echo '<h3>URI Level Access Restrictions (optional)</h3>' . "\n";
245
- echo '<p>Here you can specify URIs <em>(or word fragments found in URIs)</em> that are restricted to certain Membership Access Levels. Control over URIs is a little more complex. This section is intended for advanced webmasters only. That being said, here are the basics... A <code>REQUEST_URI</code>, is the portion of a <code>URL</code> that comes immediately after the domain. This is a URL <code>http://www.example.com/path/to/file.php</code>, and this is the URI: <code>/path/to/file.php</code>. In other words, a <code>REQUEST_URI</code> is the full path to a real <em>(or virtual)</em> directory and/or file on your domain.</p>' . "\n";
246
- echo '<p>In the fields below, you can provide a list <em>(one per line)</em> of URIs on your site that should be off-limits based on Membership Level. You can also use word fragments instead of a full URI. If a word fragment is found anywhere in the URI, it will be protected. Wildcards and other regex patterns are NOT supported here, and therefore you don\'t need to escape special characters or anything. Please note, these ARE caSe sensitive. You must be specific with respect to case sensitivity. The word fragment <code>some-path/</code> would NOT match a URI that contains <code>some-Path/</code>. <em>A few <a href="#" onclick="alert(\'URI Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s Username, lowercase (deprecated, please use %%current_user_nicename%%).\\n\\n%%current_user_nicename%% = The current User\\\'s Nicename in lowercase format (i.e. a cleaner version of the username for URLs; recommended for best compatibility).\\n\\n%%current_user_id%% = The current User\\\'s ID.\\n\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\n%%current_user_role%% = The current User\\\'s WordPress Role.' . ((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) ? '\\n\\n%%current_user_ccaps%% = The current User\\\'s Custom Capabilities.' : '') . '\\n\\n%%current_user_logins%% = Number of times the current User has logged in.\\n\\nFor example, if you\\\'re using BuddyPress, and want to protect BuddyPress Groups, you could add URI protection, like this: /members/%%current_user_nicename%%/groups/\'); return false;">Replacement Codes</a> are also supported here.</em></p>' . "\n";
247
- echo '<p><em><strong>*BuddyPress (and similar)*</strong> URI Restrictions work great with plugins like BuddyPress that add new areas to your site (where those new areas are NOT necessarily a Post/Page/Tag/Category). In other words, anytime you\'d like to protect a specific feature offered by BuddyPress (or other plugins), you\'ll need to nail down specific word fragments found in the URIs associated with those areas. For instance, with BuddyPress you might have: [ <a href="#" onclick="alert(\'/members/\\n/groups/\\n/blogs/\\n/activity/\\n/messages/\\n/profile/\\n/friends/\\n/settings/\'); return false;">click for example</a> ].</em></p>' . "\n";
248
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_uri_level_access", get_defined_vars ());
249
 
250
- echo '<table class="form-table">' . "\n";
251
- echo '<tbody>' . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
254
- {
255
- echo '<tr>' . "\n";
256
 
257
- echo '<th>' . "\n";
258
- echo '<label for="ws-plugin--s2member-level' . $n . '-ruris">' . "\n";
259
- echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'URIs That Require Highest Level #' . $n . ':' . "\n" : 'URIs That Require Level #' . $n . ' Or Higher:' . "\n";
260
- echo '</label>' . "\n";
261
- echo '</th>' . "\n";
262
 
263
- echo '</tr>' . "\n";
264
- echo '<tr>' . "\n";
265
 
266
- echo '<td>' . "\n";
267
- echo '<textarea name="ws_plugin__s2member_level' . $n . '_ruris" id="ws-plugin--s2member-level' . $n . '-ruris" rows="3" wrap="off" spellcheck="false">' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) . '</textarea><br />' . "\n";
268
- echo 'URIs and/or word fragments found in URIs. One per line please.' . "\n";
269
- echo '</td>' . "\n";
270
-
271
- echo '</tr>' . "\n";
272
- }
273
-
274
- echo '</tbody>' . "\n";
275
- echo '</table>' . "\n";
276
- echo '</div>' . "\n";
277
 
278
- echo '</div>' . "\n";
279
-
280
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_uri_level_access", get_defined_vars ());
281
- }
282
-
283
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_query_level_access", true, get_defined_vars ()))
284
- {
285
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_query_level_access", get_defined_vars ());
286
 
287
- echo '<div class="ws-menu-page-group" title="Alternative View Protection (please read)">' . "\n";
288
-
289
- echo '<div class="ws-menu-page-section ws-plugin--s2member-query-level-access-section">' . "\n";
290
- echo '<h3>Alternative View Protection (optional / experimental)</h3>' . "\n";
291
- echo '<p>s2Member protects Categories, Tags, Posts, Pages, Files, URIs &amp; more. BUT, even with all of those security restrictions, it\'s still possible for protected content excerpts to be seen through XML feeds, in search results generated by WordPress; and/or <em>(depending on your theme)</em>, possibly in other Archive views; which might include: Posts by Author, Posts by Date, a list of featured items formulated by your theme, OR even through other widgets/plugins adding functionality to your site. ~ We refer to all of these collectively, as "Alternative Views".</p>' . "\n";
292
- echo '<p>Using the options below, you can tell s2Member to protect some <em>(or all)</em> of these "Alternative Views", by filtering WordPress database queries for you. s2Member can automatically hide protected content that is NOT available to the current User/Member. In other words, s2Member is capable of pre-filtering ALL database queries, so that excerpts of protected content will not be allowed to slip through. This is marked "experimental", because we\'re still testing this against MANY widget/plugin/theme combinations. Please <a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Forum URI")) . '" target="_blank">report</a> all bugs.</p>' . "\n";
293
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_uri_level_access", get_defined_vars ());
294
-
295
- echo '<table class="form-table">' . "\n";
296
- echo '<tbody>' . "\n";
297
- echo '<tr>' . "\n";
298
-
299
- echo '<th>' . "\n";
300
- echo '<label for="ws-plugin--s2member-filter-wp-query">' . "\n";
301
- echo 'Protect Alternative Views?' . "\n";
302
- echo '</label>' . "\n";
303
- echo '</th>' . "\n";
304
-
305
- echo '</tr>' . "\n";
306
- echo '<tr>' . "\n";
307
-
308
- echo '<td>' . "\n";
309
- echo '<div class="ws-menu-page-scrollbox" style="height:105px;">' . "\n";
310
- echo '<input type="hidden" name="ws_plugin__s2member_filter_wp_query[]" value="update-signal" />' . "\n";
311
- foreach (array("all" => "<strong>Filter ALL WordPress queries</strong>; protecting all Alternative Views.", "searches" => "&#9492;&#9472; Searches (hide protected content in search results)", "feeds" => "&#9492;&#9472; Feeds (hide protected content in standard XML/RSS/ATOM feeds)", "comment-feeds" => "&#9492;&#9472; Comment Feeds (hide comments associated with protected content, in comment feeds)", "nav-menus" => "&#9492;&#9472; Nav Menus (hide protected content in menus generated with <em>WordPress -› Appearance -› Menus</em>)", "pages" => "&#9492;&#9472; Pages (hide protected content in widgets that list Pages)") as $ws_plugin__s2member_temp_s_value => $ws_plugin__s2member_temp_s_label)
312
- echo '<input type="checkbox" name="ws_plugin__s2member_filter_wp_query[]" id="ws-plugin--s2member-filter-wp-query-' . esc_attr (preg_replace ("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)) . '" value="' . esc_attr ($ws_plugin__s2member_temp_s_value) . '"' . ((in_array($ws_plugin__s2member_temp_s_value, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"])) ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-filter-wp-query-' . esc_attr (preg_replace ("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)) . '">' . $ws_plugin__s2member_temp_s_label . '</label><br />' . "\n";
313
- echo '</div>' . "\n";
314
- echo '<strong>Attn Developers:</strong> Filters can be suppressed dynamically, using this technique:<br />' . "\n";
315
- echo '<code><a href="http://codex.wordpress.org/Function_Reference/query_posts" target="_blank" rel="external">query_posts</a>("suppress_filters=true");</code><br />' . "\n";
316
- echo '<code><a href="http://codex.wordpress.org/Function_Reference/get_posts" target="_blank" rel="external">get_posts</a>()</code> auto-suppresses filters.<br />' . "\n";
317
- echo 'Also see <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_attach_s2member_query_filters()" target="_blank" rel="external">this article</a> in the s2Member Codex.' . "\n";
318
- echo '</td>' . "\n";
319
-
320
- echo '</tr>' . "\n";
321
- echo '</tbody>' . "\n";
322
- echo '</table>' . "\n";
323
- echo '</div>' . "\n";
324
-
325
- echo '</div>' . "\n";
326
-
327
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_query_level_access", get_defined_vars ());
328
- }
329
-
330
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_conditionals", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
331
- {
332
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_conditionals", get_defined_vars ());
333
-
334
- echo '<div class="ws-menu-page-group" title="Simple Shortcode Conditionals (protect only parts of your content)">' . "\n";
335
-
336
- echo '<div class="ws-menu-page-section ws-plugin--s2member-conditionals-section">' . "\n";
337
- echo '<h3>Simple Shortcode Conditionals (optional — to protect only parts of your content)</h3>' . "\n";
338
- echo '<p>s2Member makes it very simple to protect entire Posts/Pages/Categories/Tags/URIs/etc. This can be accomplished here in your WordPress Dashboard, using one of the many tools made available on this page. Or, from your Post/Page editing station in WordPress. We consider this to be point-and-click functionality ~ very easy.</p>'."\n";
339
- echo '<p>s2Member also makes it pretty simple to protect "parts" of a Post or Page. You can even get creative about what you display to certain Users/Members, based upon your own custom criteria. s2Member\'s Simple Shortcode Conditionals are the key to accomplishing this.</p>'."\n";
340
- echo '<p>Please see this KB article to learn more: <a href="http://www.s2member.com/kb/simple-shortcode-conditionals/" target="_blank" rel="external">s2Member Simple Shortcode Conditionals</a></p>' . "\n";
341
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_conditionals", get_defined_vars ());
342
- echo '</div>' . "\n";
343
-
344
- if((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) && c_ws_plugin__s2member_utils_conds::pro_is_installed())
345
- {
346
- echo '<div class="ws-menu-page-hr"></div>' . "\n";
347
-
348
- echo '<h3>Arbitrary PHP Code via <code>[s2If php=&quot;&quot;]</code></h3>' . "\n";
349
- echo '<p>By default, the <code>[s2If]</code> Shortcode is limited to a specific set of Conditional Tags provided by WordPress and the s2Member plugin; e.g. <code>[s2If current_user_can(access_s2member_level1)]</code>; as one quick example. Arbitrary PHP code is NOT allowed with this syntax.</p>'."\n";
350
- echo '<p>However, a second syntax variation exists; where it IS possible to use arbitrary PHP code (but only if enabled below). The second syntax variation uses one <code>php</code> Shortcode Attribute to run your conditional check; e.g. <code>[s2If php="current_user_can(\'access_s2member_level1\')"]</code>. For developers, this has some obvious advantages. The code inside the <code>php</code> attribute is evaluated at runtime, so it\'s possible to accomplish more when necessary. Of course, you could also use a plugin like <a href="https://www.s2member.com/kb/ezphp-plugin/" target="_blank" rel="external">ezPHP</a> to accomplish the same thing (if you prefer).</p>' . "\n";
351
-
352
- echo '<table class="form-table">' . "\n";
353
- echo '<tbody>' . "\n";
354
- echo '<tr>' . "\n";
355
-
356
- echo '<th>' . "\n";
357
- echo '<label for="ws-plugin--s2member-sc-conds-allow-arbitrary-php">' . "\n";
358
- echo 'Allow Arbitrary PHP Code via the <code>[s2If php=&quot;&quot;]</code> Attribute?' . "\n";
359
- echo '</label>' . "\n";
360
- echo '</th>' . "\n";
361
-
362
- echo '</tr>' . "\n";
363
- echo '<tr>' . "\n";
364
-
365
- echo '<td>' . "\n";
366
- echo '<select name="ws_plugin__s2member_sc_conds_allow_arbitrary_php" id="ws-plugin--s2member-sc-conds-allow-arbitrary-php">' . "\n";
367
- echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"]) ? ' selected="selected"' : '') . '>No (recommended for best security; e.g. on sites with multiple authors/editors)</option>' . "\n";
368
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"]) ? ' selected="selected"' : '') . '>Yes (allow me to use PHP via the [s2If php=&quot;&quot;][/s2If] shortcode)</option>' . "\n";
369
- echo '</select>' . "\n";
370
- echo '</td>' . "\n";
371
-
372
- echo '</tr>' . "\n";
373
- echo '</tbody>' . "\n";
374
- echo '</table>' . "\n";
375
- }
376
- echo '</div>' . "\n";
377
-
378
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_conditionals", get_defined_vars ());
379
- }
380
-
381
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_sp_access", true, get_defined_vars ()))
382
- {
383
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_sp_access", get_defined_vars ());
384
-
385
- echo '<div class="ws-menu-page-group" title="Specific Post/Page Access Restrictions">' . "\n";
386
-
387
- echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-access-section">' . "\n";
388
- echo '<h3>Specific Post/Page Access Restrictions (optional)</h3>' . "\n";
389
- echo '<p>s2Member now supports an additional layer of functionality <em>(very powerful)</em>, which allows you to sell access to specific Posts/Pages that you\'ve created in WordPress. Specific Post/Page Access works independently from Member Level Access. That is, you can sell an unlimited number of Posts/Pages using "Buy Now" Buttons, and your Customers will NOT be required to have a Membership Account with your site in order to receive access. If they are already a Member, that\'s fine, but they won\'t need to be.</p>' . "\n";
390
- echo '<p>In other words, Customers will NOT need to login, just to receive access to the Specific Post/Page they purchased access to. s2Member will immediately redirect the Customer to the Specific Post/Page after checkout is completed successfully. An email is also sent to the Customer with a link (see: <code>s2Member -› PayPal Options -› Specific Post/Page Email</code>). Authentication is handled automatically through self-expiring links, good for 72 hours by default.</p>' . "\n";
391
- echo '<p>Specific Post/Page Access, is sort of like selling a product. Only, instead of shipping anything to the Customer, you just give them access to a specific Post/Page on your site; one that you created in WordPress. A Specific Post/Page that is protected by s2Member, might contain a download link for your eBook, access to file &amp; music downloads, access to additional support services, and the list goes on and on. The possibilities with this are endless; as long as your digital product can be delivered through access to a WordPress Post/Page that you\'ve created.</p>' . "\n";
392
- echo '<p>Very simple. All you do is protect the Specific Post/Page IDs that are being sold on your site. Then, you can go to <code>s2Member -› PayPal Buttons -› Specific Post/Page</code> to generate "Buy Now" Buttons that you can insert into your WordPress Editor, and make available on your site. The Button Generator for s2Member, will even let you Package Additional Posts/Pages together into one transaction.</p>' . "\n";
393
- echo ((!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post/Page IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
394
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_sp_access", get_defined_vars ());
395
-
396
- echo '<table class="form-table">' . "\n";
397
- echo '<tbody>' . "\n";
398
- echo '<tr>' . "\n";
399
-
400
- echo '<th>' . "\n";
401
- echo '<label for="ws-plugin--s2member-specific-ids">' . "\n";
402
- echo 'Specific Post/Page IDs Being Sold On Your Site:' . "\n";
403
- echo '</label>' . "\n";
404
- echo '</th>' . "\n";
405
-
406
- echo '</tr>' . "\n";
407
- echo '<tr>' . "\n";
408
-
409
- echo '<td>' . "\n";
410
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_specific_ids" id="ws-plugin--s2member-specific-ids" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"]) . '" /><br />' . "\n";
411
- echo 'Post/Page IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> * Note... the word <code>all</code> does NOT work here. Also, please be careful not to create a conflict with other Access Restrictions. If you are going to sell Specific Post/Page Access, you should enter specific Post/Page IDs here; and <strong>make SURE that you\'ve NOT already protected any of these Posts/Pages with Member Level Access Restrictions</strong>. In other words, if you configure s2Member, in such as a way, that a Post/Page requires Membership Level Access, you cannot sell that same Post/Page through Specific Post/Page Access. Doing so, would create a conflict. Customers that purchased Specific Post/Page Access, would be unable to access the Post/Page - without also having a Membership. Not good. So please be careful.' . "\n";
412
- echo '</td>' . "\n";
413
-
414
- echo '</tr>' . "\n";
415
- echo '</tbody>' . "\n";
416
- echo '</table>' . "\n";
417
- echo '</div>' . "\n";
418
-
419
- echo '</div>' . "\n";
420
-
421
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_sp_access", get_defined_vars ());
422
- }
423
-
424
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_brute_force_restrictions", true, get_defined_vars ()))
425
- {
426
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_brute_force_restrictions", get_defined_vars ());
427
-
428
- echo '<div class="ws-menu-page-group" title="Brute Force IP/Login Restrictions">' . "\n";
429
-
430
- echo '<div class="ws-menu-page-section ws-plugin--s2member-brute-force-restrictions-section">' . "\n";
431
- echo '<h3>Brute Force IP/Login Restrictions (prevents username/password guessing)</h3>' . "\n";
432
- echo '<input type="button" id="ws-plugin--s2member-brute-force-restrictions-reset-button" value="Reset Brute Force Logs" class="ws-menu-page-right" style="min-width:175px;" />' . "\n";
433
- echo '<p>As with any Membership system, it is possible for someone to try and guess Username/Password combinations by attempting a <a href="http://en.wikipedia.org/wiki/Brute-force_attack" target="_blank" rel="external">Brute Force Attack</a>; whereby multiple/repeated logins are strategically attempted with various Username/Password combinations until a correct guess is made. It is NOT likely that you\'ll be attacked in this way, but it\'s still a good idea to protect your system; just in case somebody tries this. s2Member thwarts this behavior by monitoring failed login attempts that occur within a short period of time. Whenever s2Member detects an IP address <em>(i.e. a remote user)</em> that is consistently failing to enter a valid Username/Password, a temporary ban is created; preventing additional attempts from taking place for 30 minutes. This temporary ban, will ONLY affect the offending IP address.</p>' . "\n";
434
- echo '<p><em>*Note* an empty IP address (associated with someone browsing anonymously), is also considered a unique IP address, so it cannot circumvent s2Member\'s security.</em></p>' . "\n";
435
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_ip_restrictions", get_defined_vars ());
436
-
437
- echo '<table class="form-table">' . "\n";
438
- echo '<tbody>' . "\n";
439
- echo '<tr>' . "\n";
440
-
441
- echo '<th>' . "\n";
442
- echo '<label for="ws-plugin--s2member-max-failed-login-attempts">' . "\n";
443
- echo 'Maximum Failed Login Attempts:' . "\n";
444
- echo '</label>' . "\n";
445
- echo '</th>' . "\n";
446
-
447
- echo '</tr>' . "\n";
448
- echo '<tr>' . "\n";
449
-
450
- echo '<td>' . "\n";
451
- echo '<select name="ws_plugin__s2member_max_failed_login_attempts" id="ws-plugin--s2member-max-failed-login-attempts">' . "\n";
452
- $ws_plugin__s2member_temp_s = apply_filters("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes");
453
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 1) ? ' selected="selected"' : '') . '>Allow 1 failed login attempt ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
454
- echo '<option value="2"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 2) ? ' selected="selected"' : '') . '>Allow 2 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
455
- echo '<option value="3"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 3) ? ' selected="selected"' : '') . '>Allow 3 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
456
- echo '<option value="4"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 4) ? ' selected="selected"' : '') . '>Allow 4 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
457
- echo '<option value="5"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 5) ? ' selected="selected"' : '') . '>Allow 5 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
458
- echo '<option value="10"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 10) ? ' selected="selected"' : '') . '>Allow 10 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
459
- echo '<option value="20"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 20) ? ' selected="selected"' : '') . '>Allow 20 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
460
- echo '<option value="30"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 30) ? ' selected="selected"' : '') . '>Allow 30 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
461
- echo '<option value="40"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 40) ? ' selected="selected"' : '') . '>Allow 40 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
462
- echo '<option value="50"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 50) ? ' selected="selected"' : '') . '>Allow 50 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
463
- echo '<option value="75"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 75) ? ' selected="selected"' : '') . '>Allow 75 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
464
- echo '<option value="100"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 100) ? ' selected="selected"' : '') . '>Allow 100 failed login attempts ( then punish for ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
465
- echo '<option value="0"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 0) ? ' selected="selected"' : '') . '>Allow infinite failed logins (Brute Force Restrictions disabled)</option>' . "\n";
466
- echo '</select><br />' . "\n";
467
- echo 'When/if you change this, you should also <strong>Reset Brute Force Logs</strong> (click button above).' . "\n";
468
- echo (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) ? '<br /><br />The default period of "30 minutes" could be modified through this WordPress Filter:<br /><code>ws_plugin__s2member_track_failed_logins__exp_time</code>' . "\n" : '';
469
- echo '</td>' . "\n";
470
-
471
- echo '</tr>' . "\n";
472
- echo '</tbody>' . "\n";
473
- echo '</table>' . "\n";
474
- echo '</div>' . "\n";
475
-
476
- echo '</div>' . "\n";
477
-
478
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_ip_restrictions", get_defined_vars ());
479
- }
480
-
481
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_ip_restrictions", true, get_defined_vars ()))
482
- {
483
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_ip_restrictions", get_defined_vars ());
484
-
485
- echo '<div class="ws-menu-page-group" title="Unique IP Access Restrictions">' . "\n";
486
-
487
- echo '<div class="ws-menu-page-section ws-plugin--s2member-ip-restrictions-section">' . "\n";
488
- echo '<h3>Unique IP Access Restrictions (prevents username/link sharing)</h3>' . "\n";
489
- echo '<input type="button" id="ws-plugin--s2member-ip-restrictions-reset-button" value="Reset IP Restriction Logs" class="ws-menu-page-right" style="min-width:175px;" />' . "\n";
490
- echo '<p>As with any Membership system, it is possible for one Member to signup, and then share their Username with someone else; or even post it online for the whole world to see. This is known as Link Sharing <em>(aka: Username Sharing)</em>. It is NOT likely that you\'ll be attacked in this way, but it\'s still a good idea to protect your system; just in case somebody tries this. s2Member\'s IP Restrictions work for Membership Level Access <em>(account logins)</em>, Specific Post/Page Access, Registration Links, and other secure Entry Points. In all cases, the rules are simple. A single Username, Access Link, and/or Entry Point ... is only valid for a certain number of unique IP addresses. Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban <em>(preventing access)</em> to a Specific Post/Page, or to an account associated with a particular Username. This temporary ban, will ONLY affect the offending Link and/or Username associated with the security breach. You can fine-tune this behavior, using the options below.</p>' . "\n";
491
- echo '<p><em>*Note* an empty IP address (associated with someone browsing anonymously), is also considered a unique IP address, so it cannot circumvent s2Member\'s security.</em></p>' . "\n";
492
- echo '<p><em><strong>Note:</strong> This feature can work with or without <strong>Simultaneous Login Monitoring</strong> (Simultaneous Login Monitoring is available only in s2Member Pro). You can choose to implement both Unique IP Access Restrictions and Simultaneous Login Monitoring together; or just one of these; or neither of them. It\'s a matter of preference.</em></p>' . "\n";
493
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_ip_restrictions", get_defined_vars ());
494
-
495
- echo '<table class="form-table">' . "\n";
496
- echo '<tbody>' . "\n";
497
- echo '<tr>' . "\n";
498
-
499
- echo '<th>' . "\n";
500
- echo '<label for="ws-plugin--s2member-max-ip-restriction">' . "\n";
501
- echo 'Maximum Unique IP Addresses Allowed:' . "\n";
502
- echo '</label>' . "\n";
503
- echo '</th>' . "\n";
504
-
505
- echo '</tr>' . "\n";
506
- echo '<tr>' . "\n";
507
-
508
- echo '<td>' . "\n";
509
- echo '<select name="ws_plugin__s2member_max_ip_restriction" id="ws-plugin--s2member-max-ip-restriction">' . "\n";
510
- $ws_plugin__s2member_temp_s = apply_filters("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
511
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 1) ? ' selected="selected"' : '') . '>Allow up to 1 unique IP per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
512
- echo '<option value="2"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 2) ? ' selected="selected"' : '') . '>Allow up to 2 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
513
- echo '<option value="3"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 3) ? ' selected="selected"' : '') . '>Allow up to 3 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
514
- echo '<option value="4"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 4) ? ' selected="selected"' : '') . '>Allow up to 4 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
515
- echo '<option value="5"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 5) ? ' selected="selected"' : '') . '>Allow up to 5 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
516
- echo '<option value="10"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 10) ? ' selected="selected"' : '') . '>Allow up to 10 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
517
- echo '<option value="20"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 20) ? ' selected="selected"' : '') . '>Allow up to 20 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
518
- echo '<option value="30"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 30) ? ' selected="selected"' : '') . '>Allow up to 30 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
519
- echo '<option value="40"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 40) ? ' selected="selected"' : '') . '>Allow up to 40 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
520
- echo '<option value="50"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 50) ? ' selected="selected"' : '') . '>Allow up to 50 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
521
- echo '<option value="75"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 75) ? ' selected="selected"' : '') . '>Allow up to 75 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
522
- echo '<option value="100"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 100) ? ' selected="selected"' : '') . '>Allow up to 100 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
523
- echo '<option value="0"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 0) ? ' selected="selected"' : '') . '>Allow infinite IPs (all IP Restrictions are disabled)</option>' . "\n";
524
- echo '</select>' . "\n";
525
- echo (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) ? '<br />The default period of "30 days" could be modified through this WordPress Filter:<br /><code>ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip</code>' . "\n" : '';
526
- echo '</td>' . "\n";
527
-
528
- echo '</tr>' . "\n";
529
- echo '<tr>' . "\n";
530
-
531
- echo '<th>' . "\n";
532
- echo '<label for="ws-plugin--s2member-max-ip-restriction-time">' . "\n";
533
- echo 'Security Breach Timeout Period:' . "\n";
534
- echo '</label>' . "\n";
535
- echo '</th>' . "\n";
536
-
537
- echo '</tr>' . "\n";
538
- echo '<tr>' . "\n";
539
-
540
- echo '<td>' . "\n";
541
- echo '<select name="ws_plugin__s2member_max_ip_restriction_time" id="ws-plugin--s2member-max-ip-restriction-time">' . "\n";
542
- echo '<option value="300"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 300) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 5 mins)</option>' . "\n";
543
- echo '<option value="900"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 900) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 15 mins)</option>' . "\n";
544
- echo '<option value="1800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1800) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 30 mins)</option>' . "\n";
545
- echo '<option value="3600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 3600) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 1 hour)</option>' . "\n";
546
- echo '<option value="7200"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7200) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 2 hours)</option>' . "\n";
547
- echo '<option value="14400"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 14400) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 4 hours)</option>' . "\n";
548
- echo '<option value="21600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 21600) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 6 hours)</option>' . "\n";
549
- echo '<option value="28800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 28800) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 8 hours)</option>' . "\n";
550
- echo '<option value="43200"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 43200) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 12 hours)</option>' . "\n";
551
- echo '<option value="86400"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 86400) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 24 hours)</option>' . "\n";
552
- echo '<option value="172800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 172800) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 2 days)</option>' . "\n";
553
- echo '<option value="345600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 345600) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 4 days)</option>' . "\n";
554
- echo '<option value="604800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 604800) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 1 week)</option>' . "\n";
555
- echo '<option value="1209600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1209600) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 2 weeks)</option>' . "\n";
556
- echo '<option value="2629743"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 2629743) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 1 month)</option>' . "\n";
557
- echo '<option value="5259487"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 5259487) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 2 months)</option>' . "\n";
558
- echo '<option value="7889231"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7889231) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 3 months)</option>' . "\n";
559
- echo '<option value="15778463"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 15778463) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 6 months)</option>' . "\n";
560
- echo '<option value="31556926"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 31556926) ? ' selected="selected"' : '') . '>If limit is exceeded (punish for 1 year)</option>' . "\n";
561
- echo '</select><br />' . "\n";
562
- echo 'When/if you change this, you should also <strong>Reset IP Restriction Logs</strong> (click button above).' . "\n";
563
- echo '</td>' . "\n";
564
-
565
- echo '</tr>' . "\n";
566
- echo '</tbody>' . "\n";
567
- echo '</table>' . "\n";
568
- echo '</div>' . "\n";
569
-
570
- echo '</div>' . "\n";
571
-
572
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_ip_restrictions", get_defined_vars ());
573
- }
574
-
575
- if (apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_slogin_restrictions", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars ()))
576
- {
577
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_slogin_restrictions", get_defined_vars ());
578
-
579
- echo '<div class="ws-menu-page-group" title="Simultaneous Login Restrictions">' . "\n";
580
-
581
- echo '<div class="ws-menu-page-section ws-plugin--s2member-slogin-restrictions-section">' . "\n";
582
- echo '<h3>Simultaneous Login Restrictions (prevents username sharing)</h3>' . "\n";
583
- echo '<p>As with any Membership system, it is possible for one Member to signup, and then share their Username with someone else; or even post it online for the whole world to see. This is known as Username Sharing. It is NOT likely that you\'ll be attacked in this way, but it\'s not a bad idea to protect your system; just in case somebody tries this.</p>'."\n";
584
- echo '<p>s2Member\'s Simultaneous Login Monitoring (for Membership Access only); works w/ user account logins <em>(Usernames)</em> to help you prevent a security breach. The rules are simple. A single Username can only have X number of simultaneous logins (as configured below). Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban <em>(preventing access)</em> and the offending Username will be unable to login until somebody else (who is already logged into the account) has logged-out; clearing the way for someone new.</p>' . "\n";
585
- echo '<p>This can be a tricky feature to configure, because not everyone actually clicks the "Logout" link obviously, and so it can be challenging to know when someone is still logged into the site and when they\'re not. s2Member monitors simultaneous logins by updating a timer when someone actually logs in; and then again on each page view while they navigate the site. If there is no activity after X amount of time, s2Member\'s Simultaneous Login Monitor considers that person inactive, and will not include them in security checks until they login again, or visit a new page on the site. You can configure the timeout period below. The default value is <code>30 minutes</code> (we recommend a low value to reduce the chance of error).</p>' . "\n";
586
- echo '<p><em><strong>Note:</strong> This feature can work with or without <strong>Unique IP Access Restrictions</strong> being enabled. You can choose to implement both Unique IP Access Restrictions and Simultaneous Login Monitoring together; or just one of these; or neither of them. It\'s a matter of preference.</em></p>' . "\n";
587
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_slogin_restrictions", get_defined_vars ());
588
-
589
- echo '<table class="form-table">' . "\n";
590
- echo '<tbody>' . "\n";
591
- echo '<tr>' . "\n";
592
-
593
- echo '<th>' . "\n";
594
- echo '<label for="ws-plugin--s2member-max-simultaneous-logins">' . "\n";
595
- echo 'Max Simultaneous Logins Allowed; for each Username:' . "\n";
596
- echo '</label>' . "\n";
597
- echo '</th>' . "\n";
598
-
599
- echo '</tr>' . "\n";
600
- echo '<tr>' . "\n";
601
-
602
- echo '<td>' . "\n";
603
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_max_simultaneous_logins" id="ws-plugin--s2member-max-simultaneous-logins" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_simultaneous_logins"]) . '" /><br />' . "\n";
604
- echo 'Examples: <code>0</code> (to disable this functionality), <code>1</code> (maximum of 1 login at a time), <code>2</code>, <code>3</code>, <code>10</code>, <code>20</code>, etc.<br />' . "\n";
605
- echo 'Suggestion: <code>3</code> — the chance to open your site in multiple browsers; but still prevents major security issues.<br />' . "\n";
606
- echo '</td>' . "\n";
607
-
608
- echo '</tr>' . "\n";
609
- echo '<tr>' . "\n";
610
-
611
- echo '<th>' . "\n";
612
- echo '<label for="ws-plugin--s2member-max-simultaneous-logins-timeout">' . "\n";
613
- echo 'Inactivity Timeout Period; this impacts Simultaneous Login Monitoring only.<br />' . "\n";
614
- echo 'Simultaneous Login Monitoring should assume a Username is logged-out after this amount of time:' . "\n";
615
- echo '</label>' . "\n";
616
- echo '</th>' . "\n";
617
-
618
- echo '</tr>' . "\n";
619
- echo '<tr>' . "\n";
620
-
621
- echo '<td>' . "\n";
622
- echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_max_simultaneous_logins_timeout" id="ws-plugin--s2member-max-simultaneous-logins-timeout" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_simultaneous_logins_timeout"]) . '" /><br />' . "\n";
623
- echo 'Examples: <code>30 minutes</code>, <code>1 hour</code>, <code>2 hours</code>; anything compatible with PHP\'s <a href="http://php.net/manual/en/function.strtotime.php" target="_blank" rel="external">strtotime()</a>.<br />' . "\n";
624
- echo 'Recommended Setting: <code>30 minutes</code>; if they stop browsing the site, they\'re considered inactive.<br />' . "\n";
625
- echo '</td>' . "\n";
626
-
627
- echo '</tr>' . "\n";
628
- echo '</tbody>' . "\n";
629
- echo '</table>' . "\n";
630
- echo '</div>' . "\n";
631
-
632
- echo '</div>' . "\n";
633
-
634
- do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_slogin_restrictions", get_defined_vars ());
635
- }
636
-
637
- do_action("ws_plugin__s2member_during_res_ops_page_after_left_sections", get_defined_vars ());
638
-
639
- echo '<div class="ws-menu-page-hr"></div>' . "\n";
640
-
641
- echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>' . "\n";
642
-
643
- echo '</form>' . "\n";
644
-
645
- echo '</td>' . "\n";
646
-
647
- echo '<td class="ws-menu-page-table-r">' . "\n";
648
- c_ws_plugin__s2member_menu_pages_rs::display ();
649
- echo '</td>' . "\n";
650
-
651
- echo '</tr>' . "\n";
652
- echo '</tbody>' . "\n";
653
- echo '</table>' . "\n";
654
 
655
- echo '</div>' . "\n";
656
- }
657
- }
658
  }
659
-
660
- new c_ws_plugin__s2member_menu_page_res_ops ();
661
- ?>
1
  <?php
2
  /**
3
+ * Menu page for the s2Member plugin (Restriction Options page).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * (coded in the USA)
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Menu_Pages
15
+ * @since 3.0
16
+ */
17
+ if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
 
20
+ if(!class_exists("c_ws_plugin__s2member_menu_page_res_ops"))
21
+ {
22
+ /**
23
+ * Menu page for the s2Member plugin (Restriction Options page).
24
+ *
25
+ * @package s2Member\Menu_Pages
26
+ * @since 110531
27
+ */
28
+ class c_ws_plugin__s2member_menu_page_res_ops
29
  {
30
+ public function __construct()
31
+ {
32
+ echo '<div class="wrap ws-menu-page">'."\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ echo '<div class="ws-menu-page-toolbox">'."\n";
35
+ c_ws_plugin__s2member_menu_pages_tb::display();
36
+ echo '</div>'."\n";
37
 
38
+ echo '<h2>Restriction Options</h2>'."\n";
 
 
 
 
39
 
40
+ echo '<table class="ws-menu-page-table">'."\n";
41
+ echo '<tbody class="ws-menu-page-table-tbody">'."\n";
42
+ echo '<tr class="ws-menu-page-table-tr">'."\n";
43
+ echo '<td class="ws-menu-page-table-l">'."\n";
44
 
45
+ echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">'."\n";
46
+ echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")).'" />'."\n";
47
+ echo '<input type="hidden" name="ws_plugin__s2member_configured" id="ws-plugin--s2member-configured" value="1" />'."\n";
 
 
 
48
 
49
+ do_action("ws_plugin__s2member_during_res_ops_page_before_left_sections", get_defined_vars());
 
50
 
51
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_post_level_access", TRUE, get_defined_vars()))
52
+ {
53
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_post_level_access", get_defined_vars());
54
+
55
+ echo '<div class="ws-menu-page-group" title="Post Access Restrictions">'."\n";
56
+
57
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-post-level-access-section">'."\n";
58
+ echo '<h3>Post Level Access Restrictions (optional)</h3>'."\n";
59
+ echo '<p>Here you can specify Posts that are restricted to certain Membership Access Levels. s2Member also supports Custom <a href="http://codex.wordpress.org/Post_Types" target="_blank" rel="external">Post Types</a> here. If you have a theme or plugin installed, which has enabled Custom Post Types <em>(i.e. Music/Videos or something else)</em>, you can put the IDs for those Posts here.</p>'."\n";
60
+ echo '<p><em><strong>*Note*</strong> Protecting individual Posts, ONLY protects the Permalinks for those Posts. It is still possible for excerpts of protected content to be seen in search results generated by WordPress, feeds, and Archive views; such as your Home Page, inside a Category listing, or through other queries formulated by your theme. This is the intended functionality. Excerpts are a great way to "tease" public visitors. In other words, public visitors may have access to excerpts introduced by your theme, but any attempt to view the full Post (i.e. the Permalink) will result in an automatic redirect to your Membership Options Page; requiring registration.</em></p>'."\n";
61
+ echo '<p><em><strong>*Note*</strong> If you would like to protect many Posts at once (including Archive views), you can use Category Level Restrictions, Tag Level Restrictions, or have a look down below at s2Member\'s options for "Alternative View Protection", which deals with search results, as well as feeds.</em></p>'."\n";
62
+ echo ((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>'."\n" : '';
63
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_post_level_access", get_defined_vars());
64
+
65
+ echo '<table class="form-table">'."\n";
66
+ echo '<tbody>'."\n";
67
+
68
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
69
+ {
70
+ echo '<tr>'."\n";
71
+
72
+ echo '<th>'."\n";
73
+ echo '<label for="ws-plugin--s2member-level'.$n.'-posts">'."\n";
74
+ echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Posts That Require Highest Level #'.$n.':'."\n" : 'Posts That Require Level #'.$n.' Or Higher:'."\n";
75
+ echo '</label>'."\n";
76
+ echo '</th>'."\n";
77
+
78
+ echo '</tr>'."\n";
79
+ echo '<tr>'."\n";
80
+
81
+ echo '<td>'."\n";
82
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_posts" id="ws-plugin--s2member-level'.$n.'-posts" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_posts"]).'" /><br />'."\n";
83
+ echo 'Post IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.<br />'."\n";
84
+ echo 'You can also include all Post IDs of a specific <a href="http://codex.wordpress.org/Post_Types" target="_blank" rel="external">Post Type</a>. Ex: <code>1,2,3,34,all-newspapers</code>.<br />'."\n";
85
+ echo '<em>(which protects several Post IDs, and <code>all</code> Posts of type: <code>newspaper</code>)</em>'."\n";
86
+ echo '</td>'."\n";
87
+
88
+ echo '</tr>'."\n";
89
+ }
90
+ echo '</tbody>'."\n";
91
+ echo '</table>'."\n";
92
+ echo '</div>'."\n";
93
+
94
+ echo '</div>'."\n";
95
+
96
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_post_level_access", get_defined_vars());
97
+ }
98
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_page_level_access", TRUE, get_defined_vars()))
99
+ {
100
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_page_level_access", get_defined_vars());
101
 
102
+ echo '<div class="ws-menu-page-group" title="Page Access Restrictions">'."\n";
103
 
104
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-page-level-access-section">'."\n";
105
+ echo '<h3>Page Level Access Restrictions (optional)</h3>'."\n";
106
+ echo '<p>Here you can specify Pages that are restricted to certain Membership Access Levels.</p>'."\n";
107
+ echo ((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Page IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>'."\n" : '';
108
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_page_level_access", get_defined_vars());
109
 
110
+ echo '<table class="form-table">'."\n";
111
+ echo '<tbody>'."\n";
112
 
113
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
114
+ {
115
+ echo '<tr>'."\n";
116
 
117
+ echo '<th>'."\n";
118
+ echo '<label for="ws-plugin--s2member-level'.$n.'-pages">'."\n";
119
+ echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Pages That Require Highest Level #'.$n.':'."\n" : 'Pages That Require Level #'.$n.' Or Higher:'."\n";
120
+ echo '</label>'."\n";
121
+ echo '</th>'."\n";
122
 
123
+ echo '</tr>'."\n";
124
+ echo '<tr>'."\n";
125
 
126
+ echo '<td>'."\n";
127
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_pages" id="ws-plugin--s2member-level'.$n.'-pages" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_pages"]).'" /><br />'."\n";
128
+ echo 'Page IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.'."\n";
129
+ echo '</td>'."\n";
130
 
131
+ echo '</tr>'."\n";
132
+ }
133
+ echo '</tbody>'."\n";
134
+ echo '</table>'."\n";
135
+ echo '</div>'."\n";
136
 
137
+ echo '</div>'."\n";
 
 
138
 
139
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_page_level_access", get_defined_vars());
140
+ }
141
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_tag_level_access", TRUE, get_defined_vars()))
142
+ {
143
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_tag_level_access", get_defined_vars());
144
 
145
+ echo '<div class="ws-menu-page-group" title="Tag Access Restrictions">'."\n";
 
146
 
147
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-tag-level-access-section">'."\n";
148
+ echo '<h3>Tag Level Access Restrictions (optional)</h3>'."\n";
149
+ echo '<p>Here you can specify Tags that are restricted to certain Membership Access Levels. This is very similar to Category Level Access. When you restrict access to a Tag Archive, it also restricts access to any Post having that Tag; even if a Post has other Tags. <em>*Tip*</em> ... Tags can be applied to any Post, without affecting your Category structure at all. If you\'d like to use Tags with Pages, get <a href="http://wordpress.org/extend/plugins/page-tagger/" target="_blank" rel="external">Page Tagger</a>.</p>'."\n";
150
+ echo '<p>Tags are caSe sensitive. The Tag <code>members only</code> is NOT the same as <code>Members Only</code>.</p>'."\n";
151
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_tag_level_access", get_defined_vars());
152
 
153
+ echo '<table class="form-table">'."\n";
154
+ echo '<tbody>'."\n";
155
 
156
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
157
+ {
158
+ echo '<tr>'."\n";
 
 
159
 
160
+ echo '<th>'."\n";
161
+ echo '<label for="ws-plugin--s2member-level'.$n.'-ptags">'."\n";
162
+ echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Tags That Require Highest Level #'.$n.':'."\n" : 'Tags That Require Level #'.$n.' Or Higher:'."\n";
163
+ echo '</label>'."\n";
164
+ echo '</th>'."\n";
165
 
166
+ echo '</tr>'."\n";
167
+ echo '<tr>'."\n";
 
168
 
169
+ echo '<td>'."\n";
170
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_ptags" id="ws-plugin--s2member-level'.$n.'-ptags" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_ptags"]).'" /><br />'."\n";
171
+ echo 'Tags in comma-delimited format. Example: '.(($n === 0) ? '<code>free,subscribers only</code>' : '<code>members,members only</code>').' or you can type: <code>all</code>.'."\n";
172
+ echo '</td>'."\n";
 
173
 
174
+ echo '</tr>'."\n";
175
+ }
176
+ echo '</tbody>'."\n";
177
+ echo '</table>'."\n";
178
+ echo '</div>'."\n";
179
 
180
+ echo '</div>'."\n";
 
 
 
181
 
182
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_tag_level_access", get_defined_vars());
183
+ }
184
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_category_level_access", TRUE, get_defined_vars()))
185
+ {
186
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_category_level_access", get_defined_vars());
187
 
188
+ echo '<div class="ws-menu-page-group" title="Category Access Restrictions">'."\n";
 
 
189
 
190
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-category-level-access-section">'."\n";
191
+ echo '<h3>Category Level Access Restrictions (optional)</h3>'."\n";
192
+ echo '<p>Here you can specify Categories that are restricted to certain Membership Access Levels. Category restrictions are a bit more complex. When you restrict access to a Category, it also restricts access to any child Categories it may have <em>(aka: sub-Categories)</em>. In other words, restricting a Category, protects a Category Archive, all of its child Category Archives, and any Posts contained within the Category, or its child Categories. This is a VERY powerful form of protection, so please be careful. It\'s very easy to protect too much content by accident.</p>'."\n";
193
+ echo ((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Category IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>'."\n" : '';
194
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_category_level_access", get_defined_vars());
195
 
196
+ echo '<table class="form-table">'."\n";
197
+ echo '<tbody>'."\n";
198
 
199
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
200
+ {
201
+ echo '<tr>'."\n";
202
 
203
+ echo '<th>'."\n";
204
+ echo '<label for="ws-plugin--s2member-level'.$n.'-catgs">'."\n";
205
+ echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'Categories That Require Highest Level #'.$n.':'."\n" : 'Categories That Require Level #'.$n.' Or Higher:'."\n";
206
+ echo '</label>'."\n";
207
+ echo '</th>'."\n";
208
 
209
+ echo '</tr>'."\n";
210
+ echo '<tr>'."\n";
 
 
 
211
 
212
+ echo '<td>'."\n";
213
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_level'.$n.'_catgs" id="ws-plugin--s2member-level'.$n.'-catgs" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_catgs"]).'" /><br />'."\n";
214
+ echo 'Category IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> — or you can type: <code>all</code>.'."\n";
215
+ echo '</td>'."\n";
216
 
217
+ echo '</tr>'."\n";
 
 
218
 
219
+ echo '<tr>'."\n";
220
+ }
221
+ echo '</tbody>'."\n";
222
+ echo '</table>'."\n";
223
+ echo '</div>'."\n";
224
 
225
+ echo '</div>'."\n";
 
226
 
227
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_category_level_access", get_defined_vars());
228
+ }
229
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_uri_level_access", TRUE, get_defined_vars()))
230
+ {
231
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_uri_level_access", get_defined_vars());
232
+
233
+ echo '<div class="ws-menu-page-group" title="URI Restrictions (typical w/BuddyPress)">'."\n";
234
+
235
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-uri-level-access-section">'."\n";
236
+ echo '<h3>URI Level Access Restrictions (optional)</h3>'."\n";
237
+ echo '<p>Here you can specify URIs <em>(or word fragments found in URIs)</em> that are restricted to certain Membership Access Levels. Control over URIs is a little more complex. This section is intended for advanced webmasters only. That being said, here are the basics... A <code>REQUEST_URI</code>, is the portion of a <code>URL</code> that comes immediately after the domain. This is a URL <code>http://www.example.com/path/to/file.php</code>, and this is the URI: <code>/path/to/file.php</code>. In other words, a <code>REQUEST_URI</code> is the full path to a real <em>(or virtual)</em> directory and/or file on your domain.</p>'."\n";
238
+ echo '<p>In the fields below, you can provide a list <em>(one per line)</em> of URIs on your site that should be off-limits based on Membership Level. You can also use word fragments instead of a full URI. If a word fragment is found anywhere in the URI, it will be protected. Wildcards and other regex patterns are NOT supported here, and therefore you don\'t need to escape special characters or anything. Please note, depending on your caSe configuration option (as seen below), your exclusion patterns might be caSe sensitive. If you choose to make these caSe sensitive, you must be specific. The word fragment <code>some-path/</code> would NOT match a URI that contains <code>some-Path/</code>. <em>A few <a href="#" onclick="alert(\'URI Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s Username, lowercase (deprecated, please use %%current_user_nicename%%).\\n\\n%%current_user_nicename%% = The current User\\\'s Nicename in lowercase format (i.e. a cleaner version of the username for URLs; recommended for best compatibility).\\n\\n%%current_user_id%% = The current User\\\'s ID.\\n\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\n%%current_user_role%% = The current User\\\'s WordPress Role.'.((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) ? '\\n\\n%%current_user_ccaps%% = The current User\\\'s Custom Capabilities.' : '').'\\n\\n%%current_user_logins%% = Number of times the current User has logged in.\\n\\nFor example, if you\\\'re using BuddyPress, and want to protect BuddyPress Groups, you could add URI protection, like this: /members/%%current_user_nicename%%/groups/\'); return false;">Replacement Codes</a> are also supported here.</em></p>'."\n";
239
+ echo '<p><em><strong>*BuddyPress (and similar)*</strong> URI Restrictions work great with plugins like BuddyPress that add new areas to your site (where those new areas are NOT necessarily a Post/Page/Tag/Category). In other words, anytime you\'d like to protect a specific feature offered by BuddyPress (or other plugins), you\'ll need to nail down specific word fragments found in the URIs associated with those areas. For instance, with BuddyPress you might have: [ <a href="#" onclick="alert(\'/members/\\n/groups/\\n/blogs/\\n/activity/\\n/messages/\\n/profile/\\n/friends/\\n/settings/\'); return false;">click for example</a> ].</em></p>'."\n";
240
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_uri_level_access", get_defined_vars());
241
+
242
+ echo '<table class="form-table">'."\n";
243
+ echo '<tbody>'."\n";
244
+ echo '<tr>'."\n";
245
+
246
+ echo '<th>'."\n";
247
+ echo '<label for="ws-plugin--s2member-ruris-case-sensitive">'."\n";
248
+ echo 'URI Restrictions caSe Sensitive?'."\n";
249
+ echo '</label>'."\n";
250
+ echo '</th>'."\n";
251
+
252
+ echo '</tr>'."\n";
253
+ echo '<tr>'."\n";
254
+
255
+ echo '<td>'."\n";
256
+ echo '<select name="ws_plugin__s2member_ruris_case_sensitive" id="ws-plugin--s2member-ruris-case-sensitive">'."\n";
257
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ruris_case_sensitive"]) ? ' selected="selected"' : '').'>No (caSe-insensitive; recommended)</option>'."\n";
258
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ruris_case_sensitive"]) ? ' selected="selected"' : '').'>Yes (caSe-sensitive; /some-path/ NOT the same as /some-Path/)</option>'."\n";
259
+ echo '</select><br />'."\n";
260
+ echo 'Recommended setting: (<code>No; caSe-insensitive</code>)'."\n";
261
+ echo '</td>'."\n";
262
+
263
+ echo '</tr>'."\n";
264
+ echo '</tbody>'."\n";
265
+ echo '</table>'."\n";
266
+
267
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
268
+
269
+ echo '<table class="form-table">'."\n";
270
+ echo '<tbody>'."\n";
271
+
272
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
273
+ {
274
+ echo '<tr>'."\n";
275
+
276
+ echo '<th>'."\n";
277
+ echo '<label for="ws-plugin--s2member-level'.$n.'-ruris">'."\n";
278
+ echo ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) ? 'URIs That Require Highest Level #'.$n.':'."\n" : 'URIs That Require Level #'.$n.' Or Higher:'."\n";
279
+ echo '</label>'."\n";
280
+ echo '</th>'."\n";
281
+
282
+ echo '</tr>'."\n";
283
+ echo '<tr>'."\n";
284
+
285
+ echo '<td>'."\n";
286
+ echo '<textarea name="ws_plugin__s2member_level'.$n.'_ruris" id="ws-plugin--s2member-level'.$n.'-ruris" rows="3" wrap="off" spellcheck="false">'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_ruris"]).'</textarea><br />'."\n";
287
+ echo 'URIs and/or word fragments found in URIs. One per line please.'."\n";
288
+ echo '</td>'."\n";
289
+
290
+ echo '</tr>'."\n";
291
+ }
292
+ echo '</tbody>'."\n";
293
+ echo '</table>'."\n";
294
+ echo '</div>'."\n";
295
+
296
+ echo '</div>'."\n";
297
+
298
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_uri_level_access", get_defined_vars());
299
+ }
300
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_query_level_access", TRUE, get_defined_vars()))
301
+ {
302
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_query_level_access", get_defined_vars());
303
+
304
+ echo '<div class="ws-menu-page-group" title="Alternative View Protection (please read)">'."\n";
305
+
306
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-query-level-access-section">'."\n";
307
+ echo '<h3>Alternative View Protection (optional / experimental)</h3>'."\n";
308
+ echo '<p>s2Member protects Categories, Tags, Posts, Pages, Files, URIs &amp; more. BUT, even with all of those security restrictions, it\'s still possible for protected content excerpts to be seen through XML feeds, in search results generated by WordPress; and/or <em>(depending on your theme)</em>, possibly in other Archive views; which might include: Posts by Author, Posts by Date, a list of featured items formulated by your theme, OR even through other widgets/plugins adding functionality to your site. ~ We refer to all of these collectively, as "Alternative Views".</p>'."\n";
309
+ echo '<p>Using the options below, you can tell s2Member to protect some <em>(or all)</em> of these "Alternative Views", by filtering WordPress database queries for you. s2Member can automatically hide protected content that is NOT available to the current User/Member. In other words, s2Member is capable of pre-filtering ALL database queries, so that excerpts of protected content will not be allowed to slip through. This is marked "experimental", because we\'re still testing this against MANY widget/plugin/theme combinations. Please <a href="'.esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Forum URI")).'" target="_blank">report</a> all bugs.</p>'."\n";
310
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_uri_level_access", get_defined_vars());
311
+
312
+ echo '<table class="form-table">'."\n";
313
+ echo '<tbody>'."\n";
314
+ echo '<tr>'."\n";
315
+
316
+ echo '<th>'."\n";
317
+ echo '<label for="ws-plugin--s2member-filter-wp-query">'."\n";
318
+ echo 'Protect Alternative Views?'."\n";
319
+ echo '</label>'."\n";
320
+ echo '</th>'."\n";
321
+
322
+ echo '</tr>'."\n";
323
+ echo '<tr>'."\n";
324
+
325
+ echo '<td>'."\n";
326
+ echo '<div class="ws-menu-page-scrollbox" style="height:105px;">'."\n";
327
+ echo '<input type="hidden" name="ws_plugin__s2member_filter_wp_query[]" value="update-signal" />'."\n";
328
+ foreach(array("all" => "<strong>Filter ALL WordPress queries</strong>; protecting all Alternative Views.", "searches" => "&#9492;&#9472; Searches (hide protected content in search results)", "feeds" => "&#9492;&#9472; Feeds (hide protected content in standard XML/RSS/ATOM feeds)", "comment-feeds" => "&#9492;&#9472; Comment Feeds (hide comments associated with protected content, in comment feeds)", "nav-menus" => "&#9492;&#9472; Nav Menus (hide protected content in menus generated with <em>WordPress -› Appearance -› Menus</em>)", "pages" => "&#9492;&#9472; Pages (hide protected content in widgets that list Pages)") as $ws_plugin__s2member_temp_s_value => $ws_plugin__s2member_temp_s_label)
329
+ echo '<input type="checkbox" name="ws_plugin__s2member_filter_wp_query[]" id="ws-plugin--s2member-filter-wp-query-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'" value="'.esc_attr($ws_plugin__s2member_temp_s_value).'"'.((in_array($ws_plugin__s2member_temp_s_value, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"])) ? ' checked="checked"' : '').' /> <label for="ws-plugin--s2member-filter-wp-query-'.esc_attr(preg_replace("/[^a-z0-9_\-]/", "-", $ws_plugin__s2member_temp_s_value)).'">'.$ws_plugin__s2member_temp_s_label.'</label><br />'."\n";
330
+ echo '</div>'."\n";
331
+ echo '<strong>Attn Developers:</strong> Filters can be suppressed dynamically, using this technique:<br />'."\n";
332
+ echo '<code><a href="http://codex.wordpress.org/Function_Reference/query_posts" target="_blank" rel="external">query_posts</a>("suppress_filters=true");</code><br />'."\n";
333
+ echo '<code><a href="http://codex.wordpress.org/Function_Reference/get_posts" target="_blank" rel="external">get_posts</a>()</code> auto-suppresses filters.<br />'."\n";
334
+ echo 'Also see <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_attach_s2member_query_filters()" target="_blank" rel="external">this article</a> in the s2Member Codex.'."\n";
335
+ echo '</td>'."\n";
336
+
337
+ echo '</tr>'."\n";
338
+ echo '</tbody>'."\n";
339
+ echo '</table>'."\n";
340
+ echo '</div>'."\n";
341
+
342
+ echo '</div>'."\n";
343
+
344
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_query_level_access", get_defined_vars());
345
+ }
346
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_conditionals", (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()), get_defined_vars()))
347
+ {
348
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_conditionals", get_defined_vars());
349
+
350
+ echo '<div class="ws-menu-page-group" title="Simple Shortcode Conditionals (protect only parts of your content)">'."\n";
351
+
352
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-conditionals-section">'."\n";
353
+ echo '<h3>Simple Shortcode Conditionals (optional — to protect only parts of your content)</h3>'."\n";
354
+ echo '<p>s2Member makes it very simple to protect entire Posts/Pages/Categories/Tags/URIs/etc. This can be accomplished here in your WordPress Dashboard, using one of the many tools made available on this page. Or, from your Post/Page editing station in WordPress. We consider this to be point-and-click functionality ~ very easy.</p>'."\n";
355
+ echo '<p>s2Member also makes it pretty simple to protect "parts" of a Post or Page. You can even get creative about what you display to certain Users/Members, based upon your own custom criteria. s2Member\'s Simple Shortcode Conditionals are the key to accomplishing this.</p>'."\n";
356
+ echo '<p>Please see this KB article to learn more: <a href="http://www.s2member.com/kb/simple-shortcode-conditionals/" target="_blank" rel="external">s2Member Simple Shortcode Conditionals</a></p>'."\n";
357
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_conditionals", get_defined_vars());
358
+ echo '</div>'."\n";
359
+
360
+ if((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) && c_ws_plugin__s2member_utils_conds::pro_is_installed())
361
+ {
362
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
363
+
364
+ echo '<h3>Arbitrary PHP Code via <code>[s2If php=&quot;&quot;]</code></h3>'."\n";
365
+ echo '<p>By default, the <code>[s2If]</code> Shortcode is limited to a specific set of Conditional Tags provided by WordPress and the s2Member plugin; e.g. <code>[s2If current_user_can(access_s2member_level1)]</code>; as one quick example. Arbitrary PHP code is NOT allowed with this syntax.</p>'."\n";
366
+ echo '<p>However, a second syntax variation exists; where it IS possible to use arbitrary PHP code (but only if enabled below). The second syntax variation uses one <code>php</code> Shortcode Attribute to run your conditional check; e.g. <code>[s2If php="current_user_can(\'access_s2member_level1\')"]</code>. For developers, this has some obvious advantages. The code inside the <code>php</code> attribute is evaluated at runtime, so it\'s possible to accomplish more when necessary. Of course, you could also use a plugin like <a href="https://www.s2member.com/kb/ezphp-plugin/" target="_blank" rel="external">ezPHP</a> to accomplish the same thing (if you prefer).</p>'."\n";
367
+
368
+ echo '<table class="form-table">'."\n";
369
+ echo '<tbody>'."\n";
370
+ echo '<tr>'."\n";
371
+
372
+ echo '<th>'."\n";
373
+ echo '<label for="ws-plugin--s2member-sc-conds-allow-arbitrary-php">'."\n";
374
+ echo 'Allow Arbitrary PHP Code via the <code>[s2If php=&quot;&quot;]</code> Attribute?'."\n";
375
+ echo '</label>'."\n";
376
+ echo '</th>'."\n";
377
+
378
+ echo '</tr>'."\n";
379
+ echo '<tr>'."\n";
380
+
381
+ echo '<td>'."\n";
382
+ echo '<select name="ws_plugin__s2member_sc_conds_allow_arbitrary_php" id="ws-plugin--s2member-sc-conds-allow-arbitrary-php">'."\n";
383
+ echo '<option value="0"'.((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"]) ? ' selected="selected"' : '').'>No (recommended for best security; e.g. on sites with multiple authors/editors)</option>'."\n";
384
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"]) ? ' selected="selected"' : '').'>Yes (allow me to use PHP via the [s2If php=&quot;&quot;][/s2If] shortcode)</option>'."\n";
385
+ echo '</select>'."\n";
386
+ echo '</td>'."\n";
387
+
388
+ echo '</tr>'."\n";
389
+ echo '</tbody>'."\n";
390
+ echo '</table>'."\n";
391
+ }
392
+ echo '</div>'."\n";
393
+
394
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_conditionals", get_defined_vars());
395
+ }
396
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_sp_access", TRUE, get_defined_vars()))
397
+ {
398
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_sp_access", get_defined_vars());
399
 
400
+ echo '<div class="ws-menu-page-group" title="Specific Post/Page Access Restrictions">'."\n";
401
 
402
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-access-section">'."\n";
403
+ echo '<h3>Specific Post/Page Access Restrictions (optional)</h3>'."\n";
404
+ echo '<p>s2Member now supports an additional layer of functionality <em>(very powerful)</em>, which allows you to sell access to specific Posts/Pages that you\'ve created in WordPress. Specific Post/Page Access works independently from Member Level Access. That is, you can sell an unlimited number of Posts/Pages using "Buy Now" Buttons, and your Customers will NOT be required to have a Membership Account with your site in order to receive access. If they are already a Member, that\'s fine, but they won\'t need to be.</p>'."\n";
405
+ echo '<p>In other words, Customers will NOT need to login, just to receive access to the Specific Post/Page they purchased access to. s2Member will immediately redirect the Customer to the Specific Post/Page after checkout is completed successfully. An email is also sent to the Customer with a link (see: <code>s2Member -› PayPal Options -› Specific Post/Page Email</code>). Authentication is handled automatically through self-expiring links, good for 72 hours by default.</p>'."\n";
406
+ echo '<p>Specific Post/Page Access, is sort of like selling a product. Only, instead of shipping anything to the Customer, you just give them access to a specific Post/Page on your site; one that you created in WordPress. A Specific Post/Page that is protected by s2Member, might contain a download link for your eBook, access to file &amp; music downloads, access to additional support services, and the list goes on and on. The possibilities with this are endless; as long as your digital product can be delivered through access to a WordPress Post/Page that you\'ve created.</p>'."\n";
407
+ echo '<p>Very simple. All you do is protect the Specific Post/Page IDs that are being sold on your site. Then, you can go to <code>s2Member -› PayPal Buttons -› Specific Post/Page</code> to generate "Buy Now" Buttons that you can insert into your WordPress Editor, and make available on your site. The Button Generator for s2Member, will even let you Package Additional Posts/Pages together into one transaction.</p>'."\n";
408
+ echo ((!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) && empty($GLOBALS["WS_PLUGIN__"]["wp_show_ids"])) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post/Page IDs? Get <a href="http://wordpress.org/extend/plugins/wp-show-ids/" target="_blank" rel="external">WP Show IDs</a>.</em></p>'."\n" : '';
409
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_sp_access", get_defined_vars());
410
 
411
+ echo '<table class="form-table">'."\n";
412
+ echo '<tbody>'."\n";
413
+ echo '<tr>'."\n";
414
 
415
+ echo '<th>'."\n";
416
+ echo '<label for="ws-plugin--s2member-specific-ids">'."\n";
417
+ echo 'Specific Post/Page IDs Being Sold On Your Site:'."\n";
418
+ echo '</label>'."\n";
419
+ echo '</th>'."\n";
420
 
421
+ echo '</tr>'."\n";
422
+ echo '<tr>'."\n";
423
 
424
+ echo '<td>'."\n";
425
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_specific_ids" id="ws-plugin--s2member-specific-ids" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"]).'" /><br />'."\n";
426
+ echo 'Post/Page IDs in comma-delimited format. Example: <code>1,2,3,34,8,21</code> * Note... the word <code>all</code> does NOT work here. Also, please be careful not to create a conflict with other Access Restrictions. If you are going to sell Specific Post/Page Access, you should enter specific Post/Page IDs here; and <strong>make SURE that you\'ve NOT already protected any of these Posts/Pages with Member Level Access Restrictions</strong>. In other words, if you configure s2Member, in such as a way, that a Post/Page requires Membership Level Access, you cannot sell that same Post/Page through Specific Post/Page Access. Doing so, would create a conflict. Customers that purchased Specific Post/Page Access, would be unable to access the Post/Page - without also having a Membership. Not good. So please be careful.'."\n";
427
+ echo '</td>'."\n";
428
 
429
+ echo '</tr>'."\n";
430
+ echo '</tbody>'."\n";
431
+ echo '</table>'."\n";
432
+ echo '</div>'."\n";
433
 
434
+ echo '</div>'."\n";
 
 
 
 
 
435
 
436
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_sp_access", get_defined_vars());
437
+ }
438
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_brute_force_restrictions", TRUE, get_defined_vars()))
439
+ {
440
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_brute_force_restrictions", get_defined_vars());
441
+
442
+ echo '<div class="ws-menu-page-group" title="Brute Force IP/Login Restrictions">'."\n";
443
+
444
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-brute-force-restrictions-section">'."\n";
445
+ echo '<h3>Brute Force IP/Login Restrictions (prevents username/password guessing)</h3>'."\n";
446
+ echo '<input type="button" id="ws-plugin--s2member-brute-force-restrictions-reset-button" value="Reset Brute Force Logs" class="ws-menu-page-right" style="min-width:175px;" />'."\n";
447
+ echo '<p>As with any Membership system, it is possible for someone to try and guess Username/Password combinations by attempting a <a href="http://en.wikipedia.org/wiki/Brute-force_attack" target="_blank" rel="external">Brute Force Attack</a>; whereby multiple/repeated logins are strategically attempted with various Username/Password combinations until a correct guess is made. It is NOT likely that you\'ll be attacked in this way, but it\'s still a good idea to protect your system; just in case somebody tries this. s2Member thwarts this behavior by monitoring failed login attempts that occur within a short period of time. Whenever s2Member detects an IP address <em>(i.e. a remote user)</em> that is consistently failing to enter a valid Username/Password, a temporary ban is created; preventing additional attempts from taking place for 30 minutes. This temporary ban, will ONLY affect the offending IP address.</p>'."\n";
448
+ echo '<p><em>*Note* an empty IP address (associated with someone browsing anonymously), is also considered a unique IP address, so it cannot circumvent s2Member\'s security.</em></p>'."\n";
449
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_ip_restrictions", get_defined_vars());
450
+
451
+ echo '<table class="form-table">'."\n";
452
+ echo '<tbody>'."\n";
453
+ echo '<tr>'."\n";
454
+
455
+ echo '<th>'."\n";
456
+ echo '<label for="ws-plugin--s2member-max-failed-login-attempts">'."\n";
457
+ echo 'Maximum Failed Login Attempts:'."\n";
458
+ echo '</label>'."\n";
459
+ echo '</th>'."\n";
460
+
461
+ echo '</tr>'."\n";
462
+ echo '<tr>'."\n";
463
+
464
+ echo '<td>'."\n";
465
+ echo '<select name="ws_plugin__s2member_max_failed_login_attempts" id="ws-plugin--s2member-max-failed-login-attempts">'."\n";
466
+ $ws_plugin__s2member_temp_s = apply_filters("ws_plugin__s2member_track_failed_logins__exp_time", "30 minutes");
467
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 1) ? ' selected="selected"' : '').'>Allow 1 failed login attempt ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
468
+ echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 2) ? ' selected="selected"' : '').'>Allow 2 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
469
+ echo '<option value="3"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 3) ? ' selected="selected"' : '').'>Allow 3 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
470
+ echo '<option value="4"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 4) ? ' selected="selected"' : '').'>Allow 4 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
471
+ echo '<option value="5"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 5) ? ' selected="selected"' : '').'>Allow 5 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
472
+ echo '<option value="10"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 10) ? ' selected="selected"' : '').'>Allow 10 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
473
+ echo '<option value="20"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 20) ? ' selected="selected"' : '').'>Allow 20 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
474
+ echo '<option value="30"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 30) ? ' selected="selected"' : '').'>Allow 30 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
475
+ echo '<option value="40"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 40) ? ' selected="selected"' : '').'>Allow 40 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
476
+ echo '<option value="50"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 50) ? ' selected="selected"' : '').'>Allow 50 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
477
+ echo '<option value="75"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 75) ? ' selected="selected"' : '').'>Allow 75 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
478
+ echo '<option value="100"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 100) ? ' selected="selected"' : '').'>Allow 100 failed login attempts ( then punish for '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
479
+ echo '<option value="0"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"] == 0) ? ' selected="selected"' : '').'>Allow infinite failed logins (Brute Force Restrictions disabled)</option>'."\n";
480
+ echo '</select><br />'."\n";
481
+ echo 'When/if you change this, you should also <strong>Reset Brute Force Logs</strong> (click button above).'."\n";
482
+ echo (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) ? '<br /><br />The default period of "30 minutes" could be modified through this WordPress Filter:<br /><code>ws_plugin__s2member_track_failed_logins__exp_time</code>'."\n" : '';
483
+ echo '</td>'."\n";
484
+
485
+ echo '</tr>'."\n";
486
+ echo '</tbody>'."\n";
487
+ echo '</table>'."\n";
488
+ echo '</div>'."\n";
489
+
490
+ echo '</div>'."\n";
491
+
492
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_ip_restrictions", get_defined_vars());
493
+ }
494
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_ip_restrictions", TRUE, get_defined_vars()))
495
+ {
496
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_ip_restrictions", get_defined_vars());
497
+
498
+ echo '<div class="ws-menu-page-group" title="Unique IP Access Restrictions">'."\n";
499
+
500
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-ip-restrictions-section">'."\n";
501
+ echo '<h3>Unique IP Access Restrictions (prevents username/link sharing)</h3>'."\n";
502
+ echo '<input type="button" id="ws-plugin--s2member-ip-restrictions-reset-button" value="Reset IP Restriction Logs" class="ws-menu-page-right" style="min-width:175px;" />'."\n";
503
+ echo '<p>As with any Membership system, it is possible for one Member to signup, and then share their Username with someone else; or even post it online for the whole world to see. This is known as Link Sharing <em>(aka: Username Sharing)</em>. It is NOT likely that you\'ll be attacked in this way, but it\'s still a good idea to protect your system; just in case somebody tries this. s2Member\'s IP Restrictions work for Membership Level Access <em>(account logins)</em>, Specific Post/Page Access, Registration Links, and other secure Entry Points. In all cases, the rules are simple. A single Username, Access Link, and/or Entry Point ... is only valid for a certain number of unique IP addresses. Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban <em>(preventing access)</em> to a Specific Post/Page, or to an account associated with a particular Username. This temporary ban, will ONLY affect the offending Link and/or Username associated with the security breach. You can fine-tune this behavior, using the options below.</p>'."\n";
504
+ echo '<p><em>*Note* an empty IP address (associated with someone browsing anonymously), is also considered a unique IP address, so it cannot circumvent s2Member\'s security.</em></p>'."\n";
505
+ echo '<p><em><strong>Note:</strong> This feature can work with or without <strong>Simultaneous Login Monitoring</strong> (Simultaneous Login Monitoring is available only in s2Member Pro). You can choose to implement both Unique IP Access Restrictions and Simultaneous Login Monitoring together; or just one of these; or neither of them. It\'s a matter of preference.</em></p>'."\n";
506
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_ip_restrictions", get_defined_vars());
507
+
508
+ echo '<table class="form-table">'."\n";
509
+ echo '<tbody>'."\n";
510
+ echo '<tr>'."\n";
511
+
512
+ echo '<th>'."\n";
513
+ echo '<label for="ws-plugin--s2member-max-ip-restriction">'."\n";
514
+ echo 'Maximum Unique IP Addresses Allowed:'."\n";
515
+ echo '</label>'."\n";
516
+ echo '</th>'."\n";
517
+
518
+ echo '</tr>'."\n";
519
+ echo '<tr>'."\n";
520
+
521
+ echo '<td>'."\n";
522
+ echo '<select name="ws_plugin__s2member_max_ip_restriction" id="ws-plugin--s2member-max-ip-restriction">'."\n";
523
+ $ws_plugin__s2member_temp_s = apply_filters("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
524
+ echo '<option value="1"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 1) ? ' selected="selected"' : '').'>Allow up to 1 unique IP per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
525
+ echo '<option value="2"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 2) ? ' selected="selected"' : '').'>Allow up to 2 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
526
+ echo '<option value="3"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 3) ? ' selected="selected"' : '').'>Allow up to 3 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
527
+ echo '<option value="4"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 4) ? ' selected="selected"' : '').'>Allow up to 4 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
528
+ echo '<option value="5"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 5) ? ' selected="selected"' : '').'>Allow up to 5 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
529
+ echo '<option value="10"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 10) ? ' selected="selected"' : '').'>Allow up to 10 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
530
+ echo '<option value="20"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 20) ? ' selected="selected"' : '').'>Allow up to 20 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
531
+ echo '<option value="30"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 30) ? ' selected="selected"' : '').'>Allow up to 30 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
532
+ echo '<option value="40"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 40) ? ' selected="selected"' : '').'>Allow up to 40 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
533
+ echo '<option value="50"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 50) ? ' selected="selected"' : '').'>Allow up to 50 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
534
+ echo '<option value="75"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 75) ? ' selected="selected"' : '').'>Allow up to 75 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
535
+ echo '<option value="100"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 100) ? ' selected="selected"' : '').'>Allow up to 100 different IPs per Customer ( every '.$ws_plugin__s2member_temp_s.' )</option>'."\n";
536
+ echo '<option value="0"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 0) ? ' selected="selected"' : '').'>Allow infinite IPs (all IP Restrictions are disabled)</option>'."\n";
537
+ echo '</select>'."\n";
538
+ echo (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) ? '<br />The default period of "30 days" could be modified through this WordPress Filter:<br /><code>ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip</code>'."\n" : '';
539
+ echo '</td>'."\n";
540
+
541
+ echo '</tr>'."\n";
542
+ echo '<tr>'."\n";
543
+
544
+ echo '<th>'."\n";
545
+ echo '<label for="ws-plugin--s2member-max-ip-restriction-time">'."\n";
546
+ echo 'Security Breach Timeout Period:'."\n";
547
+ echo '</label>'."\n";
548
+ echo '</th>'."\n";
549
+
550
+ echo '</tr>'."\n";
551
+ echo '<tr>'."\n";
552
+
553
+ echo '<td>'."\n";
554
+ echo '<select name="ws_plugin__s2member_max_ip_restriction_time" id="ws-plugin--s2member-max-ip-restriction-time">'."\n";
555
+ echo '<option value="300"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 300) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 5 mins)</option>'."\n";
556
+ echo '<option value="900"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 900) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 15 mins)</option>'."\n";
557
+ echo '<option value="1800"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1800) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 30 mins)</option>'."\n";
558
+ echo '<option value="3600"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 3600) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 1 hour)</option>'."\n";
559
+ echo '<option value="7200"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7200) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 2 hours)</option>'."\n";
560
+ echo '<option value="14400"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 14400) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 4 hours)</option>'."\n";
561
+ echo '<option value="21600"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 21600) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 6 hours)</option>'."\n";
562
+ echo '<option value="28800"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 28800) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 8 hours)</option>'."\n";
563
+ echo '<option value="43200"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 43200) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 12 hours)</option>'."\n";
564
+ echo '<option value="86400"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 86400) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 24 hours)</option>'."\n";
565
+ echo '<option value="172800"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 172800) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 2 days)</option>'."\n";
566
+ echo '<option value="345600"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 345600) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 4 days)</option>'."\n";
567
+ echo '<option value="604800"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 604800) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 1 week)</option>'."\n";
568
+ echo '<option value="1209600"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1209600) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 2 weeks)</option>'."\n";
569
+ echo '<option value="2629743"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 2629743) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 1 month)</option>'."\n";
570
+ echo '<option value="5259487"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 5259487) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 2 months)</option>'."\n";
571
+ echo '<option value="7889231"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7889231) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 3 months)</option>'."\n";
572
+ echo '<option value="15778463"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 15778463) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 6 months)</option>'."\n";
573
+ echo '<option value="31556926"'.(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 31556926) ? ' selected="selected"' : '').'>If limit is exceeded (punish for 1 year)</option>'."\n";
574
+ echo '</select><br />'."\n";
575
+ echo 'When/if you change this, you should also <strong>Reset IP Restriction Logs</strong> (click button above).'."\n";
576
+ echo '</td>'."\n";
577
+
578
+ echo '</tr>'."\n";
579
+ echo '</tbody>'."\n";
580
+ echo '</table>'."\n";
581
+ echo '</div>'."\n";
582
+
583
+ echo '</div>'."\n";
584
+
585
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_ip_restrictions", get_defined_vars());
586
+ }
587
+ if(apply_filters("ws_plugin__s2member_during_res_ops_page_during_left_sections_display_slogin_restrictions", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars()))
588
+ {
589
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_before_slogin_restrictions", get_defined_vars());
590
+
591
+ echo '<div class="ws-menu-page-group" title="Simultaneous Login Restrictions">'."\n";
592
+
593
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-slogin-restrictions-section">'."\n";
594
+ echo '<h3>Simultaneous Login Restrictions (prevents username sharing)</h3>'."\n";
595
+ echo '<p>As with any Membership system, it is possible for one Member to signup, and then share their Username with someone else; or even post it online for the whole world to see. This is known as Username Sharing. It is NOT likely that you\'ll be attacked in this way, but it\'s not a bad idea to protect your system; just in case somebody tries this.</p>'."\n";
596
+ echo '<p>s2Member\'s Simultaneous Login Monitoring (for Membership Access only); works w/ user account logins <em>(Usernames)</em> to help you prevent a security breach. The rules are simple. A single Username can only have X number of simultaneous logins (as configured below). Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban <em>(preventing access)</em> and the offending Username will be unable to login until somebody else (who is already logged into the account) has logged-out; clearing the way for someone new.</p>'."\n";
597
+ echo '<p>This can be a tricky feature to configure, because not everyone actually clicks the "Logout" link obviously, and so it can be challenging to know when someone is still logged into the site and when they\'re not. s2Member monitors simultaneous logins by updating a timer when someone actually logs in; and then again on each page view while they navigate the site. If there is no activity after X amount of time, s2Member\'s Simultaneous Login Monitor considers that person inactive, and will not include them in security checks until they login again, or visit a new page on the site. You can configure the timeout period below. The default value is <code>30 minutes</code> (we recommend a low value to reduce the chance of error).</p>'."\n";
598
+ echo '<p><em><strong>Note:</strong> This feature can work with or without <strong>Unique IP Access Restrictions</strong> being enabled. You can choose to implement both Unique IP Access Restrictions and Simultaneous Login Monitoring together; or just one of these; or neither of them. It\'s a matter of preference.</em></p>'."\n";
599
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_during_slogin_restrictions", get_defined_vars());
600
+
601
+ echo '<table class="form-table">'."\n";
602
+ echo '<tbody>'."\n";
603
+ echo '<tr>'."\n";
604
+
605
+ echo '<th>'."\n";
606
+ echo '<label for="ws-plugin--s2member-max-simultaneous-logins">'."\n";
607
+ echo 'Max Simultaneous Logins Allowed; for each Username:'."\n";
608
+ echo '</label>'."\n";
609
+ echo '</th>'."\n";
610
+
611
+ echo '</tr>'."\n";
612
+ echo '<tr>'."\n";
613
+
614
+ echo '<td>'."\n";
615
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_max_simultaneous_logins" id="ws-plugin--s2member-max-simultaneous-logins" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_simultaneous_logins"]).'" /><br />'."\n";
616
+ echo 'Examples: <code>0</code> (to disable this functionality), <code>1</code> (maximum of 1 login at a time), <code>2</code>, <code>3</code>, <code>10</code>, <code>20</code>, etc.<br />'."\n";
617
+ echo 'Suggestion: <code>3</code> — the chance to open your site in multiple browsers; but still prevents major security issues.<br />'."\n";
618
+ echo '</td>'."\n";
619
+
620
+ echo '</tr>'."\n";
621
+ echo '<tr>'."\n";
622
+
623
+ echo '<th>'."\n";
624
+ echo '<label for="ws-plugin--s2member-max-simultaneous-logins-timeout">'."\n";
625
+ echo 'Inactivity Timeout Period; this impacts Simultaneous Login Monitoring only.<br />'."\n";
626
+ echo 'Simultaneous Login Monitoring should assume a Username is logged-out after this amount of time:'."\n";
627
+ echo '</label>'."\n";
628
+ echo '</th>'."\n";
629
+
630
+ echo '</tr>'."\n";
631
+ echo '<tr>'."\n";
632
+
633
+ echo '<td>'."\n";
634
+ echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_max_simultaneous_logins_timeout" id="ws-plugin--s2member-max-simultaneous-logins-timeout" value="'.format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_simultaneous_logins_timeout"]).'" /><br />'."\n";
635
+ echo 'Examples: <code>30 minutes</code>, <code>1 hour</code>, <code>2 hours</code>; anything compatible with PHP\'s <a href="http://php.net/manual/en/function.strtotime.php" target="_blank" rel="external">strtotime()</a>.<br />'."\n";
636
+ echo 'Recommended Setting: <code>30 minutes</code>; if they stop browsing the site, they\'re considered inactive.<br />'."\n";
637
+ echo '</td>'."\n";
638
+
639
+ echo '</tr>'."\n";
640
+ echo '</tbody>'."\n";
641
+ echo '</table>'."\n";
642
+ echo '</div>'."\n";
643
+
644
+ echo '</div>'."\n";
645
+
646
+ do_action("ws_plugin__s2member_during_res_ops_page_during_left_sections_after_slogin_restrictions", get_defined_vars());
647
+ }
648
+ do_action("ws_plugin__s2member_during_res_ops_page_after_left_sections", get_defined_vars());
649
 
650
+ echo '<div class="ws-menu-page-hr"></div>'."\n";
 
 
651
 
652
+ echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>'."\n";
 
 
 
 
653
 
654
+ echo '</form>'."\n";
 
655
 
656
+ echo '</td>'."\n";
 
 
 
 
 
 
 
 
 
 
657
 
658
+ echo '<td class="ws-menu-page-table-r">'."\n";
659
+ c_ws_plugin__s2member_menu_pages_rs::display();
660
+ echo '</td>'."\n";
 
 
 
 
 
661
 
662
+ echo '</tr>'."\n";
663
+ echo '</tbody>'."\n";
664
+ echo '</table>'."\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
 
666
+ echo '</div>'."\n";
667
+ }
 
668
  }
669
+ }
670
+ new c_ws_plugin__s2member_menu_page_res_ops ();
 
includes/menu-pages/trk-ops.inc.php CHANGED
@@ -57,10 +57,10 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
57
  echo '<div class="ws-menu-page-section ws-plugin--s2member-signup-tracking-section">' . "\n";
58
  echo '<h3>Signup Tracking Codes (optional)</h3>' . "\n";
59
  echo '<p>If you use affiliate software, a list server, tracking codes from advertising networks, or the like; you\'ll want to read this section. The HTML' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' and/or PHP') . ' code that you enter below, will be loaded up in a web browser, after a "new", "paying" Member completes Signup through your Payment Gateway. This is marked `Signup`, because Signup Tracking Codes will be displayed each time a "new", "paying" Member signs up. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
60
- echo '<p>Signup Tracking Codes will only be displayed once for each Member. Signup Tracking Codes are displayed right after a "new", "paying" Member signs up successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, Signup Tracking Codes are displayed anytime a "new", "paying" Member signs up; even if you provided them with something 100% free <em>(e.g. even if no money is being transacted)</em>.</p>' . "\n";
61
  echo '<p>s2Member will display your Signup Tracking Codes in one of four possible locations... <strong>1.</strong> If possible, on the Thank-You Return Page, after returning from your Payment Gateway. <strong>2.</strong> Otherwise, if possible, on the Registration Form; after returning from your Payment Gateway. <em>Note. If you offer a 100% free Trial Period, Tracking Codes will be displayed in location #2 when using PayPal Standard Button integration.</em> <strong>3.</strong> Otherwise, if possible, on the Login Form after Registration is completed. <strong>4.</strong> Otherwise, in the footer of your WordPress theme, as soon as possible <em>(immediately with s2Member Pro Form integration)</em>; or after the Customer\'s very first login.</p>' . "\n";
62
  echo '<p>Signup Tracking Codes are displayed for all types of Membership Level Access. Including Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Non-Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Lifetime Subscriptions, and even Fixed-Term Subscriptions. All of these are supported by s2Member\'s Button/Form Generators.</p>' . "\n";
63
- echo '<p>Signup Tracking Codes will NOT be processed for Free Subscribers that register without going through your Payment Gateway at all (e.g. they simply register on-site; and there is no checkout whatsoever). Signup Tracking Codes will NOT be processed when an "existing" User/Member pays for a new Subscription <em>(see: Modification Tracking Codes for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, Signup Tracking Codes will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Capability Tracking Codes for that scenario)</em>.') . '</p>' . "\n";
64
  echo '<p><em><strong>AD BLOCKERS:</strong> If a web browser has ad blockers enabled (i.e. the web browser has an ad blocking extension or add-on), Tracking Codes from popular online advertising companies (including many affiliate networks) may NOT be shown. Ad blockers can prevent your Tracking Codes from being loaded in a customer\'s browser. If you\'d like to avoid this problem, consider integrating with s2Member\'s API Notifications instead of with Tracking Codes. API Notifications occur silently behind-the-scene (more reliably), whereas Tracking Codes are loaded in a customer\'s browser. For more information, please see: <code>s2Member -› API / Notifications</code>.</em></p>' . "\n";
65
  do_action("ws_plugin__s2member_during_trk_ops_page_during_left_sections_during_signup_tracking", get_defined_vars ());
66
 
@@ -103,7 +103,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
103
  {
104
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
105
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
106
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
107
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
108
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
109
  echo '</ul>' . "\n";
@@ -142,7 +142,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
142
  echo '<div class="ws-menu-page-section ws-plugin--s2member-modification-tracking-section">' . "\n";
143
  echo '<h3>Modification Tracking Codes (optional)</h3>' . "\n";
144
  echo '<p>If you use affiliate software, a list server, tracking codes from advertising networks, or the like; you\'ll want to read this section. The HTML' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' and/or PHP') . ' code that you enter below, will be loaded up in a web browser, each time a Subscription Modification occurs. This is marked `Modification`, because Modification Tracking Codes are displayed each time an "existing" User/Member <em>(even if they are/were a Free Subscriber)</em> signs up for a paid Subscription <em>(i.e. a Modification takes place against an existing account within WordPress)</em>, or an "existing" Member modifies their paid Subscription terms <em>(again, a Modification takes places against an existing account within WordPress)</em>. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
145
- echo '<p>Modification Tracking Codes are displayed right after a Member signs up and/or modifies billing terms successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, Modification Tracking Codes are displayed even if you provided them with something for free <em>(e.g. even if no money is being transacted)</em>.</p>' . "\n";
146
  echo '<p>s2Member will display your Modification Tracking Codes in one of three possible locations... <strong>1.</strong> If possible, on the Thank-You Return Page, after returning from your Payment Gateway. <strong>2.</strong> Otherwise, if possible, on the Login Form after returning from your Payment Gateway <em>(i.e. when the Customer is asked to log back in)</em>. <strong>3.</strong> Otherwise, in the footer of your WordPress theme, as soon as possible <em>(immediately with s2Member Pro Form integration)</em>; or after the Customer\'s next login.</p>' . "\n";
147
  echo '<p>Modification Tracking Codes are displayed for all types of Membership Level Access. Including Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Non-Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Lifetime Subscriptions, and even Fixed-Term Subscriptions. All of these are supported by s2Member\'s Button/Form Generators.</p>' . "\n";
148
  echo '<p>Modification Tracking Codes will NOT be processed when a "new" User/Member signs up <em>(see: Signup Tracking Codes for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, Modification Tracking Codes will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Capability Tracking Codes for that scenario)</em>.') . '</p>' . "\n";
@@ -194,7 +194,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
194
  {
195
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
196
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
197
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
198
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
199
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
200
  echo '</ul>' . "\n";
@@ -285,7 +285,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
285
  {
286
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
287
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
288
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
289
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
290
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
291
  echo '</ul>' . "\n";
@@ -369,7 +369,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_page_trk_ops"))
369
  {
370
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
371
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
372
- echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (e.g. the full Coupon Code).</li>' . "\n";
373
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
374
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
375
  echo '</ul>' . "\n";
57
  echo '<div class="ws-menu-page-section ws-plugin--s2member-signup-tracking-section">' . "\n";
58
  echo '<h3>Signup Tracking Codes (optional)</h3>' . "\n";
59
  echo '<p>If you use affiliate software, a list server, tracking codes from advertising networks, or the like; you\'ll want to read this section. The HTML' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' and/or PHP') . ' code that you enter below, will be loaded up in a web browser, after a "new", "paying" Member completes Signup through your Payment Gateway. This is marked `Signup`, because Signup Tracking Codes will be displayed each time a "new", "paying" Member signs up. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
60
+ echo '<p>Signup Tracking Codes will only be displayed once for each Member. Signup Tracking Codes are displayed right after a "new", "paying" Member signs up successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, Signup Tracking Codes are displayed anytime a "new", "paying" Member signs up; even if you provided them with something 100% free <em>(i.e. even if no money is being transacted)</em>.</p>' . "\n";
61
  echo '<p>s2Member will display your Signup Tracking Codes in one of four possible locations... <strong>1.</strong> If possible, on the Thank-You Return Page, after returning from your Payment Gateway. <strong>2.</strong> Otherwise, if possible, on the Registration Form; after returning from your Payment Gateway. <em>Note. If you offer a 100% free Trial Period, Tracking Codes will be displayed in location #2 when using PayPal Standard Button integration.</em> <strong>3.</strong> Otherwise, if possible, on the Login Form after Registration is completed. <strong>4.</strong> Otherwise, in the footer of your WordPress theme, as soon as possible <em>(immediately with s2Member Pro Form integration)</em>; or after the Customer\'s very first login.</p>' . "\n";
62
  echo '<p>Signup Tracking Codes are displayed for all types of Membership Level Access. Including Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Non-Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Lifetime Subscriptions, and even Fixed-Term Subscriptions. All of these are supported by s2Member\'s Button/Form Generators.</p>' . "\n";
63
+ echo '<p>Signup Tracking Codes will NOT be processed for Free Subscribers that register without going through your Payment Gateway at all (i.e. they simply register on-site; and there is no checkout whatsoever). Signup Tracking Codes will NOT be processed when an "existing" User/Member pays for a new Subscription <em>(see: Modification Tracking Codes for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, Signup Tracking Codes will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Capability Tracking Codes for that scenario)</em>.') . '</p>' . "\n";
64
  echo '<p><em><strong>AD BLOCKERS:</strong> If a web browser has ad blockers enabled (i.e. the web browser has an ad blocking extension or add-on), Tracking Codes from popular online advertising companies (including many affiliate networks) may NOT be shown. Ad blockers can prevent your Tracking Codes from being loaded in a customer\'s browser. If you\'d like to avoid this problem, consider integrating with s2Member\'s API Notifications instead of with Tracking Codes. API Notifications occur silently behind-the-scene (more reliably), whereas Tracking Codes are loaded in a customer\'s browser. For more information, please see: <code>s2Member -› API / Notifications</code>.</em></p>' . "\n";
65
  do_action("ws_plugin__s2member_during_trk_ops_page_during_left_sections_during_signup_tracking", get_defined_vars ());
66
 
103
  {
104
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
105
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
106
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
107
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
108
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
109
  echo '</ul>' . "\n";
142
  echo '<div class="ws-menu-page-section ws-plugin--s2member-modification-tracking-section">' . "\n";
143
  echo '<h3>Modification Tracking Codes (optional)</h3>' . "\n";
144
  echo '<p>If you use affiliate software, a list server, tracking codes from advertising networks, or the like; you\'ll want to read this section. The HTML' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' and/or PHP') . ' code that you enter below, will be loaded up in a web browser, each time a Subscription Modification occurs. This is marked `Modification`, because Modification Tracking Codes are displayed each time an "existing" User/Member <em>(even if they are/were a Free Subscriber)</em> signs up for a paid Subscription <em>(i.e. a Modification takes place against an existing account within WordPress)</em>, or an "existing" Member modifies their paid Subscription terms <em>(again, a Modification takes places against an existing account within WordPress)</em>. Depending on your fee structure, this may include a payment that establishes their Subscription, or it may not.</p>' . "\n";
145
+ echo '<p>Modification Tracking Codes are displayed right after a Member signs up and/or modifies billing terms successfully through your Payment Gateway, regardless of whether any money has actually been transacted. In other words, Modification Tracking Codes are displayed even if you provided them with something for free <em>(i.e. even if no money is being transacted)</em>.</p>' . "\n";
146
  echo '<p>s2Member will display your Modification Tracking Codes in one of three possible locations... <strong>1.</strong> If possible, on the Thank-You Return Page, after returning from your Payment Gateway. <strong>2.</strong> Otherwise, if possible, on the Login Form after returning from your Payment Gateway <em>(i.e. when the Customer is asked to log back in)</em>. <strong>3.</strong> Otherwise, in the footer of your WordPress theme, as soon as possible <em>(immediately with s2Member Pro Form integration)</em>; or after the Customer\'s next login.</p>' . "\n";
147
  echo '<p>Modification Tracking Codes are displayed for all types of Membership Level Access. Including Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Non-Recurring Subscriptions <em>(with or without a Free Trial Period)</em>, Lifetime Subscriptions, and even Fixed-Term Subscriptions. All of these are supported by s2Member\'s Button/Form Generators.</p>' . "\n";
148
  echo '<p>Modification Tracking Codes will NOT be processed when a "new" User/Member signs up <em>(see: Signup Tracking Codes for that scenario)</em>.' . ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) ? '' : ' And, Modification Tracking Codes will NOT be processed on Buy Now transactions for Independent Custom Capabilities <em>(see: Capability Tracking Codes for that scenario)</em>.') . '</p>' . "\n";
194
  {
195
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
196
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
197
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
198
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
199
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
200
  echo '</ul>' . "\n";
285
  {
286
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
287
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
288
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
289
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
290
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
291
  echo '</ul>' . "\n";
369
  {
370
  echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro Forms):</strong>' . "\n";
371
  echo '<ul class="ws-menu-page-li-margins">' . "\n";
372
+ echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code — if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e. the full Coupon Code).</li>' . "\n";
373
  echo '<li><code>%%coupon_code%%</code> = A Coupon Code — if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
374
  echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e. the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
375
  echo '</ul>' . "\n";
includes/s2member-min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(d){window.ws_plugin__s2member_skip_all_file_confirmations=window.ws_plugin__s2member_skip_all_file_confirmations||false;var c='<?php echo c_ws_plugin__s2member_utils_conds::bp_is_installed("query-active-plugins") ? "1" : ""; ?>',a='<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])); ?>',b=ws_plugin__s2member_skip_all_file_confirmations?true:false,e=[];if(!b&&S2MEMBER_CURRENT_USER_IS_LOGGED_IN&&S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY<S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED){d('a[href*="s2member_file_download="], a[href*="/s2member-files/"], a[href^="s2member-files/"], a[href*="/'+a.replace(/([\:\.\[\]])/g,"\\$1")+'/"], a[href^="'+a.replace(/([\:\.\[\]])/g,"\\$1")+'/"]').click(function(){if(!/s2member[_\-]file[_\-]download[_\-]key[\=\-].+/i.test(this.href)){var f='<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Confirm File Download —", "s2member-front", "s2member")); ?>\n\n';f+=d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`ve downloaded %s protected %s in the last %s.", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY,((S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("file", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("files", "s2member-front", "s2member")); ?>'),((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("24 hours", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("%s days", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS)))+"\n\n";f+=(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`re entitled to UNLIMITED downloads though (so, no worries).", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`re entitled to %s unique %s %s.", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED,((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("download", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("downloads", "s2member-front", "s2member")); ?>'),((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("each day", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("every %s-day period", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS)));if((/s2member[_\-]skip[_\-]confirmation/i.test(this.href)&&!/s2member[_\-]skip[_\-]confirmation[\=\-](0|no|false)/i.test(this.href))||confirm(f)){if(d.inArray(this.href,e)===-1){S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY++,e.push(this.href)}return true}return false}return true})}if(!/\/wp-admin([\/?#]|$)/.test(location.href)){d("input#ws-plugin--s2member-profile-password1, input#ws-plugin--s2member-profile-password2").keyup(function(){ws_plugin__s2member_passwordStrength(d("input#ws-plugin--s2member-profile-login"),d("input#ws-plugin--s2member-profile-password1"),d("input#ws-plugin--s2member-profile-password2"),d("div#ws-plugin--s2member-profile-password-strength"))});d("form#ws-plugin--s2member-profile").submit(function(){var h=this,g="",f="",l="",j=d("input#ws-plugin--s2member-profile-password1",h),i=d("input#ws-plugin--s2member-profile-password2",h);var k=d("input#ws-plugin--s2member-profile-submit",h);d(":input",h).each(function(){var m=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(m&&(g=d.trim(d('label[for="'+m+'"]',h).first().children("strong").first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}});if(l=d.trim(l)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+l);return false}else{if(d.trim(j.val())&&d.trim(j.val())!==d.trim(i.val())){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');return false}else{if(d.trim(j.val())&&d.trim(j.val()).length<6){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');return false}}}ws_plugin__s2member_animateProcessing(k);return true})}if(/\/wp-signup\.php/.test(location.href)){d("div#content > div.mu_register > form#setupform").submit(function(){var h=this,g="",f="",j="",i=d('p.submit input[type="submit"]',h);d("input#user_email",h).attr("data-expected","email");d("input#user_name, input#user_email, input#blogname, input#blog_title, input#captcha_code",h).attr({"aria-required":"true"});d(":input",h).each(function(){var k=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(k&&(g=d.trim(d('label[for="'+k+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){j+=f+"\n\n"}}});if(j=d.trim(j)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+j);return false}ws_plugin__s2member_animateProcessing(i);return true})}if(/\/wp-login\.php/.test(location.href)){d("div#login > form#registerform input#user_login").attr("tabindex","10");d("div#login > form#registerform input#user_email").attr("tabindex","20");d("div#login > form#registerform input#wp-submit").attr("tabindex","1000");d("input#ws-plugin--s2member-custom-reg-field-user-pass1, input#ws-plugin--s2member-custom-reg-field-user-pass2").keyup(function(){ws_plugin__s2member_passwordStrength(d("input#user_login"),d("input#ws-plugin--s2member-custom-reg-field-user-pass1"),d("input#ws-plugin--s2member-custom-reg-field-user-pass2"),d("div#ws-plugin--s2member-custom-reg-field-user-pass-strength"))});d("div#login > form#registerform").submit(function(){var h=this,g="",f="",l="",k=d('input#ws-plugin--s2member-custom-reg-field-user-pass1[aria-required="true"]',h),i=d("input#ws-plugin--s2member-custom-reg-field-user-pass2",h),j=d("input#wp-submit",h);d("input#user_email",h).attr("data-expected","email");d("input#user_login, input#user_email, input#captcha_code",h).attr({"aria-required":"true"});d(":input",h).each(function(){var m=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(d.inArray(m,["user_login","user_email","captcha_code"])!==-1){if((g=d.trim(d(this).parent("label").text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}}else{if(m&&(g=d.trim(d('label[for="'+m+'"]',h).first().children("span").first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}}});if(l=d.trim(l)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+l);return false}else{if(k.length&&d.trim(k.val())!==d.trim(i.val())){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');return false}else{if(k.length&&d.trim(k.val()).length<6){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');return false}}}ws_plugin__s2member_animateProcessing(j);return true})}if(/\/wp-admin\/(?:user\/)?profile\.php/.test(location.href)){d("form#your-profile").submit(function(){var h=this,g="",f="",i="";d("input#email",h).attr("data-expected","email");d(':input[id^="ws-plugin--s2member-profile-"]',h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true})}if(c){d("body.registration form div#ws-plugin--s2member-custom-reg-fields-4bp-section").closest("form").submit(function(){var h=this,g="",f="",i="";d("input#signup_email",h).attr("data-expected","email");d("input#signup_username, input#signup_email, input#signup_password, input#field_1",h).attr({"aria-required":"true"});d(":input",h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true});d("body.logged-in.profile.profile-edit :input.ws-plugin--s2member-profile-field-4bp").closest("form").submit(function(){var h=this,g="",f="",i="";d("input#field_1",h).attr({"aria-required":"true"});d(":input",h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true})}window.ws_plugin__s2member_passwordStrengthMeter=function(h,f){var g=0;if((h!=f)&&f.length>0){return"mismatch"}else{if(h.length<1){return"empty"}else{if(h.length<6){return"short"}}}if(h.match(/[0-9]/)){g+=10}if(h.match(/[a-z]/)){g+=10}if(h.match(/[A-Z]/)){g+=10}if(h.match(/[^0-9a-zA-Z]/)){g=(g===30)?g+20:g+10}if(g<30){return"bad"}if(g<50){return"good"}return"strong"};window.ws_plugin__s2member_passwordStrength=function(h,k,i,g){if(h instanceof jQuery&&k instanceof jQuery&&i instanceof jQuery&&g instanceof jQuery){var j={empty:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Strength indicator", "s2member-front", "s2member")); ?>',"short":'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Very weak", "s2member-front", "s2member")); ?>',bad:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Weak", "s2member-front", "s2member")); ?>',good:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Medium", "s2member-front", "s2member")); ?>',strong:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Strong", "s2member-front", "s2member")); ?>',mismatch:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Mismatch", "s2member-front", "s2member")); ?>'};g.removeClass("ws-plugin--s2member-password-strength-short");g.removeClass("ws-plugin--s2member-password-strength-bad");g.removeClass("ws-plugin--s2member-password-strength-good");g.removeClass("ws-plugin--s2member-password-strength-strong");g.removeClass("ws-plugin--s2member-password-strength-mismatch");g.removeClass("ws-plugin--s2member-password-strength-empty");var f=ws_plugin__s2member_passwordStrengthMeter(k.val(),i.val());g.addClass("ws-plugin--s2member-password-strength-"+f).html(j[f])}};window.ws_plugin__s2member_validationErrors=function(r,q,g,m,l){if(typeof r==="string"&&r&&typeof q==="object"&&typeof g==="object"){if(typeof q.tagName==="string"&&/^(input|textarea|select)$/i.test(q.tagName)&&!q.disabled){var t=q.tagName.toLowerCase(),p=d(q),o=d.trim(p.attr("type")).toLowerCase(),f=d.trim(p.attr("name")),s=p.val();m=(typeof m==="boolean")?m:(p.attr("aria-required")==="true"),l=(typeof l==="string")?l:d.trim(p.attr("data-expected"));var k=('<?php echo strlen($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"]); ?>'>0);var i=new RegExp('^(<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (implode ("|", preg_split ("/[\r\n\t ;,]+/", preg_quote ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"], "/")))); ?>)@',"i");if(t==="input"&&o==="checkbox"&&/\[\]$/.test(f)){if(typeof q.id==="string"&&/-0$/.test(q.id)){if(m&&!d('input[name="'+ws_plugin__s2member_escjQAttr(f)+'"]:checked',g).length){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please check at least one of the boxes.", "s2member-front", "s2member")); ?>'}}}else{if(t==="input"&&o==="checkbox"){if(m&&!q.checked){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Required. This box must be checked.", "s2member-front", "s2member")); ?>'}}else{if(t==="input"&&o==="radio"){if(typeof q.id==="string"&&/-0$/.test(q.id)){if(m&&!d('input[name="'+ws_plugin__s2member_escjQAttr(f)+'"]:checked',g).length){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please select one of the options.", "s2member-front", "s2member")); ?>'}}}else{if(t==="select"&&p.attr("multiple")){if(m&&(!(s instanceof Array)||!s.length)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please select at least one of the options.", "s2member-front", "s2member")); ?>'}}else{if(typeof s!=="string"||(m&&!(s=d.trim(s)).length)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("This is a required field, please try again.", "s2member-front", "s2member")); ?>'}else{if((s=d.trim(s)).length&&((t==="input"&&/^(text|password)$/i.test(o))||t==="textarea")&&typeof l==="string"&&l.length){if(l==="numeric-wp-commas"&&(!/^[0-9\.,]+$/.test(s)||isNaN(s.replace(/,/g,"")))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be numeric (with or without decimals, commas allowed).", "s2member-front", "s2member")); ?>'}else{if(l==="numeric"&&(!/^[0-9\.]+$/.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be numeric (with or without decimals, no commas).", "s2member-front", "s2member")); ?>'}else{if(l==="integer"&&(!/^[0-9]+$/.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be an integer (a whole number, without any decimals).", "s2member-front", "s2member")); ?>'}else{if(l==="integer-gt-0"&&(!/^[0-9]+$/.test(s)||isNaN(s)||s<=0)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be an integer > 0 (whole number, no decimals, greater than 0).", "s2member-front", "s2member")); ?>'}else{if(l==="float"&&(!/^[0-9\.]+$/.test(s)||!/[0-9]/.test(s)||!/\./.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a float (floating point number, decimals required).", "s2member-front", "s2member")); ?>'}else{if(l==="float-gt-0"&&(!/^[0-9\.]+$/.test(s)||!/[0-9]/.test(s)||!/\./.test(s)||isNaN(s)||s<=0)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a float > 0 (floating point number, decimals required, greater than 0).", "s2member-front", "s2member")); ?>'}else{if(l==="date"&&!/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a date (required date format: dd/mm/yyyy).", "s2member-front", "s2member")); ?>'}else{if(l==="email"&&!/^[a-zA-Z0-9_!#$%&*+=?`{}~|\/\^\'\-]+(?:\.?[a-zA-Z0-9_!#$%&*+=?`{}~|\/\^\'\-]+)*@[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*)*(?:\.[a-zA-Z][a-zA-Z0-9]+)?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a valid email address.", "s2member-front", "s2member")); ?>'}else{if(l==="email"&&k&&i.test(s)){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use a personal email address.\nAddresses like <%s@> are problematic.", "s2member-front", "s2member")); ?>',s.split("@")[0])}else{if(l==="url"&&!/^https?\:\/\/.+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a full URL (starting with http or https).", "s2member-front", "s2member")); ?>'}else{if(l==="domain"&&!/^[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*)*(?:\.[a-zA-Z][a-zA-Z0-9]+)?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a domain name (domain name only, without http).", "s2member-front", "s2member")); ?>'}else{if(l==="phone"&&(!/^[0-9 ()\-]+$/.test(s)||s.replace(/[^0-9]+/g,"").length!==10)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a phone # (10 digits w/possible hyphens, spaces, brackets).", "s2member-front", "s2member")); ?>'}else{if(l==="uszip"&&!/^[0-9]{5}(?:\-[0-9]{4})?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a US zipcode (5-9 digits w/ possible hyphen).", "s2member-front", "s2member")); ?>'}else{if(l==="cazip"&&!/^[0-9A-Z]{3} ?[0-9A-Z]{3}$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a Canadian zipcode (6 alpha-numerics w/possible space).", "s2member-front", "s2member")); ?>'}else{if(l==="uczip"&&!/^[0-9]{5}(?:\-[0-9]{4})?$/.test(s)&&!/^[0-9A-Z]{3} ?[0-9A-Z]{3}$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a zipcode (either a US or Canadian zipcode).", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-spaces\-punctuation\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z 0-9\/\\\\,.?:;"\'{}[\]\^|+=_()*&%$#@!`~\-]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics, spaces & punctuation only.", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-spaces\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z 0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics & spaces only.", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-punctuation\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z0-9\/\\\\,.?:;"\'{}[\]\^|+=_()*&%$#@!`~\-]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics & punctuation only (no spaces).", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics only (no spaces/punctuation).", "s2member-front", "s2member")); ?>'}else{if(/^alphabetics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphabetics only (no digits/spaces/punctuation).", "s2member-front", "s2member")); ?>'}else{if(/^numerics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use numeric digits only.", "s2member-front", "s2member")); ?>'}else{if(/^(?:any|alphanumerics\-spaces\-punctuation|alphanumerics\-spaces|alphanumerics\-punctuation|alphanumerics|alphabetics|numerics)\-[0-9]+(?:\-e)?$/.test(l)){var n=l.split("-"),h=Number(n[1]),j=(n.length>2&&n[2]==="e");if(j&&s.length!==h){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be exactly %s %s.", "s2member-front", "s2member")); ?>',h,((n[0]==="numerics")?((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digit", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digits", "s2member-front", "s2member")); ?>'):((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("character", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("characters", "s2member-front", "s2member")); ?>')))}else{if(s.length<h){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be at least %s %s.", "s2member-front", "s2member")); ?>',h,((n[0]==="numerics")?((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digit", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digits", "s2member-front", "s2member")); ?>'):((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("character", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("characters", "s2member-front", "s2member")); ?>')))}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}return""};window.ws_plugin__s2member_animateProcessing=function(g,f){if(f){d(g).removeClass("ws-plugin--s2member-animate-processing")}else{d(g).addClass("ws-plugin--s2member-animate-processing")}};window.ws_plugin__s2member_escAttr=window.ws_plugin__s2member_escHtml=function(f){if(/[&\<\>"']/.test(f=String(f))){f=f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),f=f.replace(/"/g,"&quot;").replace(/'/g,"&#039;")}return f};window.ws_plugin__s2member_escjQAttr=function(f){return String(f).replace(/([.:\[\]])/g,"\\$1")}});
1
+ jQuery(document).ready(function(d){window.ws_plugin__s2member_skip_all_file_confirmations=window.ws_plugin__s2member_skip_all_file_confirmations||false;var c='<?php echo c_ws_plugin__s2member_utils_conds::bp_is_installed("query-active-plugins") ? "1" : ""; ?>',a='<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])); ?>',b=ws_plugin__s2member_skip_all_file_confirmations?true:false,e=[];if(!b&&S2MEMBER_CURRENT_USER_IS_LOGGED_IN&&S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY<S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED){d('a[href*="s2member_file_download="], a[href*="/s2member-files/"], a[href^="s2member-files/"], a[href*="/'+a.replace(/([\:\.\[\]])/g,"\\$1")+'/"], a[href^="'+a.replace(/([\:\.\[\]])/g,"\\$1")+'/"]').click(function(){if(!/s2member[_\-]file[_\-]download[_\-]key[\=\-].+/i.test(this.href)){var f='<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Confirm File Download —", "s2member-front", "s2member")); ?>\n\n';f+=d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`ve downloaded %s protected %s in the last %s.", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY,((S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("file", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("files", "s2member-front", "s2member")); ?>'),((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("24 hours", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("%s days", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS)))+"\n\n";f+=(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`re entitled to UNLIMITED downloads though (so, no worries).", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("You`re entitled to %s unique %s %s.", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED,((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("download", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("downloads", "s2member-front", "s2member")); ?>'),((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("each day", "s2member-front", "s2member")); ?>':d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("every %s-day period", "s2member-front", "s2member")); ?>',S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS)));if((/s2member[_\-]skip[_\-]confirmation/i.test(this.href)&&!/s2member[_\-]skip[_\-]confirmation[\=\-](0|no|false)/i.test(this.href))||confirm(f)){if(d.inArray(this.href,e)===-1){S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY++,e.push(this.href)}return true}return false}return true})}if(!/\/wp-admin([\/?#]|$)/i.test(location.href)){d("input#ws-plugin--s2member-profile-password1, input#ws-plugin--s2member-profile-password2").keyup(function(){ws_plugin__s2member_passwordStrength(d("input#ws-plugin--s2member-profile-login"),d("input#ws-plugin--s2member-profile-password1"),d("input#ws-plugin--s2member-profile-password2"),d("div#ws-plugin--s2member-profile-password-strength"))});d("form#ws-plugin--s2member-profile").submit(function(){var h=this,g="",f="",l="",j=d("input#ws-plugin--s2member-profile-password1",h),i=d("input#ws-plugin--s2member-profile-password2",h);var k=d("input#ws-plugin--s2member-profile-submit",h);d(":input",h).each(function(){var m=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(m&&(g=d.trim(d('label[for="'+m+'"]',h).first().children("strong").first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}});if(l=d.trim(l)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+l);return false}else{if(d.trim(j.val())&&d.trim(j.val())!==d.trim(i.val())){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');return false}else{if(d.trim(j.val())&&d.trim(j.val()).length<6){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');return false}}}ws_plugin__s2member_animateProcessing(k);return true})}if(/\/wp-signup\.php/i.test(location.href)){d("div#content > div.mu_register > form#setupform").submit(function(){var h=this,g="",f="",j="",i=d('p.submit input[type="submit"]',h);d("input#user_email",h).attr("data-expected","email");d("input#user_name, input#user_email, input#blogname, input#blog_title, input#captcha_code",h).attr({"aria-required":"true"});d(":input",h).each(function(){var k=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(k&&(g=d.trim(d('label[for="'+k+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){j+=f+"\n\n"}}});if(j=d.trim(j)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+j);return false}ws_plugin__s2member_animateProcessing(i);return true})}if(/\/wp-login\.php/i.test(location.href)){d("div#login > form#registerform input#user_login").attr("tabindex","10");d("div#login > form#registerform input#user_email").attr("tabindex","20");d("div#login > form#registerform input#wp-submit").attr("tabindex","1000");d("input#ws-plugin--s2member-custom-reg-field-user-pass1, input#ws-plugin--s2member-custom-reg-field-user-pass2").keyup(function(){ws_plugin__s2member_passwordStrength(d("input#user_login"),d("input#ws-plugin--s2member-custom-reg-field-user-pass1"),d("input#ws-plugin--s2member-custom-reg-field-user-pass2"),d("div#ws-plugin--s2member-custom-reg-field-user-pass-strength"))});d("div#login > form#registerform").submit(function(){var h=this,g="",f="",l="",k=d('input#ws-plugin--s2member-custom-reg-field-user-pass1[aria-required="true"]',h),i=d("input#ws-plugin--s2member-custom-reg-field-user-pass2",h),j=d("input#wp-submit",h);d("input#user_email",h).attr("data-expected","email");d("input#user_login, input#user_email, input#captcha_code",h).attr({"aria-required":"true"});d(":input",h).each(function(){var m=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(d.inArray(m,["user_login","user_email","captcha_code"])!==-1){if((g=d.trim(d(this).parent("label").text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}}else{if(m&&(g=d.trim(d('label[for="'+m+'"]',h).first().children("span").first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){l+=f+"\n\n"}}}});if(l=d.trim(l)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+l);return false}else{if(k.length&&d.trim(k.val())!==d.trim(i.val())){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');return false}else{if(k.length&&d.trim(k.val()).length<6){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');return false}}}ws_plugin__s2member_animateProcessing(j);return true})}if(/\/wp-admin\/(?:user\/)?profile\.php/i.test(location.href)){d("form#your-profile").submit(function(){var h=this,g="",f="",i="";d("input#email",h).attr("data-expected","email");d(':input[id^="ws-plugin--s2member-profile-"]',h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true})}if(c){d("body.registration form div#ws-plugin--s2member-custom-reg-fields-4bp-section").closest("form").submit(function(){var h=this,g="",f="",i="";d("input#signup_email",h).attr("data-expected","email");d("input#signup_username, input#signup_email, input#signup_password, input#field_1",h).attr({"aria-required":"true"});d(":input",h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true});d("body.logged-in.profile.profile-edit :input.ws-plugin--s2member-profile-field-4bp").closest("form").submit(function(){var h=this,g="",f="",i="";d("input#field_1",h).attr({"aria-required":"true"});d(":input",h).each(function(){var j=d.trim(d(this).attr("id")).replace(/---[0-9]+$/g,"");if(j&&(g=d.trim(d('label[for="'+j+'"]',h).first().text().replace(/[\r\n\t]+/g," ")))){if(f=ws_plugin__s2member_validationErrors(g,this,h)){i+=f+"\n\n"}}});if(i=d.trim(i)){alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("— Oops, you missed something: —", "s2member-front", "s2member")); ?>\n\n'+i);return false}return true})}window.ws_plugin__s2member_passwordStrengthMeter=function(h,f){var g=0;if((h!=f)&&f.length>0){return"mismatch"}else{if(h.length<1){return"empty"}else{if(h.length<6){return"short"}}}if(h.match(/[0-9]/)){g+=10}if(h.match(/[a-z]/)){g+=10}if(h.match(/[A-Z]/)){g+=10}if(h.match(/[^0-9a-zA-Z]/)){g=(g===30)?g+20:g+10}if(g<30){return"bad"}if(g<50){return"good"}return"strong"};window.ws_plugin__s2member_passwordStrength=function(h,k,i,g){if(h instanceof jQuery&&k instanceof jQuery&&i instanceof jQuery&&g instanceof jQuery){var j={empty:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Strength indicator", "s2member-front", "s2member")); ?>',"short":'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Very weak", "s2member-front", "s2member")); ?>',bad:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Weak", "s2member-front", "s2member")); ?>',good:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Medium", "s2member-front", "s2member")); ?>',strong:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Strong", "s2member-front", "s2member")); ?>',mismatch:'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Mismatch", "s2member-front", "s2member")); ?>'};g.removeClass("ws-plugin--s2member-password-strength-short");g.removeClass("ws-plugin--s2member-password-strength-bad");g.removeClass("ws-plugin--s2member-password-strength-good");g.removeClass("ws-plugin--s2member-password-strength-strong");g.removeClass("ws-plugin--s2member-password-strength-mismatch");g.removeClass("ws-plugin--s2member-password-strength-empty");var f=ws_plugin__s2member_passwordStrengthMeter(k.val(),i.val());g.addClass("ws-plugin--s2member-password-strength-"+f).html(j[f])}};window.ws_plugin__s2member_validationErrors=function(r,q,g,m,l){if(typeof r==="string"&&r&&typeof q==="object"&&typeof g==="object"){if(typeof q.tagName==="string"&&/^(input|textarea|select)$/i.test(q.tagName)&&!q.disabled){var t=q.tagName.toLowerCase(),p=d(q),o=d.trim(p.attr("type")).toLowerCase(),f=d.trim(p.attr("name")),s=p.val();m=(typeof m==="boolean")?m:(p.attr("aria-required")==="true"),l=(typeof l==="string")?l:d.trim(p.attr("data-expected"));var k=('<?php echo strlen($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"]); ?>'>0);var i=new RegExp('^(<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (implode ("|", preg_split ("/[\r\n\t ;,]+/", preg_quote ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"], "/")))); ?>)@',"i");if(t==="input"&&o==="checkbox"&&/\[\]$/.test(f)){if(typeof q.id==="string"&&/-0$/.test(q.id)){if(m&&!d('input[name="'+ws_plugin__s2member_escjQAttr(f)+'"]:checked',g).length){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please check at least one of the boxes.", "s2member-front", "s2member")); ?>'}}}else{if(t==="input"&&o==="checkbox"){if(m&&!q.checked){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Required. This box must be checked.", "s2member-front", "s2member")); ?>'}}else{if(t==="input"&&o==="radio"){if(typeof q.id==="string"&&/-0$/.test(q.id)){if(m&&!d('input[name="'+ws_plugin__s2member_escjQAttr(f)+'"]:checked',g).length){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please select one of the options.", "s2member-front", "s2member")); ?>'}}}else{if(t==="select"&&p.attr("multiple")){if(m&&(!(s instanceof Array)||!s.length)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please select at least one of the options.", "s2member-front", "s2member")); ?>'}}else{if(typeof s!=="string"||(m&&!(s=d.trim(s)).length)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("This is a required field, please try again.", "s2member-front", "s2member")); ?>'}else{if((s=d.trim(s)).length&&((t==="input"&&/^(text|password)$/i.test(o))||t==="textarea")&&typeof l==="string"&&l.length){if(l==="numeric-wp-commas"&&(!/^[0-9\.,]+$/.test(s)||isNaN(s.replace(/,/g,"")))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be numeric (with or without decimals, commas allowed).", "s2member-front", "s2member")); ?>'}else{if(l==="numeric"&&(!/^[0-9\.]+$/.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be numeric (with or without decimals, no commas).", "s2member-front", "s2member")); ?>'}else{if(l==="integer"&&(!/^[0-9]+$/.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be an integer (a whole number, without any decimals).", "s2member-front", "s2member")); ?>'}else{if(l==="integer-gt-0"&&(!/^[0-9]+$/.test(s)||isNaN(s)||s<=0)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be an integer > 0 (whole number, no decimals, greater than 0).", "s2member-front", "s2member")); ?>'}else{if(l==="float"&&(!/^[0-9\.]+$/.test(s)||!/[0-9]/.test(s)||!/\./.test(s)||isNaN(s))){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a float (floating point number, decimals required).", "s2member-front", "s2member")); ?>'}else{if(l==="float-gt-0"&&(!/^[0-9\.]+$/.test(s)||!/[0-9]/.test(s)||!/\./.test(s)||isNaN(s)||s<=0)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a float > 0 (floating point number, decimals required, greater than 0).", "s2member-front", "s2member")); ?>'}else{if(l==="date"&&!/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a date (required date format: dd/mm/yyyy).", "s2member-front", "s2member")); ?>'}else{if(l==="email"&&!/^[a-zA-Z0-9_!#$%&*+=?`{}~|\/\^\'\-]+(?:\.?[a-zA-Z0-9_!#$%&*+=?`{}~|\/\^\'\-]+)*@[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*)*(?:\.[a-zA-Z][a-zA-Z0-9]+)?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a valid email address.", "s2member-front", "s2member")); ?>'}else{if(l==="email"&&k&&i.test(s)){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use a personal email address.\nAddresses like <%s@> are problematic.", "s2member-front", "s2member")); ?>',s.split("@")[0])}else{if(l==="url"&&!/^https?\:\/\/.+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a full URL (starting with http or https).", "s2member-front", "s2member")); ?>'}else{if(l==="domain"&&!/^[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:\-*[a-zA-Z0-9]+)*)*(?:\.[a-zA-Z][a-zA-Z0-9]+)?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a domain name (domain name only, without http).", "s2member-front", "s2member")); ?>'}else{if(l==="phone"&&(!/^[0-9 ()\-]+$/.test(s)||s.replace(/[^0-9]+/g,"").length!==10)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a phone # (10 digits w/possible hyphens, spaces, brackets).", "s2member-front", "s2member")); ?>'}else{if(l==="uszip"&&!/^[0-9]{5}(?:\-[0-9]{4})?$/.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a US zipcode (5-9 digits w/ possible hyphen).", "s2member-front", "s2member")); ?>'}else{if(l==="cazip"&&!/^[0-9A-Z]{3} ?[0-9A-Z]{3}$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a Canadian zipcode (6 alpha-numerics w/possible space).", "s2member-front", "s2member")); ?>'}else{if(l==="uczip"&&!/^[0-9]{5}(?:\-[0-9]{4})?$/.test(s)&&!/^[0-9A-Z]{3} ?[0-9A-Z]{3}$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be a zipcode (either a US or Canadian zipcode).", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-spaces\-punctuation\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z 0-9\/\\\\,.?:;"\'{}[\]\^|+=_()*&%$#@!`~\-]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics, spaces & punctuation only.", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-spaces\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z 0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics & spaces only.", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-punctuation\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z0-9\/\\\\,.?:;"\'{}[\]\^|+=_()*&%$#@!`~\-]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics & punctuation only (no spaces).", "s2member-front", "s2member")); ?>'}else{if(/^alphanumerics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphanumerics only (no spaces/punctuation).", "s2member-front", "s2member")); ?>'}else{if(/^alphabetics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[a-z]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use alphabetics only (no digits/spaces/punctuation).", "s2member-front", "s2member")); ?>'}else{if(/^numerics\-[0-9]+(?:\-e)?$/.test(l)&&!/^[0-9]+$/i.test(s)){return r+'\n<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Please use numeric digits only.", "s2member-front", "s2member")); ?>'}else{if(/^(?:any|alphanumerics\-spaces\-punctuation|alphanumerics\-spaces|alphanumerics\-punctuation|alphanumerics|alphabetics|numerics)\-[0-9]+(?:\-e)?$/.test(l)){var n=l.split("-"),h=Number(n[1]),j=(n.length>2&&n[2]==="e");if(j&&s.length!==h){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be exactly %s %s.", "s2member-front", "s2member")); ?>',h,((n[0]==="numerics")?((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digit", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digits", "s2member-front", "s2member")); ?>'):((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("character", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("characters", "s2member-front", "s2member")); ?>')))}else{if(s.length<h){return r+"\n"+d.sprintf('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("Must be at least %s %s.", "s2member-front", "s2member")); ?>',h,((n[0]==="numerics")?((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digit", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("digits", "s2member-front", "s2member")); ?>'):((h===1)?'<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq(_x("character", "s2member-front", "s2member")); ?>':'<?php echo c_ws_plugin__s2member_utils_strings::es