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

Version Description

= v120213 = Optimization and a few bug fixes. Upgrade immediately.

Download this release

Release Info

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

Code changes from version 111220 to 120213

Files changed (42) hide show
  1. includes/classes/admin-css-js-in.inc.php +39 -39
  2. includes/classes/css-js-in.inc.php +82 -82
  3. includes/classes/custom-reg-fields.inc.php +292 -291
  4. includes/classes/files-in.inc.php +515 -501
  5. includes/classes/files.inc.php +155 -74
  6. includes/classes/installation.inc.php +74 -72
  7. includes/classes/login-customizations.inc.php +56 -57
  8. includes/classes/menu-pages.inc.php +237 -228
  9. includes/classes/meta-box-security.inc.php +57 -57
  10. includes/classes/mo-page-in.inc.php +1 -1
  11. includes/classes/paypal-notify-in-subscr-or-rp-eots-w-level.inc.php +164 -164
  12. includes/classes/paypal-return-in-subscr-modify-w-level.inc.php +93 -88
  13. includes/classes/paypal-return-in-subscr-or-wa-w-level.inc.php +150 -145
  14. includes/classes/roles-caps.inc.php +57 -57
  15. includes/classes/ssl-in.inc.php +59 -57
  16. includes/classes/utils-conds.inc.php +4 -1
  17. includes/classes/utils-strings.inc.php +141 -122
  18. includes/menu-pages/down-ops.inc.php +494 -471
  19. includes/menu-pages/els-ops.inc.php +233 -233
  20. includes/menu-pages/mms-ops.inc.php +251 -251
  21. includes/s2member-min.js +1 -1
  22. includes/s2member.css +24 -24
  23. includes/s2member.js +10 -8
  24. includes/syscon.inc.php +151 -150
  25. includes/templates/cfg-files/s2member-files-no-gzip.php +18 -0
  26. includes/templates/cfg-files/s2member-files.php +60 -19
  27. includes/templates/cfg-files/s2o-mu-plugins.php +13 -2
  28. includes/translations/s2member.pot +186 -186
  29. ms.txt +0 -7
  30. readme-ms.txt +4 -0
  31. readme.txt +64 -189
  32. s2member.php +52 -53
  33. screenshot-1.png +0 -0
  34. screenshot-10.png +0 -0
  35. screenshot-2.png +0 -0
  36. screenshot-3.png +0 -0
  37. screenshot-4.png +0 -0
  38. screenshot-5.png +0 -0
  39. screenshot-6.png +0 -0
  40. screenshot-7.png +0 -0
  41. screenshot-8.png +0 -0
  42. screenshot-9.png +0 -0
includes/classes/admin-css-js-in.inc.php CHANGED
@@ -14,10 +14,10 @@
14
* @package s2Member\Admin_CSS_JS
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_css_js_in"))
21
{
22
/**
23
* Administrative CSS/JS for menu pages ( inner processing routines ).
@@ -37,39 +37,39 @@ if (!class_exists ("c_ws_plugin__s2member_admin_css_js_in"))
37
*
38
* @return null Or exits script execution after loading CSS.
39
*/
40
- public static function menu_pages_css ()
41
{
42
- do_action ("ws_plugin__s2member_before_menu_pages_css", get_defined_vars ());
43
/**/
44
- if (!empty ($_GET["ws_plugin__s2member_menu_pages_css"]) && is_user_logged_in () && current_user_can ("create_users"))
45
{
46
- status_header (200); /* 200 OK status header. */
47
/**/
48
- header ("Content-Type: text/css; charset=utf-8");
49
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
50
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
51
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
52
- header ("Pragma: no-cache");
53
/**/
54
- eval ('while (@ob_end_clean ());'); /* Clean buffers. */
55
/**/
56
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
57
- $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
58
/**/
59
- ob_start ("c_ws_plugin__s2member_utils_css::compress_css");
60
/**/
61
- include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.css";
62
/**/
63
echo "\n"; /* Add a line break before inclusion of this file. */
64
/**/
65
- @include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s.css";
66
/**/
67
- do_action ("ws_plugin__s2member_during_menu_pages_css", get_defined_vars ());
68
/**/
69
- exit (); /* Clean exit. */
70
}
71
/**/
72
- do_action ("ws_plugin__s2member_after_menu_pages_css", get_defined_vars ());
73
}
74
/**
75
* Outputs the JS for administrative menu pages.
@@ -81,41 +81,41 @@ if (!class_exists ("c_ws_plugin__s2member_admin_css_js_in"))
81
*
82
* @return null Or exits script execution after loading JS.
83
*/
84
- public static function menu_pages_js ()
85
{
86
- do_action ("ws_plugin__s2member_before_menu_pages_js", get_defined_vars ());
87
/**/
88
- if (!empty ($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in () && current_user_can ("create_users"))
89
{
90
- status_header (200); /* 200 OK status header. */
91
/**/
92
- header ("Content-Type: text/javascript; charset=utf-8");
93
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
94
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
95
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
96
- header ("Pragma: no-cache");
97
/**/
98
- eval ('while (@ob_end_clean ());'); /* Clean buffers. */
99
/**/
100
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
101
- $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
102
/**/
103
- for ($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
104
- $labels .= "labels['level" . $n . "'] = '" . ((!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"])) ? str_replace ('"', "", c_ws_plugin__s2member_utils_strings::esc_js_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"], 3)) : "") . "';";
105
- unset ($n);
106
/**/
107
- include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-min.js";
108
/**/
109
echo "\n"; /* Add a line break before inclusion of this file. */
110
/**/
111
- @include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s-min.js";
112
/**/
113
- do_action ("ws_plugin__s2member_during_menu_pages_js", get_defined_vars ());
114
/**/
115
- exit (); /* Clean exit. */
116
}
117
/**/
118
- do_action ("ws_plugin__s2member_after_menu_pages_js", get_defined_vars ());
119
}
120
}
121
}
14
* @package s2Member\Admin_CSS_JS
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_css_js_in"))
21
{
22
/**
23
* Administrative CSS/JS for menu pages ( inner processing routines ).
37
*
38
* @return null Or exits script execution after loading CSS.
39
*/
40
+ public static function menu_pages_css()
41
{
42
+ do_action("ws_plugin__s2member_before_menu_pages_css", get_defined_vars());
43
/**/
44
+ if(!empty($_GET["ws_plugin__s2member_menu_pages_css"]) && is_user_logged_in() && current_user_can("create_users"))
45
{
46
+ status_header(200); /* 200 OK status header. */
47
/**/
48
+ header("Content-Type: text/css; charset=utf-8");
49
+ header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
50
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
51
+ header("Cache-Control: no-cache, must-revalidate, max-age=0");
52
+ header("Pragma: no-cache");
53
/**/
54
+ eval('while (@ob_end_clean ());'); /* Clean buffers. */
55
/**/
56
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
57
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
58
/**/
59
+ ob_start("c_ws_plugin__s2member_utils_css::compress_css");
60
/**/
61
+ include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages.css";
62
/**/
63
echo "\n"; /* Add a line break before inclusion of this file. */
64
/**/
65
+ @include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s.css";
66
/**/
67
+ do_action("ws_plugin__s2member_during_menu_pages_css", get_defined_vars());
68
/**/
69
+ exit(); /* Clean exit. */
70
}
71
/**/
72
+ do_action("ws_plugin__s2member_after_menu_pages_css", get_defined_vars());
73
}
74
/**
75
* Outputs the JS for administrative menu pages.
81
*
82
* @return null Or exits script execution after loading JS.
83
*/
84
+ public static function menu_pages_js()
85
{
86
+ do_action("ws_plugin__s2member_before_menu_pages_js", get_defined_vars());
87
/**/
88
+ if(!empty($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in() && current_user_can("create_users"))
89
{
90
+ status_header(200); /* 200 OK status header. */
91
/**/
92
+ header("Content-Type: application/x-javascript; charset=utf-8");
93
+ header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("-1 week"))." GMT");
94
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
95
+ header("Cache-Control: no-cache, must-revalidate, max-age=0");
96
+ header("Pragma: no-cache");
97
/**/
98
+ eval('while (@ob_end_clean ());'); /* Clean buffers. */
99
/**/
100
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
101
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
102
/**/
103
+ for($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
104
+ $labels .= "labels['level".$n."'] = '".((!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"])) ? str_replace('"', "", c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level".$n."_label"], 3)) : "")."';";
105
+ unset($n);
106
/**/
107
+ include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-min.js";
108
/**/
109
echo "\n"; /* Add a line break before inclusion of this file. */
110
/**/
111
+ @include_once dirname(dirname(__FILE__))."/menu-pages/menu-pages-s-min.js";
112
/**/
113
+ do_action("ws_plugin__s2member_during_menu_pages_js", get_defined_vars());
114
/**/
115
+ exit(); /* Clean exit. */
116
}
117
/**/
118
+ do_action("ws_plugin__s2member_after_menu_pages_js", get_defined_vars());
119
}
120
}
121
}
includes/classes/css-js-in.inc.php CHANGED
@@ -14,10 +14,10 @@
14
* @package s2Member\CSS_JS
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_css_js_in"))
21
{
22
/**
23
* CSS/JS loading handlers for s2Member ( inner processing routines ).
@@ -37,35 +37,35 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
37
*
38
* @return null Or exits script execution after loading CSS.
39
*/
40
- public static function css ()
41
{
42
- do_action ("ws_plugin__s2member_before_css", get_defined_vars ());
43
/**/
44
- if (!empty ($_GET["ws_plugin__s2member_css"]))
45
{
46
status_header(200); /* 200 OK status. */
47
/**/
48
header("Content-Type: text/css; charset=utf-8");
49
- header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
50
- header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
51
header("Cache-Control: max-age=604800");
52
header("Pragma: public");
53
/**/
54
eval('while (@ob_end_clean ());');
55
/**/
56
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
57
- $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
58
/**/
59
ob_start("c_ws_plugin__s2member_utils_css::compress_css");
60
/**/
61
- include_once dirname (dirname (__FILE__)) . "/s2member.css";
62
/**/
63
- do_action ("ws_plugin__s2member_during_css", get_defined_vars ());
64
/**/
65
- exit (); /* Clean exit. */
66
}
67
/**/
68
- do_action ("ws_plugin__s2member_after_css", get_defined_vars ());
69
}
70
/**
71
* Outputs JS for theme integration.
@@ -79,127 +79,127 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
79
*
80
* @return null Or exits script execution after loading JS w/Globals.
81
*/
82
- public static function js_w_globals ()
83
{
84
- do_action ("ws_plugin__s2member_before_js_w_globals", get_defined_vars ());
85
/**/
86
- if (!empty ($_GET["ws_plugin__s2member_js_w_globals"]))
87
{
88
status_header(200); /* 200 OK status header. */
89
/**/
90
- header("Content-Type: text/javascript; charset=utf-8");
91
- header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
92
- header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
93
header("Cache-Control: max-age=604800");
94
header("Pragma: public");
95
/**/
96
eval('while (@ob_end_clean ());');
97
/**/
98
- include_once dirname (dirname (__FILE__)) . "/jquery/jquery.sprintf/jquery.sprintf-min.js";
99
/**/
100
echo "\n"; /* Add a line break before writing JavaScript Globals to file. */
101
/**/
102
- echo "var S2MEMBER_VERSION = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_VERSION) . "',";
103
/**/
104
- echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = " . S2MEMBER_CURRENT_USER_LOGIN_COUNTER . ",";
105
/**/
106
- echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
107
- echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false") . ",";
108
/**/
109
- echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
110
- echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
111
/**/
112
- echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
113
- echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) . "',";
114
- echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY) . "',";
115
- echo "S2MEMBER_CURRENT_USER_CUSTOM = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_CUSTOM) . "',";
116
/**/
117
- echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_REGISTRATION_TIME . ",";
118
- echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME . ",";
119
/**/
120
- echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS . ",";
121
- echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_REGISTRATION_DAYS . ",";
122
/**/
123
- echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_DISPLAY_NAME) . "',";
124
- echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_FIRST_NAME) . "',";
125
- echo "S2MEMBER_CURRENT_USER_LAST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_LAST_NAME) . "',";
126
/**/
127
- echo "S2MEMBER_CURRENT_USER_LOGIN = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_LOGIN) . "',";
128
- echo "S2MEMBER_CURRENT_USER_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_EMAIL) . "',";
129
- echo "S2MEMBER_CURRENT_USER_IP = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_IP) . "',";
130
- echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_REGISTRATION_IP) . "',";
131
/**/
132
- echo "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
133
- echo "S2MEMBER_CURRENT_USER_FIELDS = " . S2MEMBER_CURRENT_USER_FIELDS . ",";
134
/**/
135
- echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED . ",";
136
- echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = " . ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false") . ",";
137
- echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = " . S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY . ",";
138
- echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS . ",";
139
/**/
140
- echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = " . S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID . ",";
141
- echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID . ",";
142
- echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = " . S2MEMBER_LOGIN_WELCOME_PAGE_ID . ",";
143
/**/
144
- echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL) . "',";
145
- echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL) . "',";
146
- echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL) . "',";
147
- echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_LOGIN_WELCOME_PAGE_URL) . "',";
148
- echo "S2MEMBER_LOGOUT_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_LOGOUT_PAGE_URL) . "',";
149
- echo "S2MEMBER_LOGIN_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_LOGIN_PAGE_URL) . "',";
150
/**/
151
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
152
{
153
- if (defined (($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL" . $n . "_LABEL")))
154
- echo $S2MEMBER_LEVELn_LABEL . " = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (constant ($S2MEMBER_LEVELn_LABEL)) . "',";
155
}
156
/**/
157
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
158
{
159
- if (defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED")))
160
- echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED . " = " . constant ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED) . ",";
161
}
162
/**/
163
- for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
164
{
165
- if (defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED_DAYS")))
166
- echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS . " = " . constant ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS) . ",";
167
}
168
/**/
169
- echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS) . "',";
170
/**/
171
- echo "S2MEMBER_REG_EMAIL_FROM_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_REG_EMAIL_FROM_NAME) . "',";
172
- echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_REG_EMAIL_FROM_EMAIL) . "',";
173
/**/
174
- echo "S2MEMBER_PAYPAL_NOTIFY_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_PAYPAL_NOTIFY_URL) . "',";
175
- echo "S2MEMBER_PAYPAL_RETURN_URL = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_PAYPAL_RETURN_URL) . "',";
176
/**/
177
- echo "S2MEMBER_PAYPAL_BUSINESS = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_PAYPAL_BUSINESS) . "',";
178
- echo "S2MEMBER_PAYPAL_ENDPOINT = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_PAYPAL_ENDPOINT) . "',";
179
- echo "S2MEMBER_PAYPAL_API_ENDPOINT = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_PAYPAL_API_ENDPOINT) . "',";
180
/**/
181
- echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_IP) . "',";
182
echo "S2MEMBER_VALUE_FOR_PP_INV_GEN = s2member_value_for_pp_inv_gen = function(){ var invoice = '', formatSeed = function(seed, reqWidth) { seed = parseInt(seed, 10).toString (16); if (reqWidth < seed.length) return seed.slice (seed.length - reqWidth); else if (reqWidth > seed.length) return Array(1 + (reqWidth - seed.length)).join ('0') + seed; return seed; }; if (typeof S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED === 'undefined') S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED = Math.floor (Math.random () * 0x75bcd15); S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED++; invoice = formatSeed(parseInt(new Date ().getTime () / 1000, 10), 8); invoice += formatSeed(S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED, 5); invoice += '~' + S2MEMBER_CURRENT_USER_IP; return invoice; },";
183
/**/
184
- echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) . "',";
185
- echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0) . "',";
186
/**/
187
- echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1) . "',";
188
- echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1) . "';";
189
/**/
190
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
191
- $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
192
/**/
193
echo "\n"; /* Add a line break before inclusion. */
194
/**/
195
- include_once dirname (dirname (__FILE__)) . "/s2member-min.js";
196
/**/
197
- do_action ("ws_plugin__s2member_during_js_w_globals", get_defined_vars ());
198
/**/
199
- exit (); /* Clean exit. */
200
}
201
/**/
202
- do_action ("ws_plugin__s2member_after_js_w_globals", get_defined_vars ());
203
}
204
}
205
}
14
* @package s2Member\CSS_JS
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_css_js_in"))
21
{
22
/**
23
* CSS/JS loading handlers for s2Member ( inner processing routines ).
37
*
38
* @return null Or exits script execution after loading CSS.
39
*/
40
+ public static function css()
41
{
42
+ do_action("ws_plugin__s2member_before_css", get_defined_vars());
43
/**/
44
+ if(!empty($_GET["ws_plugin__s2member_css"]))
45
{
46
status_header(200); /* 200 OK status. */
47
/**/
48
header("Content-Type: text/css; charset=utf-8");
49
+ header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
50
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
51
header("Cache-Control: max-age=604800");
52
header("Pragma: public");
53
/**/
54
eval('while (@ob_end_clean ());');
55
/**/
56
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
57
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
58
/**/
59
ob_start("c_ws_plugin__s2member_utils_css::compress_css");
60
/**/
61
+ include_once dirname(dirname(__FILE__))."/s2member.css";
62
/**/
63
+ do_action("ws_plugin__s2member_during_css", get_defined_vars());
64
/**/
65
+ exit(); /* Clean exit. */
66
}
67
/**/
68
+ do_action("ws_plugin__s2member_after_css", get_defined_vars());
69
}
70
/**
71
* Outputs JS for theme integration.
79
*
80
* @return null Or exits script execution after loading JS w/Globals.
81
*/
82
+ public static function js_w_globals()
83
{
84
+ do_action("ws_plugin__s2member_before_js_w_globals", get_defined_vars());
85
/**/
86
+ if(!empty($_GET["ws_plugin__s2member_js_w_globals"]))
87
{
88
status_header(200); /* 200 OK status header. */
89
/**/
90
+ header("Content-Type: application/x-javascript; charset=utf-8");
91
+ header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
92
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
93
header("Cache-Control: max-age=604800");
94
header("Pragma: public");
95
/**/
96
eval('while (@ob_end_clean ());');
97
/**/
98
+ include_once dirname(dirname(__FILE__))."/jquery/jquery.sprintf/jquery.sprintf-min.js";
99
/**/
100
echo "\n"; /* Add a line break before writing JavaScript Globals to file. */
101
/**/
102
+ echo "var S2MEMBER_VERSION = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_VERSION)."',";
103
/**/
104
+ echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = ".S2MEMBER_CURRENT_USER_LOGIN_COUNTER.",";
105
/**/
106
+ echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false").",";
107
+ echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false").",";
108
/**/
109
+ echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = ".S2MEMBER_CURRENT_USER_ACCESS_LEVEL.",";
110
+ echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_ACCESS_LABEL)."',";
111
/**/
112
+ echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_ID)."',";
113
+ echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID)."',";
114
+ echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY)."',";
115
+ echo "S2MEMBER_CURRENT_USER_CUSTOM = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_CUSTOM)."',";
116
/**/
117
+ echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_REGISTRATION_TIME.",";
118
+ echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME.",";
119
/**/
120
+ echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS.",";
121
+ echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_REGISTRATION_DAYS.",";
122
/**/
123
+ echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_DISPLAY_NAME)."',";
124
+ echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_FIRST_NAME)."',";
125
+ echo "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LAST_NAME)."',";
126
/**/
127
+ echo "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LOGIN)."',";
128
+ echo "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_EMAIL)."',";
129
+ echo "S2MEMBER_CURRENT_USER_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
130
+ echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_REGISTRATION_IP)."',";
131
/**/
132
+ echo "S2MEMBER_CURRENT_USER_ID = ".S2MEMBER_CURRENT_USER_ID.",";
133
+ echo "S2MEMBER_CURRENT_USER_FIELDS = ".S2MEMBER_CURRENT_USER_FIELDS.",";
134
/**/
135
+ echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED.",";
136
+ echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false").",";
137
+ echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY.",";
138
+ echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS.",";
139
/**/
140
+ echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = ".S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID.",";
141
+ echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID.",";
142
+ echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = ".S2MEMBER_LOGIN_WELCOME_PAGE_ID.",";
143
/**/
144
+ echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL)."',";
145
+ echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL)."',";
146
+ echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL)."',";
147
+ echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_WELCOME_PAGE_URL)."',";
148
+ echo "S2MEMBER_LOGOUT_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGOUT_PAGE_URL)."',";
149
+ echo "S2MEMBER_LOGIN_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_PAGE_URL)."',";
150
/**/
151
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
152
{
153
+ if(defined(($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL".$n."_LABEL")))
154
+ echo $S2MEMBER_LEVELn_LABEL." = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(constant($S2MEMBER_LEVELn_LABEL))."',";
155
}
156
/**/
157
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
158
{
159
+ if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED")))
160
+ echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED).",";
161
}
162
/**/
163
+ for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
164
{
165
+ if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED_DAYS")))
166
+ echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS).",";
167
}
168
/**/
169
+ echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS)."',";
170
/**/
171
+ echo "S2MEMBER_REG_EMAIL_FROM_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_NAME)."',";
172
+ echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_EMAIL)."',";
173
/**/
174
+ echo "S2MEMBER_PAYPAL_NOTIFY_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_NOTIFY_URL)."',";
175
+ echo "S2MEMBER_PAYPAL_RETURN_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_RETURN_URL)."',";
176
/**/
177
+ echo "S2MEMBER_PAYPAL_BUSINESS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_BUSINESS)."',";
178
+ echo "S2MEMBER_PAYPAL_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_ENDPOINT)."',";
179
+ echo "S2MEMBER_PAYPAL_API_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_API_ENDPOINT)."',";
180
/**/
181
+ echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',";
182
echo "S2MEMBER_VALUE_FOR_PP_INV_GEN = s2member_value_for_pp_inv_gen = function(){ var invoice = '', formatSeed = function(seed, reqWidth) { seed = parseInt(seed, 10).toString (16); if (reqWidth < seed.length) return seed.slice (seed.length - reqWidth); else if (reqWidth > seed.length) return Array(1 + (reqWidth - seed.length)).join ('0') + seed; return seed; }; if (typeof S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED === 'undefined') S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED = Math.floor (Math.random () * 0x75bcd15); S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED++; invoice = formatSeed(parseInt(new Date ().getTime () / 1000, 10), 8); invoice += formatSeed(S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED, 5); invoice += '~' + S2MEMBER_CURRENT_USER_IP; return invoice; },";
183
/**/
184
+ echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0)."',";
185
+ echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0)."',";
186
/**/
187
+ echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1)."',";
188
+ echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1)."';";
189
/**/
190
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
191
+ $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/images";
192
/**/
193
echo "\n"; /* Add a line break before inclusion. */
194
/**/
195
+ include_once dirname(dirname(__FILE__))."/s2member-min.js";
196
/**/
197
+ do_action("ws_plugin__s2member_during_js_w_globals", get_defined_vars());
198
/**/
199
+ exit(); /* Clean exit. */
200
}
201
/**/
202
+ do_action("ws_plugin__s2member_after_js_w_globals", get_defined_vars());
203
}
204
}
205
}
includes/classes/custom-reg-fields.inc.php CHANGED
@@ -14,10 +14,10 @@
14
* @package s2Member\Custom_Reg_Fields
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_custom_reg_fields"))
21
{
22
/**
23
* Custom Registration/Profile Fields for s2Member.
@@ -46,224 +46,225 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
46
* @param str $_editable_context Optional. One of `profile|profile-view|registration`.
47
* @return str The resulting Custom Field, in HTML format.
48
*/
49
- public static function custom_field_gen ($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_editable_context = FALSE)
50
{
51
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
52
- do_action ("ws_plugin__s2member_before_custom_field_gen", get_defined_vars ());
53
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
54
/**/
55
- if (!($gen = "") && $_function && is_array ($field = $_field) && !empty ($field["type"]) && !empty ($field["id"]) && $_name_prefix && $_id_prefix)
56
{
57
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
58
- do_action ("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars ());
59
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
60
- /**/
61
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
62
- $field_id_class = preg_replace ("/_/", "-", $field_var);
63
- /**/
64
- $name_suffix = (preg_match ("/\[#x2F;", $_name_prefix)) ? ']' : '';
65
- $field_name = trim ($_name_prefix . $field_var . $name_suffix);
66
- /**/
67
- $common = ''; /* Common attribute configuration. */
68
- $common .= ' name="' . esc_attr ($field_name) . '"';
69
- $common .= ' id="' . esc_attr ($_id_prefix . $field_id_class) . '"';
70
- $common .= ((!empty ($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : '');
71
- $common .= ((strlen ($_tabindex)) ? ' tabindex="' . esc_attr ($_tabindex) . '"' : ''); /* No tabindex if empty. */
72
- $common .= ((!empty ($field["expected"])) ? ' data-expected="' . esc_attr ($field["expected"]) . '"' : ''); /* Certain data expected? */
73
- $common .= (($_editable_context === "profile-view" || (!empty ($field["editable"]) && strpos ($field["editable"], "no") === 0 && $_editable_context === "profile")) ? ' disabled="disabled"' : '');
74
- $common .= (($_classes || !empty ($field["classes"])) ? ' class="' . esc_attr (trim ($_classes . ((!empty ($field["classes"])) ? ' ' . $field["classes"] : ''))) . '"' : '');
75
- $common .= (($_styles || !empty ($field["styles"])) ? ' style="' . esc_attr (trim ($_styles . ((!empty ($field["styles"])) ? ' ' . $field["styles"] : ''))) . '"' : '');
76
- $common .= (($_attrs || !empty ($field["attrs"])) ? ' ' . trim ($_attrs . ((!empty ($field["attrs"])) ? ' ' . $field["attrs"] : '')) : '');
77
- /**/
78
- if ($field["type"] === "text")
79
{
80
- if ($_editable_context === "profile-view")
81
- $gen = esc_html ((string)$_value);
82
/**/
83
- else /* Else handle this Field normally. */
84
{
85
$gen = '<input type="text" maxlength="100" autocomplete="off"';
86
- $gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"';
87
- $gen .= $common . ' />';
88
}
89
}
90
/**/
91
- else if ($field["type"] === "textarea")
92
{
93
- if ($_editable_context === "profile-view")
94
- $gen = nl2br (esc_html ((string)$_value));
95
/**/
96
- else /* Else handle this Field normally. */
97
{
98
- $gen = '<textarea rows="3"' . $common . '>';
99
- $gen .= format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value);
100
$gen .= '</textarea>';
101
}
102
}
103
/**/
104
- else if ($field["type"] === "select" && !empty ($field["options"]))
105
{
106
- if ($_editable_context === "profile-view")
107
{
108
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
109
{
110
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
111
- if ($option_value === (string)$_value)
112
{
113
$gen = $option_label;
114
break;
115
}
116
}
117
}
118
- else /* Else handle this Field normally. */
119
{
120
- $gen = '<select' . $common . '>';
121
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
122
{
123
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
124
- $gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
125
}
126
$gen .= '</select>';
127
}
128
}
129
/**/
130
- else if ($field["type"] === "selects" && !empty ($field["options"]))
131
{
132
- if ($_editable_context === "profile-view")
133
{
134
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
135
{
136
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
137
- if (in_array ($option_value, (array)$_value))
138
- $gen .= $option_label . ", ";
139
}
140
- $gen = trim ($gen, ", \r\n\t\0\x0B");
141
}
142
- else /* Else handle this Field normally. */
143
{
144
- $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
145
- $common = preg_replace ('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
146
/**/
147
- $gen = '<select multiple="multiple" size="3"' . $common . '>';
148
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
149
{
150
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
151
- $gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
152
}
153
$gen .= '</select>';
154
}
155
}
156
/**/
157
- else if ($field["type"] === "checkbox" && !empty ($field["label"]))
158
{
159
- if ($_editable_context === "profile-view")
160
$gen = ((string)$_value) ? "yes" : "no";
161
/**/
162
- else /* Else handle this Field normally. */
163
{
164
$gen = '<input type="checkbox" value="1"';
165
$gen .= (((string)$_value) ? ' checked="checked"' : '');
166
- $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>';
167
}
168
}
169
/**/
170
- else if ($field["type"] === "pre_checkbox" && !empty ($field["label"]))
171
{
172
- if ($_editable_context === "profile-view")
173
$gen = ((string)$_value) ? "yes" : "no";
174
/**/
175
- else /* Else handle this Field normally. */
176
{
177
$gen = '<input type="checkbox" value="1"';
178
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
179
- $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>';
180
}
181
}
182
/**/
183
- else if ($field["type"] === "checkboxes" && !empty ($field["options"]))
184
{
185
- if ($_editable_context === "profile-view")
186
{
187
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
188
{
189
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
190
- if (in_array ($option_value, (array)$_value))
191
- $gen .= $option_label . ", ";
192
}
193
- $gen = trim ($gen, ", \r\n\t\0\x0B");
194
}
195
- else /* Else handle this Field normally. */
196
{
197
- $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
198
/**/
199
- $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_sep", "&nbsp;&nbsp;", get_defined_vars ());
200
- $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
201
/**/
202
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
203
{
204
- $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
205
/**/
206
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
207
/**/
208
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
209
- $gen .= '<input type="checkbox" value="' . esc_attr ($option_value) . '"';
210
- $gen .= ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' checked="checked"' : '');
211
- $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>';
212
}
213
}
214
}
215
/**/
216
- else if ($field["type"] === "radios" && !empty ($field["options"]))
217
{
218
- if ($_editable_context === "profile-view")
219
{
220
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
221
{
222
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
223
- if ($option_value === (string)$_value)
224
{
225
$gen = $option_label;
226
break;
227
}
228
}
229
}
230
- else /* Else handle this Field normally. */
231
{
232
- $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_sep", "&nbsp;&nbsp;", get_defined_vars ());
233
- $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
234
/**/
235
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
236
{
237
- $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
238
/**/
239
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
240
/**/
241
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
242
- $gen .= '<input type="radio" value="' . esc_attr ($option_value) . '"';
243
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
244
- $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>';
245
}
246
}
247
}
248
- else /* Default to using a text field. */
249
{
250
- if ($_editable_context === "profile-view")
251
- $gen = esc_html ((string)$_value);
252
/**/
253
- else /* Else handle this Field normally. */
254
{
255
$gen = '<input type="text" maxlength="100" autocomplete="off"';
256
- $gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"';
257
- $gen .= $common . ' />';
258
}
259
}
260
/**/
261
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
262
- do_action ("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars ());
263
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
264
}
265
/**/
266
- return apply_filters ("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars ());
267
}
268
/**
269
* Determines which Custom Fields apply to a specific Level.
@@ -276,27 +277,27 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
276
* @param str $_editable_context Optional. One of `profile|profile-view|registration`.
277
* @return array Array of Custom Field IDs applicable.
278
*/
279
- public static function custom_fields_configured_at_level ($_level = "auto-detection", $_editable_context = FALSE)
280
{
281
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
282
- do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ());
283
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
284
/**/
285
- $level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level () : $_level;
286
- if ($_level === "auto-detection" && $level < 0 && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok ()) && extract ($reg_cookies) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number, $m) && !empty ($m[1]) && is_numeric ($m[1]))
287
- $level = $m[1]; /* A numeric Membership Level # . */
288
/**/
289
- $level = ($level !== "any" && (!is_numeric ($level) || $level < 0)) ? 0 : $level; /* Default. */
290
/**/
291
- if (($level === "any" || (is_numeric ($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
292
{
293
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
294
- if ($level === "any" || $field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9;,]/", "", $field["levels"]))))
295
- if (empty ($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible"))
296
$configured[] = $field["id"]; /* Add this to the array. */
297
}
298
/**/
299
- return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty ($configured)) ? $configured : array ()), get_defined_vars ());
300
}
301
/**
302
* Adds Custom Fields to: `/wp-signup.php`.
@@ -312,105 +313,105 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
312
*
313
* @todo Optimize with ``empty()``.
314
*/
315
- public static function ms_custom_registration_fields ()
316
{
317
- do_action ("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars ());
318
/**/
319
- if (is_multisite () && is_main_site ()) /* Must be Main Site of a Network. */
320
{
321
- $_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
322
/**/
323
- echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
324
/**/
325
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
326
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ());
327
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
328
/**/
329
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
330
{
331
- echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n";
332
/**/
333
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
334
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ());
335
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
336
/**/
337
- echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">' . _x ("First Name", "s2member-front", "s2member") . ' *</label>' . "\n";
338
- echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n";
339
- echo '<br />' . "\n";
340
/**/
341
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
342
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars ());
343
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
344
/**/
345
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
346
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars ());
347
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
348
/**/
349
- echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">' . _x ("Last Name", "s2member-front", "s2member") . ' *</label>' . "\n";
350
- echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n";
351
- echo '<br />' . "\n";
352
/**/
353
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
354
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ());
355
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
356
}
357
/**/
358
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
359
- if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
360
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
361
{
362
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
363
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ());
364
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
365
/**/
366
- if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
367
{
368
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
369
- $field_id_class = preg_replace ("/_/", "-", $field_var);
370
/**/
371
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
372
- if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
373
{
374
- if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
375
- echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
376
/**/
377
- echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '"' . ((preg_match ("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</label>' . ((preg_match ("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? '<br />' : '') . "\n";
378
- echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
379
- echo '<br />' . "\n";
380
}
381
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
382
}
383
/**/
384
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
385
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ());
386
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
387
}
388
/**/
389
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
390
{
391
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
392
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ());
393
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
394
/**/
395
- echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
396
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
397
- echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
398
- echo '</label>' . "\n";
399
- echo '<br />' . "\n";
400
/**/
401
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
402
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ());
403
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
404
}
405
/**/
406
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
407
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ());
408
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
409
}
410
/**/
411
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
412
- do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ());
413
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
414
/**/
415
return; /* Return for uniformity. */
416
}
@@ -426,143 +427,143 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
426
*
427
* @todo Optimize with ``empty()``.
428
*/
429
- public static function custom_registration_fields ()
430
{
431
- do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ());
432
/**/
433
- $_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
434
/**/
435
- echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
436
/**/
437
$tabindex = 20; /* Incremented tabindex starting with 20. */
438
/**/
439
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
440
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ());
441
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
442
/**/
443
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
444
{
445
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
446
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ());
447
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
448
/**/
449
- echo '<p>' . "\n";
450
/**/
451
- echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="' . esc_attr (_x ("Please type your Password twice to confirm.", "s2member-front", "s2member")) . '">' . "\n";
452
- echo '<span>' . _x ("Password ( please type it twice )", "s2member-front", "s2member") . ' *</span><br />' . "\n";
453
- echo '<input type="password" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
454
- echo '</label>' . "\n";
455
/**/
456
- echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="' . esc_attr (_x ("Please type your Password twice to confirm.", "s2member-front", "s2member")) . '">' . "\n";
457
- echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
458
- echo '</label>' . "\n";
459
/**/
460
- echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>' . _x ("password strength indicator", "s2member-front", "s2member") . '</em></div>' . "\n";
461
/**/
462
- echo '</p>' . "\n";
463
/**/
464
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
465
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ());
466
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
467
}
468
/**/
469
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
470
{
471
- echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n";
472
- /**/
473
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
474
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ());
475
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
476
- /**/
477
- echo '<p>' . "\n";
478
- echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">' . "\n";
479
- echo '<span>' . _x ("First Name", "s2member-front", "s2member") . ' *</span><br />' . "\n";
480
- echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
481
- echo '</label>' . "\n";
482
- echo '</p>' . "\n";
483
- /**/
484
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
485
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ());
486
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
487
- /**/
488
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
489
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ());
490
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
491
- /**/
492
- echo '<p>' . "\n";
493
- echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">' . "\n";
494
- echo '<span>' . _x ("Last Name", "s2member-front", "s2member") . ' *</span><br />' . "\n";
495
- echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
496
- echo '</label>' . "\n";
497
- echo '</p>' . "\n";
498
- /**/
499
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
500
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ());
501
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
502
}
503
/**/
504
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
505
- if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
506
{
507
$tabindex = $tabindex + 9; /* Start tabindex at +9 ( +1 below ). */
508
/**/
509
- foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
510
{
511
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
512
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ());
513
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
514
/**/
515
- if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
516
{
517
- $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
518
- $field_id_class = preg_replace ("/_/", "-", $field_var);
519
/**/
520
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
521
- if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
522
{
523
- if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
524
- echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
525
/**/
526
- echo '<p>' . "\n";
527
- echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '">' . "\n";
528
- echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . ((preg_match ("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? '' : '<br />') . "\n";
529
- echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
530
- echo '</p>' . "\n";
531
}
532
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
533
}
534
/**/
535
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
536
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ());
537
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
538
}
539
}
540
/**/
541
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
542
{
543
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
544
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ());
545
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
546
- /**/
547
- echo '<p>' . "\n";
548
- echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
549
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
550
- echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
551
- echo '</label>' . "\n";
552
- echo '</p>' . "\n";
553
- /**/
554
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
555
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ());
556
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
557
}
558
/**/
559
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
560
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ());
561
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
562
/**/
563
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
564
- do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ());
565
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
566
/**/
567
return; /* Return for uniformity. */
568
}
14
* @package s2Member\Custom_Reg_Fields
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_custom_reg_fields"))
21
{
22
/**
23
* Custom Registration/Profile Fields for s2Member.
46
* @param str $_editable_context Optional. One of `profile|profile-view|registration`.
47
* @return str The resulting Custom Field, in HTML format.
48
*/
49
+ public static function custom_field_gen($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_editable_context = FALSE)
50
{
51
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
52
+ do_action("ws_plugin__s2member_before_custom_field_gen", get_defined_vars());
53
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
54
/**/
55
+ if(!($gen = "") && $_function && is_array($field = $_field) && !empty($field["type"]) && !empty($field["id"]) && $_name_prefix && $_id_prefix)
56
{
57
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
58
+ do_action("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars());
59
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
60
+ /**/
61
+ $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
62
+ $field_id_class = preg_replace("/_/", "-", $field_var);
63
+ /**/
64
+ $name_suffix = (preg_match("/\[#x2F;", $_name_prefix)) ? ']' : '';
65
+ $field_name = trim($_name_prefix.$field_var.$name_suffix);
66
+ /**/
67
+ $common = ''; /* Common attributes. */
68
+ $common .= ' name="'.esc_attr($field_name).'"';
69
+ $common .= ' id="'.esc_attr($_id_prefix.$field_id_class).'"';
70
+ $common .= ((!empty($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : '');
71
+ $common .= ((strlen($_tabindex)) ? ' tabindex="'.esc_attr($_tabindex).'"' : /* No tabindex if empty. */ '');
72
+ $common .= (( /* Certain data expected? */!empty($field["expected"])) ? ' data-expected="'.esc_attr($field["expected"]).'"' : '');
73
+ $common .= (($_editable_context === "profile-view" || (!empty($field["editable"]) && strpos($field["editable"], "no") === 0 && $_editable_context === "profile")) ? ' disabled="disabled"' : '');
74
+ $common .= (($_classes || !empty($field["classes"])) ? ' class="'.esc_attr(trim($_classes.((!empty($field["classes"])) ? ' '.$field["classes"] : ''))).'"' : '');
75
+ $common .= (($_styles || !empty($field["styles"])) ? ' style="'.esc_attr(trim($_styles.((!empty($field["styles"])) ? ' '.$field["styles"] : ''))).'"' : '');
76
+ $common .= (($_attrs || !empty($field["attrs"])) ? ' '.trim($_attrs.((!empty($field["attrs"])) ? ' '.$field["attrs"] : '')) : '');
77
+ /**/
78
+ if($field["type"] === "text")
79
{
80
+ if($_editable_context === "profile-view")
81
+ $gen = esc_html((string)$_value);
82
/**/
83
+ else /* Else handle normally. */
84
{
85
$gen = '<input type="text" maxlength="100" autocomplete="off"';
86
+ $gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
87
+ $gen .= $common.' />';
88
}
89
}
90
/**/
91
+ else if($field["type"] === "textarea")
92
{
93
+ if($_editable_context === "profile-view")
94
+ $gen = nl2br(esc_html((string)$_value));
95
/**/
96
+ else /* Else handle normally. */
97
{
98
+ $gen = '<textarea rows="3"'.$common.'>';
99
+ $gen .= format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value);
100
$gen .= '</textarea>';
101
}
102
}
103
/**/
104
+ else if($field["type"] === "select" && !empty($field["options"]))
105
{
106
+ if($_editable_context === "profile-view")
107
{
108
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
109
{
110
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
111
+ if($option_value === (string)$_value)
112
{
113
$gen = $option_label;
114
break;
115
}
116
}
117
}
118
+ else /* Else handle normally. */
119
{
120
+ $gen = '<select'.$common.'>';
121
+ $selected_default_option = false;
122
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
123
{
124
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
125
+ $gen .= '<option value="'.esc_attr($option_value).'"'.(((($option_default && !$_submission) || ($option_value === (string)$_value && !$selected_default_option)) && ($selected_default_option = true)) ? ' selected="selected"' : '').'>'.$option_label.'</option>';
126
}
127
$gen .= '</select>';
128
}
129
}
130
/**/
131
+ else if($field["type"] === "selects" && !empty($field["options"]))
132
{
133
+ if($_editable_context === "profile-view")
134
{
135
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
136
{
137
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
138
+ if(in_array($option_value, (array)$_value))
139
+ $gen .= $option_label.", ";
140
}
141
+ $gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
142
}
143
+ else /* Else handle normally. */
144
{
145
+ $common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
146
+ $common = preg_replace('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
147
/**/
148
+ $gen = '<select multiple="multiple" size="3"'.$common.'>';
149
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line)
150
{
151
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
152
+ $gen .= '<option value="'.esc_attr($option_value).'"'.((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' selected="selected"' : '').'>'.$option_label.'</option>';
153
}
154
$gen .= '</select>';
155
}
156
}
157
/**/
158
+ else if($field["type"] === "checkbox" && !empty($field["label"]))
159
{
160
+ if($_editable_context === "profile-view")
161
$gen = ((string)$_value) ? "yes" : "no";
162
/**/
163
+ else /* Else handle normally. */
164
{
165
$gen = '<input type="checkbox" value="1"';
166
$gen .= (((string)$_value) ? ' checked="checked"' : '');
167
+ $gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
168
}
169
}
170
/**/
171
+ else if($field["type"] === "pre_checkbox" && !empty($field["label"]))
172
{
173
+ if($_editable_context === "profile-view")
174
$gen = ((string)$_value) ? "yes" : "no";
175
/**/
176
+ else /* Else handle normally. */
177
{
178
$gen = '<input type="checkbox" value="1"';
179
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
180
+ $gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>';
181
}
182
}
183
/**/
184
+ else if($field["type"] === "checkboxes" && !empty($field["options"]))
185
{
186
+ if($_editable_context === "profile-view")
187
{
188
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
189
{
190
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
191
+ if(in_array($option_value, (array)$_value))
192
+ $gen .= $option_label.", ";
193
}
194
+ $gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ",");
195
}
196
+ else /* Else handle normally. */
197
{
198
+ $common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common);
199
/**/
200
+ $sep = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_sep", "&nbsp;&nbsp;", get_defined_vars());
201
+ $opl = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
202
/**/
203
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
204
{
205
+ $common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
206
/**/
207
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
208
/**/
209
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
210
+ $gen .= '<input type="checkbox" value="'.esc_attr($option_value).'"';
211
+ $gen .= ((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' checked="checked"' : '');
212
+ $gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
213
}
214
}
215
}
216
/**/
217
+ else if($field["type"] === "radios" && !empty($field["options"]))
218
{
219
+ if($_editable_context === "profile-view")
220
{
221
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
222
{
223
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
224
+ if($option_value === (string)$_value)
225
{
226
$gen = $option_label;
227
break;
228
}
229
}
230
}
231
+ else /* Else handle normally. */
232
{
233
+ $sep = apply_filters("ws_plugin__s2member_custom_field_gen_radios_sep", "&nbsp;&nbsp;", get_defined_vars());
234
+ $opl = apply_filters("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars());
235
/**/
236
+ foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
237
{
238
+ $common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common);
239
/**/
240
+ list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line)));
241
/**/
242
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
243
+ $gen .= '<input type="radio" value="'.esc_attr($option_value).'"';
244
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
245
+ $gen .= $common_i.' /><label for="'.esc_attr($_id_prefix.$field_id_class."-".$i).'" class="'.esc_attr($opl).'" style="display:inline !important; margin:0 !important;">'.$option_label.'</label>';
246
}
247
}
248
}
249
+ else /* Default to a text field input type when nothing matches. */
250
{
251
+ if($_editable_context === "profile-view")
252
+ $gen = esc_html((string)$_value);
253
/**/
254
+ else /* Else handle normally. */
255
{
256
$gen = '<input type="text" maxlength="100" autocomplete="off"';
257
+ $gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"';
258
+ $gen .= $common.' />';
259
}
260
}
261
/**/
262
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
263
+ do_action("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars());
264
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
265
}
266
/**/
267
+ return apply_filters("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars());
268
}
269
/**
270
* Determines which Custom Fields apply to a specific Level.
277
* @param str $_editable_context Optional. One of `profile|profile-view|registration`.
278
* @return array Array of Custom Field IDs applicable.
279
*/
280
+ public static function custom_fields_configured_at_level($_level = "auto-detection", $_editable_context = FALSE)
281
{
282
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
283
+ do_action("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars());
284
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
285
/**/
286
+ $level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level() : $_level;
287
+ if($_level === "auto-detection" && $level < 0 && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number, $m) && !empty($m[1]) && is_numeric($m[1]))
288
+ $level = /* A numeric Membership Level # . */ $m[1];
289
/**/
290
+ $level = ($level !== "any" && (!is_numeric($level) || $level < 0)) ? 0 : /* Default. */ $level;
291
/**/
292
+ if(($level === "any" || (is_numeric($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
293
{
294
+ foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
295
+ if($level === "any" || $field["levels"] === "all" || in_array($level, preg_split("/[;,]+/", preg_replace("/[^0-9;,]/", "", $field["levels"]))))
296
+ if(empty($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible"))
297
$configured[] = $field["id"]; /* Add this to the array. */
298
}
299
/**/
300
+ return apply_filters("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty($configured)) ? $configured : array()), get_defined_vars());
301
}
302
/**
303
* Adds Custom Fields to: `/wp-signup.php`.
313
*
314
* @todo Optimize with ``empty()``.
315
*/
316
+ public static function ms_custom_registration_fields()
317
{
318
+ do_action("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars());
319
/**/
320
+ if(is_multisite() && is_main_site()) /* Must be Main Site of a Network. */
321
{
322
+ $_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
323
/**/
324
+ echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
325
/**/
326
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
327
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars());
328
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
329
/**/
330
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
331
{
332
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
333
/**/
334
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
335
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars());
336
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
337
/**/
338
+ echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'._x("First Name", "s2member-front", "s2member").' *</label>'."\n";
339
+ echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" />'."\n";
340
+ echo '<br />'."\n";
341
/**/
342
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
343
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars());
344
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
345
/**/
346
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
347
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars());
348
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
349
/**/
350
+ echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'._x("Last Name", "s2member-front", "s2member").' *</label>'."\n";
351
+ echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" />'."\n";
352
+ echo '<br />'."\n";
353
/**/
354
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
355
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars());
356
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
357
}
358
/**/
359
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
360
+ if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
361
+ foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
362
{
363
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
364
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars());
365
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
366
/**/
367
+ if(in_array($field["id"], $fields_applicable)) /* Field applicable? */
368
{
369
+ $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
370
+ $field_id_class = preg_replace("/_/", "-", $field_var);
371
/**/
372
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
373
+ if(apply_filters("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
374
{
375
+ if(!empty($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
376
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
377
/**/
378
+ echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'"'.((preg_match("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</label>'.((preg_match("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? '<br />' : '')."\n";
379
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
380
+ echo '<br />'."\n";
381
}
382
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
383
}
384
/**/
385
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
386
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars());
387
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
388
}
389
/**/
390
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
391
{
392
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
393
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars());
394
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
395
/**/
396
+ echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
397
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' />'."\n";
398
+ echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
399
+ echo '</label>'."\n";
400
+ echo '<br />'."\n";
401
/**/
402
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
403
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars());
404
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
405
}
406
/**/
407
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
408
+ do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars());
409
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
410
}
411
/**/
412
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
413
+ do_action("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars());
414
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
415
/**/
416
return; /* Return for uniformity. */
417
}
427
*
428
* @todo Optimize with ``empty()``.
429
*/
430
+ public static function custom_registration_fields()
431
{
432
+ do_action("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars());
433
/**/
434
+ $_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
435
/**/
436
+ echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n";
437
/**/
438
$tabindex = 20; /* Incremented tabindex starting with 20. */
439
/**/
440
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
441
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars());
442
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
443
/**/
444
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
445
{
446
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
447
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars());
448
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
449
/**/
450
+ echo '<p>'."\n";
451
/**/
452
+ echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
453
+ echo '<span>'._x("Password ( please type it twice )", "s2member-front", "s2member").' *</span><br />'."\n";
454
+ echo '<input type="password" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
455
+ echo '</label>'."\n";
456
/**/
457
+ echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n";
458
+ echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="'.format_to_edit($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
459
+ echo '</label>'."\n";
460
/**/
461
+ echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>'._x("password strength indicator", "s2member-front", "s2member").'</em></div>'."\n";
462
/**/
463
+ echo '</p>'."\n";
464
/**/
465
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
466
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars());
467
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
468
}
469
/**/
470
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
471
{
472
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n";
473
+ /**/
474
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
475
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars());
476
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
477
+ /**/
478
+ echo '<p>'."\n";
479
+ echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'."\n";
480
+ echo '<span>'._x("First Name", "s2member-front", "s2member").' *</span><br />'."\n";
481
+ echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_first_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
482
+ echo '</label>'."\n";
483
+ echo '</p>'."\n";
484
+ /**/
485
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
486
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars());
487
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
488
+ /**/
489
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
490
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars());
491
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
492
+ /**/
493
+ echo '<p>'."\n";
494
+ echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'."\n";
495
+ echo '<span>'._x("Last Name", "s2member-front", "s2member").' *</span><br />'."\n";
496
+ echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="'.esc_attr($_p["ws_plugin__s2member_custom_reg_field_last_name"]).'" tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
497
+ echo '</label>'."\n";
498
+ echo '</p>'."\n";
499
+ /**/
500
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
501
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars());
502
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
503
}
504
/**/
505
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
506
+ if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration"))
507
{
508
$tabindex = $tabindex + 9; /* Start tabindex at +9 ( +1 below ). */
509
/**/
510
+ foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
511
{
512
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
513
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars());
514
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
515
/**/
516
+ if(in_array($field["id"], $fields_applicable)) /* Field applicable? */
517
{
518
+ $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
519
+ $field_id_class = preg_replace("/_/", "-", $field_var);
520
/**/
521
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
522
+ if(apply_filters("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars()))
523
{
524
+ if(!empty($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
525
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
526
/**/
527
+ echo '<p>'."\n";
528
+ echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'">'."\n";
529
+ echo '<span'.((preg_match("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</span></label>'.((preg_match("/^(checkbox|pre_checkbox)#x2F;", $field["type"])) ? '' : '<br />')."\n";
530
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
531
+ echo '</p>'."\n";
532
}
533
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
534
}
535
/**/
536
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
537
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars());
538
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
539
}
540
}
541
/**/
542
+ if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated())
543
{
544
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
545
+ do_action("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars());
546
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
547
+ /**/
548
+ echo '<p>'."\n";
549
+ echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n";
550
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"'.(((empty($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '').' tabindex="'.esc_attr(($tabindex = $tabindex + 10)).'" />'."\n";
551
+ echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n";
552
+ echo '</label>'."\n";
553
+ echo '</p>'."\n";
554
+ /**/
555
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
556
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars());
557
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
558
}
559
/**/
560
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
561
+ do_action("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars());
562
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
563
/**/
564
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
565
+ do_action("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars());
566
+ unset($__refs, $__v); /* Unset defined __refs, __v. */
567
/**/
568
return; /* Return for uniformity. */
569
}
includes/classes/files-in.inc.php CHANGED
@@ -14,10 +14,10 @@
14
* @package s2Member\Files
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_files_in"))
21
{
22
/**
23
* File Download routines for s2Member ( inner processing routines ).
@@ -41,16 +41,16 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
41
* @return null|str If called directly with ``$create_file_download_url``, returns a string with the URL, based on configuration.
42
* Else, this function may exit script execution after serving a File Download.
43
*/
44
- public static function check_file_download_access ($create_file_download_url = FALSE)
45
{
46
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
47
- do_action ("ws_plugin__s2member_before_file_download_access", get_defined_vars ());
48
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
49
/**/
50
- $_g = !empty ($_GET) ? $_GET : array ();
51
- $_g = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_g));
52
/**/
53
- $creating = /* Creating URL? */ (is_array ($create = $create_file_download_url)) ? true : false;
54
$serving = /* If NOT creating a File Download URL, we're serving one. */ (!$creating) ? true : false;
55
/**/
56
$req["file_download"] = ($creating) ? @$create["file_download"] : @$_g["s2member_file_download"];
@@ -70,143 +70,144 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
70
$req["count_against_user"] = ($creating) ? @$create["count_against_user"] : /* N/A. */ null;
71
$req["check_user"] = ($creating) ? @$create["check_user"] : /* N/A. */ null;
72
/**/
73
- if ($req["file_download"] && is_string ($req["file_download"]) && ($req["file_download"] = trim ($req["file_download"], "/")))
74
- if (strpos ($req["file_download"], "..") === false && strpos (basename ($req["file_download"]), ".") !== 0)
75
{
76
- $using_amazon_s3_storage = ((!$req["file_storage"] || strcasecmp ((string)$req["file_storage"], "s3") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_s3_storage ()) ? true : false;
77
- $using_amazon_cf_storage = ((!$req["file_storage"] || strcasecmp ((string)$req["file_storage"], "cf") === 0) && c_ws_plugin__s2member_utils_conds::using_amazon_cf_storage ()) ? true : false;
78
$using_amazon_storage = /* Either/or? */ ($using_amazon_s3_storage || $using_amazon_cf_storage) ? true : false;
79
/**/
80
- $excluded = apply_filters ("ws_plugin__s2member_check_file_download_access_excluded", false, get_defined_vars ());
81
- $valid_file_download_key = ($req["file_download_key"] && is_string ($req["file_download_key"])) ? c_ws_plugin__s2member_files_in::check_file_download_key ($req["file_download"], $req["file_download_key"]) : false;
82
- $checking_user = ($excluded || $valid_file_download_key || ($creating && (!isset ($req["check_user"]) || !filter_var ($req["check_user"], FILTER_VALIDATE_BOOLEAN)) && (!isset ($req["count_against_user"]) || !filter_var ($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
83
- $updating_user_counter = (!$checking_user || ($creating && (!isset ($req["count_against_user"]) || !filter_var ($req["count_against_user"], FILTER_VALIDATE_BOOLEAN)))) ? false : true;
84
/**/
85
- if ( /* In either case, the following routines apply whenever we ARE ``$checking_user``. */($serving || $creating) && $checking_user)
86
{
87
- if (!$using_amazon_storage && !file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $req["file_download"]))
88
{
89
- if /* We only need this section when/if we're actually serving. */ ($serving)
90
- status_header (404) . header ("Content-Type: text/html; charset=utf-8") . eval ('while (@ob_end_clean ());') #
91
- . exit (_x ('<strong>404: Sorry, file not found.</strong> Please contact Support for assistance.', "s2member-front", "s2member"));
92
/**/
93
else /* Else return false. */
94
return false;
95
}
96
/**/
97
- else if ($req["file_download_key"] && is_string ($req["file_download_key"]) && !$valid_file_download_key)
98
{
99
- if /* We only need this section when/if we're actually serving. */ ($serving)
100
- status_header (503) . header ("Content-Type: text/html; charset=utf-8") . eval ('while (@ob_end_clean ());') #
101
- . exit (_x ('<strong>503 ( Invalid Key ):</strong> Sorry, your access to this file has expired. Please contact Support for assistance.', "s2member-front", "s2member"));
102
/**/
103
else /* Else return false. */
104
return false;
105
}
106
/**/
107
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads ()) === false)
108
{
109
- if /* We only need remote functionality when/if we're actually serving. */ ($serving)
110
- if (!has_filter ("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
111
- add_filter ("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
112
/**/
113
- if /* We only need remote functionality when/if we're actually serving. */ ($creating)
114
- if (has_filter ("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization"))
115
- remove_filter ("ws_plugin__s2member_check_file_download_access_user", "c_ws_plugin__s2member_files_in::check_file_remote_authorization", 10, 2);
116
/**/
117
- if ((isset ($file_downloads_enabled_by_site_owner, $min_level_4_downloads) && $file_downloads_enabled_by_site_owner === false) || ($file_downloads_enabled_by_site_owner = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads ()) === false)
118
{
119
- if /* We only need this section when/if we're actually serving. */ ($serving)
120
- status_header (503) . header ("Content-Type: text/html; charset=utf-8") . eval ('while (@ob_end_clean ());') #
121
- . exit (_x ('<strong>503: Basic File Downloads are NOT enabled yet.</strong> Please contact Support for assistance. If you are the site owner, please configure: <code>s2Member -> Download Options -> Basic Download Restrictions</code>.', "s2member-front", "s2member"));
122
/**/
123
else /* Else return false. */
124
return false;
125
}
126
/**/
127
- else if (!is_object ($user = apply_filters ("ws_plugin__s2member_check_file_download_access_user", ((is_user_logged_in ()) ? wp_get_current_user () : false), get_defined_vars ())) || empty ($user->ID) || !($user_id = $user->ID) || !is_array ($user_file_downloads = c_ws_plugin__s2member_files::user_downloads ($user)) || (!$user->has_cap ("administrator") && (!$user_file_downloads["allowed"] || !$user_file_downloads["allowed_days"])))
128
{
129
- if (preg_match ("/^access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen ($req_level = $m[1]) && (!is_object ($user) || empty ($user->ID) || !$user->has_cap ("access_s2member_level" . $req_level)))
130
{
131
- if /* We only need this section when/if we're actually serving. */ ($serving)
132
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]) . exit ();
133
/**/
134
else /* Else return false. */
135
return false;
136
}
137
/**/
138
- else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen ($req_ccap = preg_replace ("/-/", "_", $m[1])) && (!is_object ($user) || empty ($user->ID) || !$user->has_cap ("access_s2member_ccap_" . $req_ccap)))
139
{
140
- if /* We only need this section when/if we're actually serving. */ ($serving)
141
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]) . exit ();
142
/**/
143
else /* Else return false. */
144
return false;
145
}
146
/**/
147
- else if /* We only need this section when/if we're actually serving. */ ($serving)
148
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("file", $req["file_download"], "level", $min_level_4_downloads, $_SERVER["REQUEST_URI"]) . exit ();
149
/**/
150
else /* Else return false. */
151
return false;
152
}
153
/**/
154
- else if (preg_match ("/^access[_\-]s2member[_\-]level([0-9]+)\//", $req["file_download"], $m) && strlen ($req_level = $m[1]) && !$user->has_cap ("access_s2member_level" . $req_level))
155
{
156
- if /* We only need this section when/if we're actually serving. */ ($serving)
157
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("file", $req["file_download"], "level", $req_level, $_SERVER["REQUEST_URI"]) . exit ();
158
/**/
159
else /* Else return false. */
160
return false;
161
}
162
/**/
163
- else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $req["file_download"], $m) && strlen ($req_ccap = preg_replace ("/-/", "_", $m[1])) && !$user->has_cap ("access_s2member_ccap_" . $req_ccap))
164
{
165
- if /* We only need this section when/if we're actually serving. */ ($serving)
166
- c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */ ("file", $req["file_download"], "ccap", $req_ccap, $_SERVER["REQUEST_URI"]) . exit ();
167
/**/
168
else /* Else return false. */
169
return false;
170
}
171
/**/
172
- else if /* In either case, the following routines apply. */ ($serving || $creating)
173
{
174
$user_previous_file_downloads = /* Downloads the User has already; in current period/cycle. */ 0;
175
$user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = false;
176
/**/
177
- $user_file_download_access_log = (is_array ($user_file_download_access_log = get_user_option ("s2member_file_download_access_log", $user_id))) ? $user_file_download_access_log : array ();
178
- $user_file_download_access_arc = (is_array ($user_file_download_access_arc = get_user_option ("s2member_file_download_access_arc", $user_id))) ? $user_file_download_access_arc : array ();
179
/**/
180
- $streaming_file_extns = c_ws_plugin__s2member_utils_strings::preg_quote_deep ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["streaming_file_extns"], "/");
181
- $streaming_variations = /* Only count one streaming media file variation. */ "/\.(" . implode ("|", $streaming_file_extns) . ")#x2F;i";
182
/**/
183
- foreach ($user_file_download_access_log as $user_file_download_access_log_entry_key => $user_file_download_access_log_entry)
184
{
185
- if ( /* Weed out corrupt/empty log entries. */isset ($user_file_download_access_log_entry["date"], $user_file_download_access_log_entry["file"]))
186
{
187
- if (strtotime ($user_file_download_access_log_entry["date"]) < strtotime ("-" . $user_file_downloads["allowed_days"] . " days"))
188
{
189
- unset /* Remove it from the `log`. */ ($user_file_download_access_log[$user_file_download_access_log_entry_key]);
190
$user_file_download_access_arc[] = /* Move `log` entry to the `archive` now. */ $user_file_download_access_log_entry;
191
}
192
- else if (strtotime ($user_file_download_access_log_entry["date"]) >= strtotime ("-" . $user_file_downloads["allowed_days"] . " days"))
193
{
194
$user_previous_file_downloads++; /* Previous files always count against this User/Member. */
195
/**/
196
$_user_file_download_access_log_entry = &$user_file_download_access_log[$user_file_download_access_log_entry_key];
197
$_user_already_downloaded_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = false;
198
/**/
199
- if /* Already downloaded this file? If yes, mark this flag as true. */ ($user_file_download_access_log_entry["file"] === $req["file_download"])
200
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = /* Already downloaded this file? If yes, mark as true. */ true;
201
/**/
202
- else if (preg_replace ($streaming_variations, "", $user_file_download_access_log_entry["file"]) === preg_replace ($streaming_variations, "", $req["file_download"]))
203
$user_already_downloaded_this_file = $_user_already_downloaded_this_file = $user_already_downloaded_a_streaming_variation_of_this_file = $_user_already_downloaded_a_streaming_variation_of_this_file = true;
204
/**/
205
- if ( /* Updating counter? */$updating_user_counter && ($_user_already_downloaded_this_file || $_user_already_downloaded_a_streaming_variation_of_this_file))
206
{
207
- $_user_file_download_access_log_entry /* First, we update the last download time for this file. */["ltime"] = time ();
208
/**/
209
- if ( /* Backward compatiility here. Is this even set? */!empty ($user_file_download_access_log_entry["counter"]))
210
$_user_file_download_access_log_entry["counter"] = (int)$user_file_download_access_log_entry["counter"] + 1;
211
else /* Backward compatiility here. Default value to `1`, if this is NOT even set yet. */
212
$_user_file_download_access_log_entry["counter"] = 1 + 1;
@@ -214,185 +215,198 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
214
}
215
}
216
else /* Weed out empty log entries. Some older versions of s2Member may have corrupt/empty log entries. */
217
- unset ($user_file_download_access_log[$user_file_download_access_log_entry_key]); /* Remove. */
218
}
219
- if ( /* Updating counter? */$updating_user_counter && /* Do we need a new log entry for this file? */ !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file)
220
- $user_file_download_access_log[] = array ("date" => date ("Y-m-d"), "time" => time (), "ltime" => time (), "file" => $req["file_download"], "counter" => 1);
221
/**/
222
- if ($user_previous_file_downloads >= $user_file_downloads["allowed"] && !$user_already_downloaded_this_file && !$user_already_downloaded_a_streaming_variation_of_this_file && !$user->has_cap ("administrator"))
223
{
224
- if /* We only need this section when/if we're actually serving. */ ($serving)
225
- wp_redirect (add_query_arg (urlencode_deep (array ("_s2member_seeking" => array ("type" => "file", "file" => $req["file_download"], "_uri" => base64_encode ($_SERVER["REQUEST_URI"])), "s2member_seeking" => "file-" . $req["file_download"])), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) . exit ();
226
/**/
227
else /* Else return false. */
228
return false;
229
}
230
- else if /* Save/update counter? By default, we do NOT update the counter when a URL is simply being created for access. */ ($updating_user_counter)
231
- update_user_option ($user_id, "s2member_file_download_access_log", c_ws_plugin__s2member_utils_arrays::array_unique ($user_file_download_access_log)) . update_user_option ($user_id, "s2member_file_download_access_arc", c_ws_plugin__s2member_utils_arrays::array_unique ($user_file_download_access_arc));
232
}
233
}
234
}
235
else /* Otherwise, we're either NOT ``$checking_user``; or permission was granted with a valid File Download Key. */
236
{
237
- if (!$using_amazon_storage && !file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $req["file_download"]))
238
{
239
- if /* We only need this section when/if we're actually serving. */ ($serving)
240
- status_header (404) . header ("Content-Type: text/html; charset=utf-8") . eval ('while (@ob_end_clean ());') #
241
- . exit (_x ('<strong>404: Sorry, file not found.</strong> Please contact Support for assistance.', "s2member-front", "s2member"));
242
/**/
243
else /* Else return false. */
244
return false;
245
}
246
}
247
/**/
248
- if /* In either case, the following routines apply. */ ($serving || $creating)
249
{
250
- $basename = basename ($req["file_download"]);
251
- $mimetypes = parse_ini_file (dirname (dirname (dirname (__FILE__))) . "/includes/mime-types.ini");
252
- $extension = strtolower (substr ($req["file_download"], strrpos ($req["file_download"], ".") + 1));
253
/**/
254
- $key = ($req["file_download_key"] && is_string ($req["file_download_key"])) ? $req["file_download_key"] : false;
255
/**/
256
- $stream = (isset ($req["file_stream"])) ? filter_var ($req["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array ($extension, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
257
- $inline = (!$stream && isset ($req["file_inline"])) ? filter_var ($req["file_inline"], FILTER_VALIDATE_BOOLEAN) : (($stream || in_array ($extension, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]))) ? true : false);
258
- $ssl = (isset ($req["file_ssl"])) ? filter_var ($req["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl ()) ? true : false);
259
- $storage = ($req["file_storage"] && is_string ($req["file_storage"])) ? strtolower ($req["file_storage"]) : false;
260
- $remote = (isset ($req["file_remote"])) ? filter_var ($req["file_remote"], FILTER_VALIDATE_BOOLEAN) : false;
261
/**/
262
- $rewrite_base_guess = dirname ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . "/" . c_ws_plugin__s2member_utils_dirs::basename_dir_app_data ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]);
263
- $rewrite_base = ($req["file_rewrite_base"] && is_string ($req["file_rewrite_base"])) ? $req["file_rewrite_base"] : false;
264
- $rewrite = $rewriting = (!$rewrite_base && isset ($req["file_rewrite"])) ? filter_var ($req["file_rewrite"], FILTER_VALIDATE_BOOLEAN) : (($rewrite_base) ? true : false);
265
/**/
266
- $skip_confirmation = (isset ($req["skip_confirmation"])) ? filter_var ($req["skip_confirmation"], FILTER_VALIDATE_BOOLEAN) : false;
267
- $url_to_storage_source = (isset ($req["url_to_storage_source"])) ? filter_var ($req["url_to_storage_source"], FILTER_VALIDATE_BOOLEAN) : false;
268
/**/
269
- $pathinfo = (!$using_amazon_storage) ? pathinfo (($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $req["file_download"])) : array ();
270
$mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream";
271
- $length = (!$using_amazon_storage && $file) ? filesize ($file) : -1;
272
/**/
273
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
274
- do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
275
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
276
/**/
277
- if ($using_amazon_s3_storage && ($serving || ($creating && $url_to_storage_source)))
278
{
279
- if /* We only need this section when/if we're actually serving. */ ($serving)
280
- wp_redirect (c_ws_plugin__s2member_files_in::amazon_s3_url ($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)) . exit ();
281
/**/
282
else /* Else return File Download URL. */
283
- return apply_filters ("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_s3_url ($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars ());
284
}
285
/**/
286
- else if ($using_amazon_cf_storage && ($serving || ($creating && $url_to_storage_source)))
287
{
288
- if /* We only need this section when/if we're actually serving. */ ($serving)
289
- wp_redirect (c_ws_plugin__s2member_files_in::amazon_cf_url ($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype)) . exit ();
290
/**/
291
else /* Else return File Download URL. */
292
- return apply_filters ("ws_plugin__s2member_file_download_access_url", c_ws_plugin__s2member_files_in::amazon_cf_url ($req["file_download"], $stream, $inline, $ssl, $basename, $mimetype), get_defined_vars ());
293
}
294
/**/
295
- else if /* Creating a rewrite URL, pointing to local storage. */ ($creating && $rewriting)
296
{
297
- $url = ($rewrite_base) ? rtrim ($rewrite_base, "/") : rtrim ($rewrite_base_guess, "/");
298
- $url .= (isset ($req["file_download_key"])) ? (($key) ? "/s2member-file-download-key-" . $key : "") : "";
299
- $url .= (isset ($req["file_stream"])) ? (($stream) ? "/s2member-file-stream" : "/s2member-file-stream-no") : "";
300
- $url .= (isset ($req["file_inline"])) ? (($inline) ? "/s2member-file-inline" : "/s2member-file-inline-no") : "";
301
- $url .= (isset ($req["file_storage"])) ? (($storage) ? "/s2member-file-storage-" . $storage : "") : "";
302
- $url .= (isset ($req["file_remote"])) ? (($remote) ? "/s2member-file-remote" : "/s2member-file-remote-no") : "";
303
- $url .= (isset ($req["skip_confirmation"])) ? (($skip_confirmation) ? "/s2member-skip-confirmation" : "/s2member-skip-confirmation-no") : "";
304
/**/
305
- $url = /* File Download Access URL via `mod_rewrite` functionality. */ $url . "/" . $req["file_download"];
306
- $url = ($ssl) ? preg_replace ("/^https?/", "https", $url) : preg_replace ("/^https?/", "http", $url);
307
/**/
308
- return apply_filters ("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars ());
309
}
310
/**/
311
- else if /* Else we're creating a URL w/ a query-string; w/ local storage. */ ($creating)
312
{ /* Note: we don't URL encode unreserved chars. Improves media player compatibility. */
313
- $_url_e_key = ($key) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode ($key)) : "";
314
- $_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode ($storage)) : "";
315
- $_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode ($req["file_download"]));
316
/**/
317
- $url = (isset ($req["file_download_key"])) ? (($key && $_url_e_key) ? "&s2member_file_download_key=" . $_url_e_key : "") : "";
318
- $url .= (isset ($req["file_stream"])) ? (($stream) ? "&s2member_file_stream=yes" : "&s2member_file_stream=no") : "";
319
- $url .= (isset ($req["file_inline"])) ? (($inline) ? "&s2member_file_inline=yes" : "&s2member_file_inline=no") : "";
320
- $url .= (isset ($req["file_storage"])) ? (($storage && $_url_e_storage) ? "&s2member_file_storage=" . $_url_e_storage : "") : "";
321
- $url .= (isset ($req["file_remote"])) ? (($remote) ? "&s2member_file_remote=yes" : "&s2member_file_remote=no") : "";
322
- $url .= (isset ($req["skip_confirmation"])) ? (($skip_confirmation) ? "&s2member_skip_confirmation=yes" : "&s2member_skip_confirmation=no") : "";
323
/**/
324
- $url = site_url ("/?" . ltrim ($url . "&s2member_file_download=/" . $_url_e_file, "&"));
325
- $url = ($ssl) ? preg_replace ("/^https?/", "https", $url) : preg_replace ("/^https?/", "http", $url);
326
/**/
327
- return apply_filters ("ws_plugin__s2member_file_download_access_url", $url, get_defined_vars ());
328
}
329
/**/
330
else /* Else, ``if ($serving)``, use local storage option. */
331
{
332
- @set_time_limit (0) . @ini_set ("zlib.output_compression", 0);
333
/**/
334
- status_header /* 200 OK status header. */ (200);
335
/**/
336
- header ("Content-Encoding:");
337
- header ("Accept-Ranges: none");
338
- header ("Content-Type: " . $mimetype);
339
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
340
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
341
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
342
- header ("Cache-Control: post-check=0, pre-check=0", false);
343
- header ("Pragma: no-cache");
344
/**/
345
- header ('Content-Disposition: ' . (($inline) ? "inline" : "attachment") . '; filename="' . $basename . '"');
346
/**/
347
- eval /* End/clean any output buffers that may exist already. Prep for content delivery. */ ('while (@ob_end_clean ());');
348
/**/
349
- $_chunk_file = ($_SERVER["SERVER_PROTOCOL"] === "HTTP/1.1" && preg_match ("/apache/i", $_SERVER["SERVER_SOFTWARE"])) ? true : false;
350
- /**/
351
- if ($length && apply_filters ("ws_plugin__s2member_chunk_file_downloads", $_chunk_file, get_defined_vars ()) && is_resource ($resource = fopen ($file, "rb")))
352
{
353
- $_chunk_size = apply_filters ("ws_plugin__s2member_chunk_file_downloads_w_chunk_size", 2097152, get_defined_vars ());
354
/**/
355
- if (apply_filters ("ws_plugin__s2member_chunk_file_downloads_w_content_length", true, get_defined_vars ()))
356
- header ("Content-Length: " . $length);
357
/**/
358
- header /* `Transfer-Encoding: chunked` conserves memory. */ ("Transfer-Encoding: chunked");
359
/**/
360
- while (!feof ($resource) && ($chunk_size = strlen ($data = fread ($resource, $_chunk_size))))
361
- eval ('echo dechex ($chunk_size) . "\r\n". $data . "\r\n"; @flush ();');
362
/**/
363
- fclose ($resource) . exit ("0\r\n\r\n");
364
}
365
- else if ($length && apply_filters ("ws_plugin__s2member_flush_file_downloads", true, get_defined_vars ()) && is_resource ($resource = fopen ($file, "rb")))
366
{
367
- $_flush_size = apply_filters ("ws_plugin__s2member_flush_file_downloads_w_flush_size", 2097152, get_defined_vars ());
368
/**/
369
- if (apply_filters ("ws_plugin__s2member_flush_file_downloads_w_content_length", true, get_defined_vars ()))
370
- header ("Content-Length: " . $length);
371
/**/
372
- while (!feof ($resource) && ($flush_size = strlen ($data = fread ($resource, $_flush_size))))
373
- eval /* Conserves memory. */ ('echo $data; @flush ();');
374
}
375
- else if /* Else, use: ``file_get_contents()``. */ ($length)
376
{
377
- @ini_set /* RAM/memory. */ ("memory_limit", WP_MAX_MEMORY_LIMIT);
378
- header ("Content-Length: " . $length) . exit (file_get_contents ($file));
379
}
380
else /* Else, we have an empty file with no length. */
381
{
382
- header ("Content-Length: 0") . exit ();
383
}
384
}
385
}
386
}
387
/**/
388
- else if /* We only need this section when/if we're actually serving. */ ($serving && $req["file_download"])
389
- status_header (503) . header ("Content-Type: text/html; charset=utf-8") . eval ('while (@ob_end_clean ());') #
390
- . exit (_x ('<strong>503: Access denied.</strong> Invalid File Download specs.', "s2member-front", "s2member"));
391
/**/
392
- else if /* We only need this section when/if we're creating a URL. */ ($creating)
393
return false;
394
/**/
395
- do_action ("ws_plugin__s2member_after_file_download_access", get_defined_vars ());
396
/**/
397
return ($creating) ? /* If creating, false. */ false : null;
398
}
@@ -409,44 +423,44 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
409
*
410
* @see s2Member\API_Functions\s2member_file_download_url()
411
*/
412
- public static function create_file_download_url ($config = FALSE, $get_streamer_array = FALSE)
413
{
414
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
415
- do_action ("ws_plugin__s2member_before_create_file_download_url", get_defined_vars ());
416
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
417
/**/
418
- $config = (is_array ($config)) ? $config : /* This absolutely MUST be an array. */ array ();
419
/**/
420
- $config["file_download"] = (isset ($config["file_download"]) && is_string ($config["file_download"])) ? trim ($config["file_download"], "/") : @$config["file_download"];
421
- $config["file_download_key"] = (isset ($config["file_download"]) && is_string ($config["file_download"]) && !empty ($config["file_download_key"])) ? c_ws_plugin__s2member_files::file_download_key ($config["file_download"], ((in_array ($config["file_download_key"], array ("ip-forever", "universal", "cache-compatible"))) ? $config["file_download_key"] : false)) : @$config["file_download_key"];
422
/**/
423
$config["url_to_storage_source"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["url_to_storage_source"];
424
$config["file_stream"] = /* Force a streaming URL here via ``$get_streamer_array``? */ ($get_streamer_array) ? true : @$config["file_stream"];
425
/**/
426
- if (($_url = c_ws_plugin__s2member_files_in::check_file_download_access /* Successfully created a URL to the file? */ (($create_file_download_url = $config))))
427
{
428
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
429
- do_action ("ws_plugin__s2member_during_create_file_download_url", get_defined_vars ());
430
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
431
/**/
432
- $extension = strtolower (substr ($config["file_download"], strrpos ($config["file_download"], ".") + 1));
433
- $streaming = (isset ($config["file_stream"])) ? filter_var ($config["file_stream"], FILTER_VALIDATE_BOOLEAN) : ((in_array ($extension, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_stream_extensions"]))) ? true : false);
434
- $ssl = (isset ($config["file_ssl"])) ? filter_var ($config["file_ssl"], FILTER_VALIDATE_BOOLEAN) : ((is_ssl ()) ? true : false);
435
/**/
436
- if ($get_streamer_array && $streaming && ($cfx = "/cfx/st") && ($cfx_pos = strpos ($_url, $cfx)) !== false && ($streamer = substr ($_url, 0, $cfx_pos + strlen ($cfx))) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access (array_merge ($config, array ("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
437
- $return = array ("streamer" => $streamer, "file" => preg_replace ("/^" . preg_quote ($streamer, "/") . "\//", "", $_url), "url" => preg_replace ("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
438
/**/
439
- else if ($get_streamer_array && $streaming && is_array ($ups = c_ws_plugin__s2member_utils_urls::parse_url ($_url)) && isset ($ups["scheme"], $ups["host"]) && ($streamer = $ups["scheme"] . "://" . $ups["host"] . ((!empty ($ups["port"])) ? ":" . $ups["port"] : "")) && ($url = c_ws_plugin__s2member_files_in::check_file_download_access (array_merge ($config, array ("file_stream" => false, "check_user" => false, "count_against_user" => false)))))
440
- $return = array ("streamer" => $streamer, "file" => preg_replace ("/^" . preg_quote ($streamer, "/") . "\//", "", $_url), "url" => preg_replace ("/^.+?\:/", (($ssl) ? "https:" : "http:"), $url));
441
/**/
442
- else if /* If streamer, we MUST return false here; unable to acquire streamer/file. */ ($get_streamer_array)
443
$return = /* We MUST return false here, unable to acquire streamer/file. */ false;
444
/**/
445
else /* Else return URL string ( ``$get_streamer_array`` is false ). */
446
$return = /* Else return URL string. */ $_url;
447
}
448
/**/
449
- return apply_filters ("ws_plugin__s2member_create_file_download_url", ((isset ($return)) ? $return : false), get_defined_vars ());
450
}
451
/**
452
* Checks Header Authorization for Remote File Downloads.
@@ -459,34 +473,34 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
459
* @param obj $user Expects a WP_User object passed in by the Filter.
460
* @return obj A `WP_User` object, possibly obtained through Header Authorization.
461
*/
462
- public static function check_file_remote_authorization ($user = FALSE)
463
{
464
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
465
- do_action ("ws_plugin__s2member_before_check_file_remote_authorization", get_defined_vars ());
466
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
467
/**/
468
- $_g = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep (((!empty ($_GET)) ? $_GET : array ())));
469
/**/
470
- if (!is_object ($user) && isset ($_g["s2member_file_remote"]) && filter_var ($_g["s2member_file_remote"], FILTER_VALIDATE_BOOLEAN))
471
{
472
- do_action ("ws_plugin__s2member_during_check_file_remote_authorization_before", get_defined_vars ());
473
/**/
474
- if (empty ($_SERVER["PHP_AUTH_USER"]) || empty ($_SERVER["PHP_AUTH_PW"]) || !user_pass_ok ($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
475
{
476
- header ('WWW-Authenticate: Basic realm="' . c_ws_plugin__s2member_utils_strings::esc_dq (strip_tags (_x ("Members Only", "s2member-front", "s2member"))) . '"');
477
/**/
478
- status_header /* Send an unauthorized 401 status header now. */ (401);
479
- header /* Content-Type with UTF-8. */ ("Content-Type: text/html; charset=utf-8");
480
- eval /* End/clean any output buffers that may exist. */ ('while (@ob_end_clean ());');
481
/**/
482
- exit (_x ('<strong>401:</strong> Sorry, access denied.', "s2member-front", "s2member"));
483
}
484
- else if (is_object ($_user = new WP_User ($_SERVER["PHP_AUTH_USER"])) && !empty ($_user->ID))
485
$user = /* Now assign ``$user``. */ $_user;
486
/**/
487
- do_action ("ws_plugin__s2member_during_check_file_remote_authorization_after", get_defined_vars ());
488
}
489
- return apply_filters ("ws_plugin__s2member_check_file_remote_authorization", $user, get_defined_vars ());
490
}
491
/**
492
* Checks a File Download Key for validity.
@@ -498,22 +512,22 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
498
* @param str $key Input File Download Key to validate.
499
* @return bool True if valid, else false.
500
*/
501
- public static function check_file_download_key ($file = FALSE, $key = FALSE)
502
{
503
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
504
- do_action ("_ws_plugin__s2member_before_check_file_download_key", get_defined_vars ());
505
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
506
/**/
507
- if ($file && is_string ($file) && ($file = trim ($file, "/")) && $key && is_string ($key))
508
{
509
- if ($key === c_ws_plugin__s2member_files::file_download_key ($file) || $key === c_ws_plugin__s2member_files::file_download_key ("/" . $file))
510
$valid = /* File Download Key is valid. */ true;
511
- else if ($key === c_ws_plugin__s2member_files::file_download_key ($file, "ip-forever") || $key === c_ws_plugin__s2member_files::file_download_key ("/" . $file, "ip-forever"))
512
$valid = /* File Download Key is valid. */ true;
513
- else if ($key === c_ws_plugin__s2member_files::file_download_key ($file, "universal") || $key === c_ws_plugin__s2member_files::file_download_key ("/" . $file, "universal"))
514
$valid = /* File Download Key is valid. */ true;
515
}
516
- return apply_filters ("ws_plugin__s2member_check_file_download_key", ((isset ($valid) && $valid) ? true : false), get_defined_vars ());
517
}
518
/**
519
* Creates an Amazon® S3 HMAC-SHA1 signature.
@@ -524,11 +538,11 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
524
* @param str $string Input string/data, to be signed by this routine.
525
* @return str An HMAC-SHA1 signature for Amazon® S3.
526
*/
527
- public static function amazon_s3_sign ($string = FALSE)
528
{
529
$s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
530
/**/
531
- return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign ((string)$string, $s3c["secret_key"]);
532
}
533
/**
534
* Creates an Amazon® S3 HMAC-SHA1 signature URL.
@@ -544,24 +558,24 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
544
* @param str $mimetype The MIME content-type of the resource file.
545
* @return str An HMAC-SHA1 signature URL for Amazon® S3.
546
*/
547
- public static function amazon_s3_url ($file = FALSE, $stream = FALSE, $inline = FALSE, $ssl = FALSE, $basename = FALSE, $mimetype = FALSE)
548
{
549
- $file = /* Trim / force string. */ trim ((string)$file, "/");
550
/**/
551
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
552
- if (preg_match ("/^amazon_s3_files_/", $option) && ($option = preg_replace ("/^amazon_s3_files_/", "", $option)))
553
$s3c[$option] = $option_value;
554
/**/
555
- $s3c["expires"] = strtotime ("+" . apply_filters ("ws_plugin__s2member_amazon_s3_file_expires_time", "30 seconds", get_defined_vars ()));
556
/**/
557
- $s3_file = add_query_arg (c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep (urlencode_deep (array ("response-cache-control" => ($s3_cache_control = "no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"), "response-content-disposition" => ($s3_content_disposition = (((bool)$inline) ? "inline" : "attachment") . '; filename="' . (string)$basename . '"'), "response-content-type" => ($s3_content_type = (string)$mimetype), "response-expires" => ($s3_expires = gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT")))), "/" . $file);
558
- $s3_raw_file = add_query_arg (array ("response-cache-control" => $s3_cache_control, "response-content-disposition" => $s3_content_disposition, "response-content-type" => $s3_content_type, "response-expires" => $s3_expires), "/" . $file);
559
- $s3_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("GET\n\n\n" . $s3c["expires"] . "\n" . "/" . $s3c["bucket"] . $s3_raw_file));
560
/**/
561
- $s3_url = ((strtolower ($s3c["bucket"]) !== $s3c["bucket"])) ? "http" . (($ssl) ? "s" : "") . "://s3.amazonaws.com/" . $s3c["bucket"] . $s3_file : "http" . (($ssl) ? "s" : "") . "://" . $s3c["bucket"] . ".s3.amazonaws.com" . $s3_file;
562
/**/
563
- return add_query_arg (c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep /* Don't encode unreserved chars. Maximizes media player compatibility. */
564
- (urlencode_deep (array ("AWSAccessKeyId" => $s3c["access_key"], "Expires" => $s3c["expires"], "Signature" => $s3_signature))), $s3_url);
565
}
566
/**
567
* Auto-configures an Amazon® S3 Bucket's ACLs.
@@ -572,82 +586,82 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
572
* @return array Array containing a true `success` element on success, else a failure array.
573
* Failure array will contain a failure `code`, and a failure `message`.
574
*/
575
- public static function amazon_s3_auto_configure_acls ()
576
{
577
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
578
- if (preg_match ("/^amazon_s3_files_/", $option) && ($option = preg_replace ("/^amazon_s3_files_/", "", $option)))
579
$s3c[$option] = $option_value;
580
/**/
581
$cfc["distros_s3_access_id"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_s3_access_id"];
582
/**/
583
- if /* Must have Amazon® S3 Bucket/Keys. */ ($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
584
{
585
- $s3_date = gmdate ("D, d M Y H:i:s") . " GMT";
586
- $s3_location = ((strtolower ($s3c["bucket"]) !== $s3c["bucket"])) ? "/" . $s3c["bucket"] . "/?acl" : "/?acl";
587
- $s3_domain = ((strtolower ($s3c["bucket"]) !== $s3c["bucket"])) ? "s3.amazonaws.com" : $s3c["bucket"] . ".s3.amazonaws.com";
588
- $s3_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("GET\n\n\n" . $s3_date . "\n/" . $s3c["bucket"] . "/?acl"));
589
- $s3_args = array ("method" => "GET", "headers" => array ("Host" => $s3_domain, "Date" => $s3_date, "Authorization" => "AWS " . $s3c["access_key"] . ":" . $s3_signature));
590
/**/
591
- if (($s3_response = c_ws_plugin__s2member_utils_urls::remote ("https://" . $s3_domain . $s3_location, false, array_merge ($s3_args, array ("timeout" => 20)), "array")) && $s3_response["code"] === 200)
592
{
593
- if (preg_match ("/\<Owner\>(.+?)\<\/Owner\>/is", $s3_response["body"], $s3_owner_tag) && preg_match ("/\<ID\>(.+?)\<\/ID\>/is", $s3_owner_tag[1], $s3_owner_id_tag) && (preg_match ("/\<DisplayName\>(.*?)\<\/DisplayName\>/is", $s3_owner_tag[1], $s3_owner_display_name_tag) || ($s3_owner_display_name_tag = array ("-", "Owner"))))
594
{
595
- $s3_owner = array ("access_id" => trim ($s3_owner_id_tag[1]), "display_name" => trim ($s3_owner_display_name_tag[1]));
596
- $s3_acls_xml = '<AccessControlPolicy><Owner><ID>' . esc_html ($s3_owner["access_id"]) . '</ID><DisplayName>' . esc_html ($s3_owner["display_name"]) . '</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>' . esc_html ($s3_owner["access_id"]) . '</ID><DisplayName>' . esc_html ($s3_owner["display_name"]) . '</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant>' . (($cfc["distros_s3_access_id"]) ? '<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>' . esc_html ($cfc["distros_s3_access_id"]) . '</ID><DisplayName>s2Member/CloudFront</DisplayName></Grantee><Permission>READ</Permission></Grant>' : '') . '</AccessControlList></AccessControlPolicy>';
597
- $s3_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("PUT\n\napplication/xml\n" . $s3_date . "\n/" . $s3c["bucket"] . "/?acl"));
598
- $s3_args = array ("method" => "PUT", "body" => $s3_acls_xml, "headers" => array ("Host" => $s3_domain, "Content-Type" => "application/xml", "Date" => $s3_date, "Authorization" => "AWS " . $s3c["access_key"] . ":" . $s3_signature));
599
/**/
600
- if (($s3_response = c_ws_plugin__s2member_utils_urls::remote ("https://" . $s3_domain . $s3_location, false, array_merge ($s3_args, array ("timeout" => 20)), "array")) && $s3_response["code"] === 200)
601
{
602
- $s3_location = ((strtolower ($s3c["bucket"]) !== $s3c["bucket"])) ? "/" . $s3c["bucket"] . "/?policy" : "/?policy";
603
- ($s3_policy_id = md5 (uniqid ("s2Member/CloudFront:", true))) . ($s3_policy_sid = md5 (uniqid ("s2Member/CloudFront:", true)));
604
- $s3_policy_json = '{"Version":"2008-10-17","Id":"' . c_ws_plugin__s2member_utils_strings::esc_dq ($s3_policy_id) . '","Statement":[{"Sid":"' . c_ws_plugin__s2member_utils_strings::esc_dq ($s3_policy_sid) . '","Effect":"Allow","Principal":{"CanonicalUser":"' . c_ws_plugin__s2member_utils_strings::esc_dq ($cfc["distros_s3_access_id"]) . '"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::' . c_ws_plugin__s2member_utils_strings::esc_dq ($s3c["bucket"]) . '/*"}]}';
605
- $s3_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("PUT\n\napplication/json\n" . $s3_date . "\n/" . $s3c["bucket"] . "/?policy"));
606
- $s3_args = array ("method" => "PUT", "body" => $s3_policy_json, "headers" => array ("Host" => $s3_domain, "Content-Type" => "application/json", "Date" => $s3_date, "Authorization" => "AWS " . $s3c["access_key"] . ":" . $s3_signature));
607
/**/
608
- if (!$cfc["distros_s3_access_id"] || (($s3_response = c_ws_plugin__s2member_utils_urls::remote ("https://" . $s3_domain . $s3_location, false, array_merge ($s3_args, array ("timeout" => 20)), "array")) && ($s3_response["code"] === 200 || $s3_response["code"] === 204 /* Also OK. */)))
609
{
610
- $s3_location = ((strtolower ($s3c["bucket"]) !== $s3c["bucket"])) ? "/" . $s3c["bucket"] . "/crossdomain.xml" : "/crossdomain.xml";
611
- $s3_policy_xml = trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (__FILE__)) . "/templates/cfg-files/s2-cross-xml.php")));
612
- $s3_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("PUT\n\ntext/xml\n" . $s3_date . "\nx-amz-acl:public-read\n/" . $s3c["bucket"] . "/crossdomain.xml"));
613
- $s3_args = array ("method" => "PUT", "body" => $s3_policy_xml, "headers" => array ("Host" => $s3_domain, "Content-Type" => "text/xml", "Date" => $s3_date, "X-Amz-Acl" => "public-read", "Authorization" => "AWS " . $s3c["access_key"] . ":" . $s3_signature));
614
/**/
615
- if (($s3_response = c_ws_plugin__s2member_utils_urls::remote ("https://" . $s3_domain . $s3_location, false, array_merge ($s3_args, array ("timeout" => 20)), "array")) && $s3_response["code"] === 200)
616
- return /* Successfully configured Amazon® S3 Bucket ACLs and Policy. */ array ("success" => true, "code" => null, "message" => null);
617
/**/
618
- else if (isset ($s3_response["code"], $s3_response["message"]))
619
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
620
- return array ("success" => false, "code" => $s3_response["code"], "message" => sprintf (_x ("Unable to update existing Amazon® S3 Cross-Domain Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
621
/**/
622
else /* Else, we use a default error code and message. */
623
- return array ("success" => false, "code" => -94, "message" => _x ("Unable to update existing Amazon® S3 Cross-Domain Policy. Connection failed.", "s2member-admin", "s2member"));
624
}
625
- else if (isset ($s3_response["code"], $s3_response["message"]))
626
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
627
- return array ("success" => false, "code" => $s3_response["code"], "message" => sprintf (_x ("Unable to update existing Amazon® S3 Bucket Policy. %s", "s2member-admin", "s2member"), $s3_response["message"]));
628
/**/
629
else /* Else, we use a default error code and message. */
630
- return array ("success" => false, "code" => -95, "message" => _x ("Unable to update existing Amazon® S3 Bucket Policy. Connection failed.", "s2member-admin", "s2member"));
631
}
632
- else if (isset ($s3_response["code"], $s3_response["message"]))
633
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
634
- return array ("success" => false, "code" => $s3_response["code"], "message" => sprintf (_x ("Unable to update existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
635
/**/
636
else /* Else, we use a default error code and message. */
637
- return array ("success" => false, "code" => -96, "message" => _x ("Unable to update existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
638
}
639
else /* Else, we use a default error code and message. */
640
- return array ("success" => false, "code" => -97, "message" => _x ("Unable to acquire/read existing Amazon® S3 Bucket ACLs. Unexpected response.", "s2member-admin", "s2member"));
641
}
642
- else if (isset ($s3_response["code"], $s3_response["message"]))
643
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
644
- return array ("success" => false, "code" => $s3_response["code"], "message" => sprintf (_x ("Unable to acquire existing Amazon® S3 Bucket ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
645
/**/
646
else /* Else, we use a default error code and message. */
647
- return array ("success" => false, "code" => -98, "message" => _x ("Unable to acquire existing Amazon® S3 Bucket ACLs. Connection failed.", "s2member-admin", "s2member"));
648
}
649
else /* Else, we use a default error code and message. */
650
- return array ("success" => false, "code" => -99, "message" => _x ("Unable to auto-configure existing Amazon® S3 Bucket ACLs. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key.", "s2member-admin", "s2member"));
651
}
652
/**
653
* Creates an Amazon® CloudFront HMAC-SHA1 signature.
@@ -658,11 +672,11 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
658
* @param str $string Input string/data, to be signed by this routine.
659
* @return str An HMAC-SHA1 signature for Amazon® CloudFront.
660
*/
661
- public static function amazon_cf_sign ($string = FALSE)
662
{
663
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
664
/**/
665
- return c_ws_plugin__s2member_utils_strings::hmac_sha1_sign ((string)$string, ($cfc["secret_key"] = $s3c["secret_key"]));
666
}
667
/**
668
* Creates an Amazon® CloudFront RSA-SHA1 signature.
@@ -676,11 +690,11 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
676
* @todo Double underscores *( i.e. base64 padding chars )* in the signature seem to cause issues for Amazon® CloudFront?
677
* See ticket: {@link https://forums.aws.amazon.com/thread.jspa?messageID=286182&#286182}
678
*/
679
- public static function amazon_cf_rsa_sign ($string = FALSE)
680
{
681
$cfc["private_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"];
682
/**/
683
- return c_ws_plugin__s2member_utils_strings::rsa_sha1_sign ((string)$string, $cfc["private_key"]);
684
}
685
/**
686
* Creates an Amazon® CloudFront RSA-SHA1 signature URL.
@@ -696,29 +710,29 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
696
* @param str $mimetype The MIME content-type of the resource file.
697
* @return str An RSA-SHA1 signature URL for Amazon® CloudFront.
698
*/
699
- public static function amazon_cf_url ($file = FALSE, $stream = FALSE, $inline = FALSE, $ssl = FALSE, $basename = FALSE, $mimetype = FALSE)
700
{
701
- $file = /* Trim / force string. */ trim ((string)$file, "/");
702
/**/
703
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
704
- if (preg_match ("/^amazon_cf_files_/", $option) && ($option = preg_replace ("/^amazon_cf_files_/", "", $option)))
705
$cfc[$option] = $option_value;
706
/**/
707
- $cfc["expires"] = strtotime ("+" . apply_filters ("ws_plugin__s2member_amazon_cf_file_expires_time", "24 hours", get_defined_vars ()));
708
/**/
709
- $cf_extn = /* Parses the file extension out so we can scan it in some special scenarios. */ strtolower (substr ($file, strrpos ($file, ".") + 1));
710
- $cf_ip_res = /* Do NOT restrict access to a particular IP during `localhost` development. The IP may NOT be the same one Amazon® CloudFront sees. */ (c_ws_plugin__s2member_utils_conds::is_localhost ()) ? false : true;
711
- $cf_stream_extn_resource_exclusions = array_unique ((array)apply_filters ("ws_plugin__s2member_amazon_cf_file_streaming_extension_resource_exclusions", array ("mp3" /* MP3 files should NOT include an extension in their resource reference. */), get_defined_vars ()));
712
- $cf_resource = ($stream) ? ((in_array ($cf_extn, $cf_stream_extn_resource_exclusions)) ? substr ($file, 0, strrpos ($file, ".")) : $file) : "http" . (($ssl) ? "s" : "") . "://" . (($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"]) . "/" . $file;
713
- $cf_url = ($stream) ? "rtmp" . (($ssl) ? "e" : "") . "://" . (($cfc["distro_streaming_cname"]) ? $cfc["distro_streaming_cname"] : $cfc["distro_streaming_dname"]) . "/cfx/st/" . $file : "http" . (($ssl) ? "s" : "") . "://" . (($cfc["distro_downloads_cname"]) ? $cfc["distro_downloads_cname"] : $cfc["distro_downloads_dname"]) . "/" . $file;
714
- $cf_policy = '{"Statement":[{"Resource":"' . c_ws_plugin__s2member_utils_strings::esc_dq ($cf_resource) . '","Condition":{' . (($cf_ip_res) ? '"IpAddress":{"AWS:SourceIp":"' . c_ws_plugin__s2member_utils_strings::esc_dq ($_SERVER["REMOTE_ADDR"]) . '/32"},' : '') . '"DateLessThan":{"AWS:EpochTime":' . (int)$cfc["expires"] . '}}}]}';
715
/**/
716
- $cf_signature = c_ws_plugin__s2member_files_in::amazon_cf_rsa_sign ($cf_policy);
717
- $cf_base64_url_safe_policy = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode ($cf_policy, array ("+", "=", "/"), array ("-", "_", "~"), false);
718
- $cf_base64_url_safe_signature = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode ($cf_signature, array ("+", "=", "/"), array ("-", "_", "~"), false);
719
/**/
720
- return add_query_arg (c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep /* Don't encode unreserved chars. Maximizes media player compatibility. */
721
- (urlencode_deep (array ("Policy" => $cf_base64_url_safe_policy, "Signature" => $cf_base64_url_safe_signature, "Key-Pair-Id" => $cfc["private_key_id"]))), $cf_url);
722
}
723
/**
724
* Auto-configures Amazon® S3/CloudFront distros.
@@ -729,170 +743,170 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
729
* @return array Array containing a true `success` element on success, else a failure array.
730
* Failure array will contain a failure `code`, and a failure `message`.
731
*/
732
- public static function amazon_cf_auto_configure_distros ()
733
{
734
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
735
- if (preg_match ("/^amazon_cf_files_/", $option) && ($option = preg_replace ("/^amazon_cf_files_/", "", $option)))
736
$cfc[$option] = $option_value;
737
/**/
738
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
739
$cfc["access_key"] = $s3c["access_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"];
740
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
741
/**/
742
- if /* We MUST have an Amazon® S3 Bucket and Keys. */ ($s3c["bucket"] && $s3c["access_key"] && $s3c["secret_key"])
743
{
744
- if /* We MUST have Amazon® CloudFront Keys in order to auto-configure. */ ($cfc["private_key"] && $cfc["private_key_id"])
745
{
746
- if (!$cfc["distro_downloads_id"] || ($cfc["distro_downloads_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_distro ($cfc["distro_downloads_id"], "downloads")) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
747
{
748
- if (!$cfc["distro_downloads_id"] || ($cfc["distro_downloads_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
749
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
750
/**/
751
- else if ($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
752
- return array ("success" => false, "code" => -86, "message" => _x ("Unable to delete existing Amazon® CloudFront Downloads Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
753
/**/
754
- else if ($cfc["distro_downloads_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro ($cfc["distro_downloads_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
755
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
756
/**/
757
- else if (isset ($cf_del_response["code"], $cf_del_response["message"]))
758
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
759
- return array ("success" => false, "code" => $cf_del_response["code"], "message" => sprintf (_x ("Unable to delete existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
760
/**/
761
- if /* Successfully cleared? Ready for a new one? */ (isset ($cf_distro_downloads_clear) && $cf_distro_downloads_clear)
762
{
763
- unset /* Unset these before processing additional routines. Prevents problems in error reporting. */ ($cf_get_response, $cf_del_response);
764
/**/
765
- if (!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_distro ($cfc["distro_streaming_id"], "streaming")) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
766
{
767
- if (!$cfc["distro_streaming_id"] || ($cfc["distro_streaming_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
768
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
769
/**/
770
- else if ($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && !$cf_get_response["deployed"])
771
- return array ("success" => false, "code" => -87, "message" => _x ("Unable to delete existing Amazon® CloudFront Streaming Distro. Still in a `pending` state. Please wait 15 minutes, then try again. There is a certain process that s2Member must strictly adhere to when re-configuring your Amazon® CloudFront Distros. You may have to tick the auto-configure checkbox again, and re-run s2Member's auto-configuration routine many times, because s2Member will likely run into several `pending` challenges, as it works to completely re-configure your Amazon® CloudFront Distros for you. Thanks for your patience. Please wait 15 minutes, then try again.", "s2member-admin", "s2member"));
772
/**/
773
- else if ($cfc["distro_streaming_id"] && $cf_get_response && $cf_get_response["success"] && $cf_get_response["deployed"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_distro ($cfc["distro_streaming_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
774
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
775
/**/
776
- else if (isset ($cf_del_response["code"], $cf_del_response["message"]))
777
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
778
- return array ("success" => false, "code" => $cf_del_response["code"], "message" => sprintf (_x ("Unable to delete existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
779
/**/
780
- if /* Successfully cleared? Ready for a new one? */ (isset ($cf_distro_streaming_clear) && $cf_distro_streaming_clear)
781
{
782
- unset /* Unset these before processing additional routines. Prevents problems in error reporting. */ ($cf_get_response, $cf_del_response);
783
/**/
784
- if (!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && ($cf_get_response = c_ws_plugin__s2member_files_in::amazon_cf_get_access_origin_identity ($cfc["distros_access_id"])) && ($cf_get_response["success"] || $cf_get_response["code"] === 404)))
785
{
786
- if (!$cfc["distros_access_id"] || ($cfc["distros_access_id"] && $cf_get_response && !$cf_get_response["success"] && $cf_get_response["code"] === 404))
787
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
788
/**/
789
- else if ($cfc["distros_access_id"] && $cf_get_response && $cf_get_response["success"] && ($cf_del_response = c_ws_plugin__s2member_files_in::amazon_cf_del_access_origin_identity ($cfc["distros_access_id"], $cf_get_response["etag"], $cf_get_response["xml"])) && $cf_del_response["success"])
790
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
791
/**/
792
- else if (isset ($cf_del_response["code"], $cf_del_response["message"]))
793
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
794
- return array ("success" => false, "code" => $cf_del_response["code"], "message" => sprintf (_x ("Unable to delete existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_del_response["message"]));
795
/**/
796
- if /* Successfully cleared? Ready for a new one? */ (isset ($cf_distros_access_clear) && $cf_distros_access_clear)
797
{
798
- unset /* Unset these before processing additional routines. Prevents problems in error reporting. */ ($cf_get_response, $cf_del_response);
799
/**/
800
- $cfc = array_merge ($cfc, array ("distros_access_id" => "", "distros_s3_access_id" => "", "distro_downloads_id" => "", "distro_downloads_dname" => "", "distro_streaming_id" => "", "distro_streaming_dname" => "", "distros_auto_config_status" => ""));
801
- $cf_options = array ("ws_plugin__s2member_amazon_cf_files_distros_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => "", "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => "", "ws_plugin__s2member_amazon_cf_files_distros_auto_config_status" => "");
802
- c_ws_plugin__s2member_menu_pages::update_all_options ($cf_options, true, false, false, false, false);
803
/**/
804
- if (($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distros_access_origin_identity ()) && $cf_response["success"])
805
{
806
- $cfc = array_merge ($cfc, array ("distros_access_id" => $cf_response["distros_access_id"], "distros_s3_access_id" => $cf_response["distros_s3_access_id"]));
807
- $cf_options = array ("ws_plugin__s2member_amazon_cf_files_distros_access_id" => $cf_response["distros_access_id"], "ws_plugin__s2member_amazon_cf_files_distros_s3_access_id" => $cf_response["distros_s3_access_id"]);
808
- c_ws_plugin__s2member_menu_pages::update_all_options ($cf_options, true, false, false, false, false);
809
/**/
810
- if (($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro ("downloads")) && $cf_response["success"])
811
{
812
- $cfc = array_merge ($cfc, array ("distro_downloads_id" => $cf_response["distro_downloads_id"], "distro_downloads_dname" => $cf_response["distro_downloads_dname"]));
813
- $cf_options = array ("ws_plugin__s2member_amazon_cf_files_distro_downloads_id" => $cf_response["distro_downloads_id"], "ws_plugin__s2member_amazon_cf_files_distro_downloads_dname" => $cf_response["distro_downloads_dname"]);
814
- c_ws_plugin__s2member_menu_pages::update_all_options ($cf_options, true, false, false, false, false);
815
/**/
816
- if (($cf_response = c_ws_plugin__s2member_files_in::amazon_cf_create_distro ("streaming")) && $cf_response["success"])
817
{
818
- $cfc = array_merge ($cfc, array ("distro_streaming_id" => $cf_response["distro_streaming_id"], "distro_streaming_dname" => $cf_response["distro_streaming_dname"]));
819
- $cf_options = array ("ws_plugin__s2member_amazon_cf_files_distro_streaming_id" => $cf_response["distro_streaming_id"], "ws_plugin__s2member_amazon_cf_files_distro_streaming_dname" => $cf_response["distro_streaming_dname"]);
820
- c_ws_plugin__s2member_menu_pages::update_all_options ($cf_options, true, false, false, false, false);
821
/**/
822
- for ($a = 1, $attempts = 4, $sleep = 2, sleep ($sleep); $a <= $attempts; $a++, (($a <= $attempts) ? sleep ($sleep) : null))
823
/* Allow a generous propagation time here. Amazon's high-availability services do NOT guarantee real-time updates.
824
Since we DO need a fully propagated Origin Access Identity now, we need to make several attempts at success.
825
For further details, please see this thread: <https://forums.aws.amazon.com/message.jspa?messageID=42875>. */
826
- if (($s3_response = c_ws_plugin__s2member_files_in::amazon_s3_auto_configure_acls ()) && $s3_response["success"])
827
{
828
- $cfc = array_merge ($cfc, array ("distros_auto_config_status" => "configured"));
829
- $cf_options = array ("ws_plugin__s2member_amazon_cf_files_distros_auto_config_status" => "configured");
830
- c_ws_plugin__s2member_menu_pages::update_all_options ( /* Now configured! */$cf_options, true, false, false, false, false);
831
- return /* Successfully configured Amazon® S3/CloudFront distros. */ array ("success" => true, "code" => null, "message" => null);
832
}
833
- if (isset ($s3_response["code"], $s3_response["message"]))
834
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® S3 API call. Feel free to exclude `%s` if you like. */
835
- return array ("success" => false, "code" => $s3_response["code"], "message" => sprintf (_x ("Unable to update existing Amazon® S3 ACLs. %s", "s2member-admin", "s2member"), $s3_response["message"]));
836
/**/
837
else /* Else, we use a default error code and message. */
838
- return array ("success" => false, "code" => -88, "message" => _x ("Unable to update existing Amazon® S3 ACLs. Connection failed.", "s2member-admin", "s2member"));
839
}
840
- else if (isset ($cf_response["code"], $cf_response["message"]))
841
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
842
- return array ("success" => false, "code" => $cf_response["code"], "message" => sprintf (_x ("Unable to create Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
843
/**/
844
else /* Else, we use a default error code and message. */
845
- return array ("success" => false, "code" => -89, "message" => _x ("Unable to create Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
846
}
847
- else if (isset ($cf_response["code"], $cf_response["message"]))
848
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
849
- return array ("success" => false, "code" => $cf_response["code"], "message" => sprintf (_x ("Unable to create Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_response["message"]));
850
/**/
851
else /* Else, we use a default error code and message. */
852
- return array ("success" => false, "code" => -90, "message" => _x ("Unable to create Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
853
}
854
- else if (isset ($cf_response["code"], $cf_response["message"]))
855
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
856
- return array ("success" => false, "code" => $cf_response["code"], "message" => sprintf (_x ("Unable to create Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
857
/**/
858
else /* Else, we use a default error code and message. */
859
- return array ("success" => false, "code" => -91, "message" => _x ("Unable to create Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
860
}
861
else /* Else, we use a default error code and message. */
862
- return array ("success" => false, "code" => -92, "message" => _x ("Unable to clear existing Amazon® CloudFront Origin Access Identity.", "s2member-admin", "s2member"));
863
}
864
- else if (isset ($cf_get_response["code"], $cf_get_response["message"]))
865
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
866
- return array ("success" => false, "code" => $cf_get_response["code"], "message" => sprintf (_x ("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
867
/**/
868
else /* Else, we use a default error code and message. */
869
- return array ("success" => false, "code" => -93, "message" => _x ("Unable to acquire existing Amazon® CloudFront Origin Access Identity. Connection failed.", "s2member-admin", "s2member"));
870
}
871
else /* Else, we use a default error code and message. */
872
- return array ("success" => false, "code" => -94, "message" => _x ("Unable to clear existing Amazon® CloudFront Streaming Distro.", "s2member-admin", "s2member"));
873
}
874
- else if (isset ($cf_get_response["code"], $cf_get_response["message"]))
875
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
876
- return array ("success" => false, "code" => $cf_get_response["code"], "message" => sprintf (_x ("Unable to acquire existing Amazon® CloudFront Streaming Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
877
/**/
878
else /* Else, we use a default error code and message. */
879
- return array ("success" => false, "code" => -95, "message" => _x ("Unable to acquire existing Amazon® CloudFront Streaming Distro. Connection failed.", "s2member-admin", "s2member"));
880
}
881
else /* Else, we use a default error code and message. */
882
- return array ("success" => false, "code" => -96, "message" => _x ("Unable to clear existing Amazon® CloudFront Downloads Distro.", "s2member-admin", "s2member"));
883
}
884
- else if (isset ($cf_get_response["code"], $cf_get_response["message"]))
885
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
886
- return array ("success" => false, "code" => $cf_get_response["code"], "message" => sprintf (_x ("Unable to acquire existing Amazon® CloudFront Downloads Distro. %s", "s2member-admin", "s2member"), $cf_get_response["message"]));
887
/**/
888
else /* Else, we use a default error code and message. */
889
- return array ("success" => false, "code" => -97, "message" => _x ("Unable to acquire existing Amazon® CloudFront Downloads Distro. Connection failed.", "s2member-admin", "s2member"));
890
}
891
else /* Else, we use a default error code and message. */
892
- return array ("success" => false, "code" => -98, "message" => _x ("Unable to auto-configure Amazon® CloudFront Distros. Incomplete Amazon® CloudFront configuration options. Missing of one: Amazon® CloudFront Private Key-Pair-ID, or Private Key file contents.", "s2member-admin", "s2member"));
893
}
894
else /* Else, we use a default error code and message. */
895
- return array ("success" => false, "code" => -99, "message" => _x ("Unable to auto-configure Amazon® S3/CloudFront Distros. Incomplete Amazon® S3 configuration options. Missing one of: Amazon® S3 Bucket, Access Key, or Secret Key. You must provide s2Member with an Amazon® S3 configuration before enabling CloudFront.", "s2member-admin", "s2member"));
896
}
897
/**
898
* Acquires an Amazon® S3/CloudFront Access Origin Identity.
@@ -904,12 +918,12 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
904
* @return array Array containing a true `success` and `etag`, `xml` elements on success, else a failure array.
905
* Failure array will contain a failure `code`, and a failure `message`.
906
*/
907
- public static function amazon_cf_get_access_origin_identity ($access_id = FALSE)
908
{
909
- if /* Valid parameters? */ ($access_id && is_string ($access_id))
910
{
911
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"] as $option => $option_value)
912
- if (preg_match ("/^amazon_cf_files_/", $option) && ($option = preg_replace ("/^amazon_cf_files_/", "", $option)))
913
$cfc[$option] = $option_value;
914
/**/
915
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
@@ -917,28 +931,28 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
917
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
918
/**/
919
$cf_domain = "cloudfront.amazonaws.com";
920
- $cf_date = gmdate ("D, d M Y H:i:s") . " GMT";
921
- $cf_location = "/2010-11-01/origin-access-identity/cloudfront/" . $access_id;
922
- $cf_signature = base64_encode (c_ws_plugin__s2member_files_in::amazon_cf_sign ($cf_date));
923
- $cf_args = array ("method" => "GET", "headers" => array ("Host" => $cf_domain, "Date" => $cf_date, "Authorization" => "AWS " . $cfc["access_key"] . ":" . $cf_signature));
924
/**/
925
- if (($cf_response = c_ws_plugin__s2member_utils_urls::remote ("https://" . $cf_domain . $cf_location, false, array_merge ($cf_args, array ("timeout" => 20)), "array")) && (($cf_response["code"] === 404 && $cf_response["message"]) || ($cf_response["code"] === 200 && !empty ($cf_response["headers"]["etag"]) && !empty ($cf_response["body"]))))
926
{
927
- if ($cf_response["code"] === 200 && !empty ($cf_response["headers"]["etag"]) && !empty ($cf_response["body"]))
928
- return array ("success" => true, "code" => null, "message" => null, "etag" => trim ($cf_response["headers"]["etag"]), "xml" => trim ($cf_response["body"]));
929
/**/
930
else /* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
931
- return array ("success" => false, "code" => $cf_response["code"], "message" => sprintf (_x ("Existing Amazon® CloudFront Origin Access Identity NOT found. %s", "s2member-admin", "s2member"), $cf_response["message"]));
932
}
933
- else if (isset ($cf_response["code"], $cf_response["message"]))
934
/* translators: In this translation, `%s` may be filled with an English message, which comes from the Amazon® CloudFront API call. Feel free to exclude `%s` if you like. */
935
- return array ("success" => false, "code" => $cf_response["code"], "message" => sprintf (_x ("Unable to acquire existing Amazon® CloudFront Origin Access Identity. %s", "s2member-admin", "s2member"), $cf_response["message"]));
936
/**/
937
else /* Else, we use a default error code and message. */
938