Version Description
= v141007 =
(Maintenance Release) Upgrade immediately.
Download this release
Release Info
Developer | JasWSInc |
Plugin | ![]() |
Version | 141007 |
Comparing to | |
See all releases |
Code changes from version 140921 to 141007
- checksum.txt +1 -1
- includes/classes/admin-lockouts.inc.php +1 -1
- includes/classes/admin-notices.inc.php +137 -137
- includes/classes/aweber-e.inc.php +151 -0
- includes/classes/aweber.inc.php +314 -0
- includes/classes/catgs-sp.inc.php +73 -73
- includes/classes/catgs.inc.php +70 -73
- includes/classes/getresponse.inc.php +196 -0
- includes/classes/list-server-base.inc.php +118 -0
- includes/classes/list-servers.inc.php +160 -414
- includes/classes/login-redirects.inc.php +9 -9
- includes/classes/mailchimp-o.inc.php +204 -0
- includes/classes/mailchimp.inc.php +218 -0
- includes/classes/pages-sp.inc.php +3 -2
- includes/classes/pages.inc.php +3 -2
- includes/classes/posts-sp.inc.php +3 -2
- includes/classes/posts.inc.php +3 -2
- includes/classes/ptags-sp.inc.php +87 -90
- includes/classes/ptags.inc.php +70 -71
- includes/classes/querys.inc.php +1 -1
- includes/classes/register-access.inc.php +93 -91
- includes/classes/registrations.inc.php +1150 -1105
- includes/classes/ruris-sp.inc.php +62 -64
- includes/classes/ruris.inc.php +5 -4
- includes/classes/sc-gets-in.inc.php +76 -61
- includes/classes/sc-gets.inc.php +43 -43
- includes/classes/sc-if-conds-in.inc.php +284 -284
- includes/classes/sc-if-conds.inc.php +53 -53
- includes/classes/sc-keys-in.inc.php +53 -54
- includes/classes/sc-keys.inc.php +43 -43
- includes/classes/ssl-in.inc.php +158 -162
- includes/classes/ssl.inc.php +56 -60
- includes/classes/systematics-sp.inc.php +123 -130
- includes/classes/systematics.inc.php +136 -149
- includes/classes/utils-conds.inc.php +237 -216
- includes/classes/utils-logs.inc.php +151 -131
- includes/codes.inc.php +20 -21
- includes/externals/aweber/aweber.php +294 -0
- includes/externals/aweber/aweber_api.php +8 -0
- includes/externals/aweber/aweber_collection.php +268 -0
- includes/externals/aweber/aweber_entry.php +343 -0
- includes/externals/aweber/aweber_entry_data_array.php +68 -0
- includes/externals/aweber/aweber_response.php +73 -0
- includes/externals/aweber/curl_object.php +103 -0
- includes/externals/aweber/curl_response.php +51 -0
- includes/externals/aweber/exceptions.php +130 -0
- includes/externals/aweber/oauth_adapter.php +11 -0
- includes/externals/aweber/oauth_application.php +681 -0
- includes/externals/mailchimp/{nc-mcapi.inc.php → Mailchimp-o.php} +2 -2
- includes/externals/mailchimp/Mailchimp.php +261 -0
- includes/externals/mailchimp/Mailchimp/Campaigns.php +378 -0
- includes/externals/mailchimp/Mailchimp/Conversations.php +80 -0
- includes/externals/mailchimp/Mailchimp/Ecomm.php +86 -0
- includes/externals/mailchimp/Mailchimp/Exceptions.php +471 -0
- includes/externals/mailchimp/Mailchimp/Folders.php +62 -0
- includes/externals/mailchimp/Mailchimp/Gallery.php +106 -0
- includes/externals/mailchimp/Mailchimp/Goal.php +49 -0
- includes/externals/mailchimp/Mailchimp/Helper.php +237 -0
- includes/externals/mailchimp/Mailchimp/Lists.php +904 -0
- includes/externals/mailchimp/Mailchimp/Mobile.php +10 -0
- includes/externals/mailchimp/Mailchimp/Neapolitan.php +10 -0
- includes/externals/mailchimp/Mailchimp/Reports.php +459 -0
- includes/externals/mailchimp/Mailchimp/Templates.php +114 -0
- includes/externals/mailchimp/Mailchimp/Users.php +105 -0
- includes/externals/mailchimp/Mailchimp/Vip.php +111 -0
- includes/funcs.inc.php +21 -22
- includes/menu-pages/api-ops.inc.php +7 -7
- includes/menu-pages/down-ops.inc.php +1 -1
- includes/menu-pages/els-ops.inc.php +403 -356
- includes/menu-pages/gen-ops.inc.php +7 -7
- includes/menu-pages/logs.inc.php +1 -1
- includes/menu-pages/mms-ops.inc.php +1 -1
- includes/menu-pages/paypal-buttons.inc.php +2 -2
- includes/menu-pages/res-ops.inc.php +611 -602
- includes/menu-pages/trk-ops.inc.php +7 -7
- includes/s2member-min.js +1 -1
checksum.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
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
|
18 |
-
exit(
|
19 |
-
|
20 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
/**
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
{
|
30 |
-
|
31 |
-
|
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 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
{
|
74 |
-
|
75 |
-
|
76 |
-
unset($__refs, $__v);
|
77 |
|
78 |
-
|
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 |
-
|
83 |
-
|
84 |
-
else if (is_string ($notice) && $notice)
|
85 |
{
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
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 |
-
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
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
|
18 |
-
exit(
|
19 |
|
20 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
/**
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
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 |
-
|
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 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
|
|
56 |
|
57 |
-
|
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 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
68 |
-
|
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 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
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
|
18 |
-
exit(
|
19 |
|
20 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
/**
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
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 |
-
|
45 |
|
46 |
-
|
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 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
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 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
{
|
72 |
-
if /* URIs configured at this Level? */ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
|
73 |
|
74 |
-
|
75 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
*
|
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
|
56 |
-
* @param int|string $level A numeric
|
57 |
-
* @param string $login Username for the
|
58 |
-
* @param string $pass Plain
|
59 |
-
* @param string $email Email
|
60 |
-
* @param string $fname First
|
61 |
-
* @param string $lname Last
|
62 |
-
* @param string $ip IP
|
63 |
-
* @param bool $opt_in Defaults to
|
64 |
-
* @param bool $double_opt_in Defaults to
|
65 |
* @param int|string $user_id A WordPress User ID, numeric string or integer.
|
66 |
*
|
67 |
-
* @return bool True if at least one
|
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 = '',
|
|
|
|
|
|
|
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()
|
82 |
{
|
83 |
-
$
|
84 |
-
|
85 |
-
$
|
86 |
-
|
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);
|