Version Description
= v120213 = Optimization and a few bug fixes. Upgrade immediately.
Download this release
Release Info
Developer | PriMoThemes |
Plugin | ![]() |
Version | 120213 |
Comparing to | |
See all releases |
Code changes from version 111220 to 120213
- includes/classes/admin-css-js-in.inc.php +39 -39
- includes/classes/css-js-in.inc.php +82 -82
- includes/classes/custom-reg-fields.inc.php +292 -291
- includes/classes/files-in.inc.php +515 -501
- includes/classes/files.inc.php +155 -74
- includes/classes/installation.inc.php +74 -72
- includes/classes/login-customizations.inc.php +56 -57
- includes/classes/menu-pages.inc.php +237 -228
- includes/classes/meta-box-security.inc.php +57 -57
- includes/classes/mo-page-in.inc.php +1 -1
- includes/classes/paypal-notify-in-subscr-or-rp-eots-w-level.inc.php +164 -164
- includes/classes/paypal-return-in-subscr-modify-w-level.inc.php +93 -88
- includes/classes/paypal-return-in-subscr-or-wa-w-level.inc.php +150 -145
- includes/classes/roles-caps.inc.php +57 -57
- includes/classes/ssl-in.inc.php +59 -57
- includes/classes/utils-conds.inc.php +4 -1
- includes/classes/utils-strings.inc.php +141 -122
- includes/menu-pages/down-ops.inc.php +494 -471
- includes/menu-pages/els-ops.inc.php +233 -233
- includes/menu-pages/mms-ops.inc.php +251 -251
- includes/s2member-min.js +1 -1
- includes/s2member.css +24 -24
- includes/s2member.js +10 -8
- includes/syscon.inc.php +151 -150
- includes/templates/cfg-files/s2member-files-no-gzip.php +18 -0
- includes/templates/cfg-files/s2member-files.php +60 -19
- includes/templates/cfg-files/s2o-mu-plugins.php +13 -2
- includes/translations/s2member.pot +179 -180
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
|
18 |
-
exit
|
19 |
/**/
|
20 |
-
if
|
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
|
43 |
/**/
|
44 |
-
if
|
45 |
{
|
46 |
-
status_header
|
47 |
/**/
|
48 |
-
header
|
49 |
-
header
|
50 |
-
header
|
51 |
-
header
|
52 |
-
header
|
53 |
/**/
|
54 |
-
eval
|
55 |
/**/
|
56 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
57 |
-
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]
|
58 |
/**/
|
59 |
-
ob_start
|
60 |
/**/
|
61 |
-
include_once dirname
|
62 |
/**/
|
63 |
echo "\n"; /* Add a line break before inclusion of this file. */
|
64 |
/**/
|
65 |
-
@include_once dirname
|
66 |
/**/
|
67 |
-
do_action
|
68 |
/**/
|
69 |
-
exit
|
70 |
}
|
71 |
/**/
|
72 |
-
do_action
|
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
|
87 |
/**/
|
88 |
-
if
|
89 |
{
|
90 |
-
status_header
|
91 |
/**/
|
92 |
-
header
|
93 |
-
header
|
94 |
-
header
|
95 |
-
header
|
96 |
-
header
|
97 |
/**/
|
98 |
-
eval
|
99 |
/**/
|
100 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
|
101 |
-
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]
|
102 |
/**/
|
103 |
-
for
|
104 |
-
$labels .= "labels['level"
|
105 |
-
unset
|
106 |
/**/
|
107 |
-
include_once dirname
|
108 |
/**/
|
109 |
echo "\n"; /* Add a line break before inclusion of this file. */
|
110 |
/**/
|
111 |
-
@include_once dirname
|
112 |
/**/
|
113 |
-
do_action
|
114 |
/**/
|
115 |
-
exit
|
116 |
}
|
117 |
/**/
|
118 |
-
do_action
|
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
|
18 |
exit("Do not access this file directly.");
|
19 |
/**/
|
20 |
-
if
|
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
|
43 |
/**/
|
44 |
-
if
|
45 |
{
|
46 |
status_header(200); /* 200 OK status. */
|
47 |
/**/
|
48 |
header("Content-Type: text/css; charset=utf-8");
|
49 |
-
header("Expires: "
|
50 |
-
header("Last-Modified: "
|
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"]
|
58 |
/**/
|
59 |
ob_start("c_ws_plugin__s2member_utils_css::compress_css");
|
60 |
/**/
|
61 |
-
include_once dirname
|
62 |
/**/
|
63 |
-
do_action
|
64 |
/**/
|
65 |
-
exit
|
66 |
}
|
67 |
/**/
|
68 |
-
do_action
|
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
|
85 |
/**/
|
86 |
-
if
|
87 |
{
|
88 |
status_header(200); /* 200 OK status header. */
|
89 |
/**/
|
90 |
-
header("Content-Type:
|
91 |
-
header("Expires: "
|
92 |
-
header("Last-Modified: "
|
93 |
header("Cache-Control: max-age=604800");
|
94 |
header("Pragma: public");
|
95 |
/**/
|
96 |
eval('while (@ob_end_clean ());');
|
97 |
/**/
|
98 |
-
include_once dirname
|
99 |
/**/
|
100 |
echo "\n"; /* Add a line break before writing JavaScript Globals to file. */
|
101 |
/**/
|
102 |
-
echo "var S2MEMBER_VERSION = '"
|
103 |
/**/
|
104 |
-
echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = "
|
105 |
/**/
|
106 |
-
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = "
|
107 |
-
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = "
|
108 |
/**/
|
109 |
-
echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = "
|
110 |
-
echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '"
|
111 |
/**/
|
112 |
-
echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '"
|
113 |
-
echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '"
|
114 |
-
echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '"
|
115 |
-
echo "S2MEMBER_CURRENT_USER_CUSTOM = '"
|
116 |
/**/
|
117 |
-
echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = "
|
118 |
-
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = "
|
119 |
/**/
|
120 |
-
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = "
|
121 |
-
echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = "
|
122 |
/**/
|
123 |
-
echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '"
|
124 |
-
echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '"
|
125 |
-
echo "S2MEMBER_CURRENT_USER_LAST_NAME = '"
|
126 |
/**/
|
127 |
-
echo "S2MEMBER_CURRENT_USER_LOGIN = '"
|
128 |
-
echo "S2MEMBER_CURRENT_USER_EMAIL = '"
|
129 |
-
echo "S2MEMBER_CURRENT_USER_IP = '"
|
130 |
-
echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '"
|
131 |
/**/
|
132 |
-
echo "S2MEMBER_CURRENT_USER_ID = "
|
133 |
-
echo "S2MEMBER_CURRENT_USER_FIELDS = "
|
134 |
/**/
|
135 |
-
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = "
|
136 |
-
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = "
|
137 |
-
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = "
|
138 |
-
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = "
|
139 |
/**/
|
140 |
-
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = "
|
141 |
-
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = "
|
142 |
-
echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = "
|
143 |
/**/
|
144 |
-
echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '"
|
145 |
-
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '"
|
146 |
-
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '"
|
147 |
-
echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '"
|
148 |
-
echo "S2MEMBER_LOGOUT_PAGE_URL = '"
|
149 |
-
echo "S2MEMBER_LOGIN_PAGE_URL = '"
|
150 |
/**/
|
151 |
-
for
|
152 |
{
|
153 |
-
if
|
154 |
-
echo $S2MEMBER_LEVELn_LABEL
|
155 |
}
|
156 |
/**/
|
157 |
-
for
|
158 |
{
|
159 |
-
if
|
160 |
-
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
|
161 |
}
|
162 |
/**/
|
163 |
-
for
|
164 |
{
|
165 |
-
if
|
166 |
-
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
|
167 |
}
|
168 |
/**/
|
169 |
-
echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '"
|
170 |
/**/
|
171 |
-
echo "S2MEMBER_REG_EMAIL_FROM_NAME = '"
|
172 |
-
echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '"
|
173 |
/**/
|
174 |
-
echo "S2MEMBER_PAYPAL_NOTIFY_URL = '"
|
175 |
-
echo "S2MEMBER_PAYPAL_RETURN_URL = '"
|
176 |
/**/
|
177 |
-
echo "S2MEMBER_PAYPAL_BUSINESS = '"
|
178 |
-
echo "S2MEMBER_PAYPAL_ENDPOINT = '"
|
179 |
-
echo "S2MEMBER_PAYPAL_API_ENDPOINT = '"
|
180 |
/**/
|
181 |
-
echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~"
|
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 = '"
|
185 |
-
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '"
|
186 |
/**/
|
187 |
-
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '"
|
188 |
-
echo "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"]
|
192 |
/**/
|
193 |
echo "\n"; /* Add a line break before inclusion. */
|
194 |
/**/
|
195 |
-
include_once dirname
|
196 |
/**/
|
197 |
-
do_action
|
198 |
/**/
|
199 |
-
exit
|
200 |
}
|
201 |
/**/
|
202 |
-
do_action
|
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
|
18 |
-
exit
|
19 |
/**/
|
20 |
-
if
|
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
|
50 |
{
|
51 |
-
eval
|
52 |
-
do_action
|
53 |
-
unset
|
54 |
/**/
|
55 |
-
if
|
56 |
{
|
57 |
-
eval
|
58 |
-
do_action
|
59 |
-
unset
|
60 |
-
/**/
|
61 |
-
$field_var = preg_replace
|
62 |
-
$field_id_class = preg_replace
|
63 |
-
/**/
|
64 |
-
$name_suffix = (preg_match
|
65 |
-
$field_name = trim
|
66 |
-
/**/
|
67 |
-
$common = ''; /* Common
|
68 |
-
$common .= ' name="'
|
69 |
-
$common .= ' id="'
|
70 |
-
$common .= ((!empty
|
71 |
-
$common .= ((strlen
|
72 |
-
$common .= ((
|
73 |
-
$common .= (($_editable_context === "profile-view" || (!empty
|
74 |
-
$common .= (($_classes || !empty
|
75 |
-
$common .= (($_styles || !empty
|
76 |
-
$common .= (($_attrs || !empty
|
77 |
-
/**/
|
78 |
-
if
|
79 |
{
|
80 |
-
if
|
81 |
-
$gen = esc_html
|
82 |
/**/
|
83 |
-
else /* Else handle
|
84 |
{
|
85 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
86 |
-
$gen .= ' value="'
|
87 |
-
$gen .= $common
|
88 |
}
|
89 |
}
|
90 |
/**/
|
91 |
-
else if
|
92 |
{
|
93 |
-
if
|
94 |
-
$gen = nl2br
|
95 |
/**/
|
96 |
-
else /* Else handle
|
97 |
{
|
98 |
-
$gen = '<textarea rows="3"'
|
99 |
-
$gen .= format_to_edit
|
100 |
$gen .= '</textarea>';
|
101 |
}
|
102 |
}
|
103 |
/**/
|
104 |
-
else if
|
105 |
{
|
106 |
-
if
|
107 |
{
|
108 |
-
foreach
|
109 |
{
|
110 |
-
list
|
111 |
-
if
|
112 |
{
|
113 |
$gen = $option_label;
|
114 |
break;
|
115 |
}
|
116 |
}
|
117 |
}
|
118 |
-
else /* Else handle
|
119 |
{
|
120 |
-
$gen = '<select'
|
121 |
-
|
|
|
122 |
{
|
123 |
-
list
|
124 |
-
$gen .= '<option value="'
|
125 |
}
|
126 |
$gen .= '</select>';
|
127 |
}
|
128 |
}
|
129 |
/**/
|
130 |
-
else if
|
131 |
{
|
132 |
-
if
|
133 |
{
|
134 |
-
foreach
|
135 |
{
|
136 |
-
list
|
137 |
-
if
|
138 |
-
$gen .= $option_label
|
139 |
}
|
140 |
-
$gen = trim
|
141 |
}
|
142 |
-
else /* Else handle
|
143 |
{
|
144 |
-
$common = preg_replace
|
145 |
-
$common = preg_replace
|
146 |
/**/
|
147 |
-
$gen = '<select multiple="multiple" size="3"'
|
148 |
-
foreach
|
149 |
{
|
150 |
-
list
|
151 |
-
$gen .= '<option value="'
|
152 |
}
|
153 |
$gen .= '</select>';
|
154 |
}
|
155 |
}
|
156 |
/**/
|
157 |
-
else if
|
158 |
{
|
159 |
-
if
|
160 |
$gen = ((string)$_value) ? "yes" : "no";
|
161 |
/**/
|
162 |
-
else /* Else handle
|
163 |
{
|
164 |
$gen = '<input type="checkbox" value="1"';
|
165 |
$gen .= (((string)$_value) ? ' checked="checked"' : '');
|
166 |
-
$gen .= $common
|
167 |
}
|
168 |
}
|
169 |
/**/
|
170 |
-
else if
|
171 |
{
|
172 |
-
if
|
173 |
$gen = ((string)$_value) ? "yes" : "no";
|
174 |
/**/
|
175 |
-
else /* Else handle
|
176 |
{
|
177 |
$gen = '<input type="checkbox" value="1"';
|
178 |
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
|
179 |
-
$gen .= $common
|
180 |
}
|
181 |
}
|
182 |
/**/
|
183 |
-
else if
|
184 |
{
|
185 |
-
if
|
186 |
{
|
187 |
-
foreach
|
188 |
{
|
189 |
-
list
|
190 |
-
if
|
191 |
-
$gen .= $option_label
|
192 |
}
|
193 |
-
$gen = trim
|
194 |
}
|
195 |
-
else /* Else handle
|
196 |
{
|
197 |
-
$common = preg_replace
|
198 |
/**/
|
199 |
-
$sep = apply_filters
|
200 |
-
$opl = apply_filters
|
201 |
/**/
|
202 |
-
foreach
|
203 |
{
|
204 |
-
$common_i = preg_replace
|
205 |
/**/
|
206 |
-
list
|
207 |
/**/
|
208 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
|
209 |
-
$gen .= '<input type="checkbox" value="'
|
210 |
-
$gen .= ((($option_default && !$_submission) || in_array
|
211 |
-
$gen .= $common_i
|
212 |
}
|
213 |
}
|
214 |
}
|
215 |
/**/
|
216 |
-
else if
|
217 |
{
|
218 |
-
if
|
219 |
{
|
220 |
-
foreach
|
221 |
{
|
222 |
-
list
|
223 |
-
if
|
224 |
{
|
225 |
$gen = $option_label;
|
226 |
break;
|
227 |
}
|
228 |
}
|
229 |
}
|
230 |
-
else /* Else handle
|
231 |
{
|
232 |
-
$sep = apply_filters
|
233 |
-
$opl = apply_filters
|
234 |
/**/
|
235 |
-
foreach
|
236 |
{
|
237 |
-
$common_i = preg_replace
|
238 |
/**/
|
239 |
-
list
|
240 |
/**/
|
241 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
|
242 |
-
$gen .= '<input type="radio" value="'
|
243 |
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
|
244 |
-
$gen .= $common_i
|
245 |
}
|
246 |
}
|
247 |
}
|
248 |
-
else /* Default to
|
249 |
{
|
250 |
-
if
|
251 |
-
$gen = esc_html
|
252 |
/**/
|
253 |
-
else /* Else handle
|
254 |
{
|
255 |
$gen = '<input type="text" maxlength="100" autocomplete="off"';
|
256 |
-
$gen .= ' value="'
|
257 |
-
$gen .= $common
|
258 |
}
|
259 |
}
|
260 |
/**/
|
261 |
-
eval
|
262 |
-
do_action
|
263 |
-
unset
|
264 |
}
|
265 |
/**/
|
266 |
-
return apply_filters
|
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
|
280 |
{
|
281 |
-
eval
|
282 |
-
do_action
|
283 |
-
unset
|
284 |
/**/
|
285 |
-
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level
|
286 |
-
if
|
287 |
-
$level =
|
288 |
/**/
|
289 |
-
$level = ($level !== "any" && (!is_numeric
|
290 |
/**/
|
291 |
-
if
|
292 |
{
|
293 |
-
foreach
|
294 |
-
if
|
295 |
-
if
|
296 |
$configured[] = $field["id"]; /* Add this to the array. */
|
297 |
}
|
298 |
/**/
|
299 |
-
return apply_filters
|
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
|
318 |
/**/
|
319 |
-
if
|
320 |
{
|
321 |
-
$_p = (!empty
|
322 |
/**/
|
323 |
-
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'
|
324 |
/**/
|
325 |
-
eval
|
326 |
-
do_action
|
327 |
-
unset
|
328 |
/**/
|
329 |
-
if
|
330 |
{
|
331 |
-
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'
|
332 |
/**/
|
333 |
-
eval
|
334 |
-
do_action
|
335 |
-
unset
|
336 |
/**/
|
337 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'
|
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="'
|
339 |
-
echo '<br />'
|
340 |
/**/
|
341 |
-
eval
|
342 |
-
do_action
|
343 |
-
unset
|
344 |
/**/
|
345 |
-
eval
|
346 |
-
do_action
|
347 |
-
unset
|
348 |
/**/
|
349 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'
|
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="'
|
351 |
-
echo '<br />'
|
352 |
/**/
|
353 |
-
eval
|
354 |
-
do_action
|
355 |
-
unset
|
356 |
}
|
357 |
/**/
|
358 |
-
if
|
359 |
-
if
|
360 |
-
foreach
|
361 |
{
|
362 |
-
eval
|
363 |
-
do_action
|
364 |
-
unset
|
365 |
/**/
|
366 |
-
if
|
367 |
{
|
368 |
-
$field_var = preg_replace
|
369 |
-
$field_id_class = preg_replace
|
370 |
/**/
|
371 |
-
eval
|
372 |
-
if
|
373 |
{
|
374 |
-
if
|
375 |
-
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'
|
376 |
/**/
|
377 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-'
|
378 |
-
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen
|
379 |
-
echo '<br />'
|
380 |
}
|
381 |
-
unset
|
382 |
}
|
383 |
/**/
|
384 |
-
eval
|
385 |
-
do_action
|
386 |
-
unset
|
387 |
}
|
388 |
/**/
|
389 |
-
if
|
390 |
{
|
391 |
-
eval
|
392 |
-
do_action
|
393 |
-
unset
|
394 |
/**/
|
395 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'
|
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"'
|
397 |
-
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]
|
398 |
-
echo '</label>'
|
399 |
-
echo '<br />'
|
400 |
/**/
|
401 |
-
eval
|
402 |
-
do_action
|
403 |
-
unset
|
404 |
}
|
405 |
/**/
|
406 |
-
eval
|
407 |
-
do_action
|
408 |
-
unset
|
409 |
}
|
410 |
/**/
|
411 |
-
eval
|
412 |
-
do_action
|
413 |
-
unset
|
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
|
432 |
/**/
|
433 |
-
$_p = (!empty
|
434 |
/**/
|
435 |
-
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'
|
436 |
/**/
|
437 |
$tabindex = 20; /* Incremented tabindex starting with 20. */
|
438 |
/**/
|
439 |
-
eval
|
440 |
-
do_action
|
441 |
-
unset
|
442 |
/**/
|
443 |
-
if
|
444 |
{
|
445 |
-
eval
|
446 |
-
do_action
|
447 |
-
unset
|
448 |
/**/
|
449 |
-
echo '<p>'
|
450 |
/**/
|
451 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="'
|
452 |
-
echo '<span>'
|
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="'
|
454 |
-
echo '</label>'
|
455 |
/**/
|
456 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="'
|
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="'
|
458 |
-
echo '</label>'
|
459 |
/**/
|
460 |
-
echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>'
|
461 |
/**/
|
462 |
-
echo '</p>'
|
463 |
/**/
|
464 |
-
eval
|
465 |
-
do_action
|
466 |
-
unset
|
467 |
}
|
468 |
/**/
|
469 |
-
if
|
470 |
{
|
471 |
-
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'
|
472 |
-
/**/
|
473 |
-
eval
|
474 |
-
do_action
|
475 |
-
unset
|
476 |
-
/**/
|
477 |
-
echo '<p>'
|
478 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'
|
479 |
-
echo '<span>'
|
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="'
|
481 |
-
echo '</label>'
|
482 |
-
echo '</p>'
|
483 |
-
/**/
|
484 |
-
eval
|
485 |
-
do_action
|
486 |
-
unset
|
487 |
-
/**/
|
488 |
-
eval
|
489 |
-
do_action
|
490 |
-
unset
|
491 |
-
/**/
|
492 |
-
echo '<p>'
|
493 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'
|
494 |
-
echo '<span>'
|
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="'
|
496 |
-
echo '</label>'
|
497 |
-
echo '</p>'
|
498 |
-
/**/
|
499 |
-
eval
|
500 |
-
do_action
|
501 |
-
unset
|
502 |
}
|
503 |
/**/
|
504 |
-
if
|
505 |
-
if
|
506 |
{
|
507 |
$tabindex = $tabindex + 9; /* Start tabindex at +9 ( +1 below ). */
|
508 |
/**/
|
509 |
-
foreach
|
510 |
{
|
511 |
-
eval
|
512 |
-
do_action
|
513 |
-
unset
|
514 |
/**/
|
515 |
-
if
|
516 |
{
|
517 |
-
$field_var = preg_replace
|
518 |
-
$field_id_class = preg_replace
|
519 |
/**/
|
520 |
-
eval
|
521 |
-
if
|
522 |
{
|
523 |
-
if
|
524 |
-
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'
|
525 |
/**/
|
526 |
-
echo '<p>'
|
527 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-'
|
528 |
-
echo '<span'
|
529 |
-
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen
|
530 |
-
echo '</p>'
|
531 |
}
|
532 |
-
unset
|
533 |
}
|
534 |
/**/
|
535 |
-
eval
|
536 |
-
do_action
|
537 |
-
unset
|
538 |
}
|
539 |
}
|
540 |
/**/
|
541 |
-
if
|
542 |
{
|
543 |
-
eval
|
544 |
-
do_action
|
545 |
-
unset
|
546 |
-
/**/
|
547 |
-
echo '<p>'
|
548 |
-
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'
|
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"'
|
550 |
-
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]
|
551 |
-
echo '</label>'
|
552 |
-
echo '</p>'
|
553 |
-
/**/
|
554 |
-
eval
|
555 |
-
do_action
|
556 |
-
unset
|
557 |
}
|
558 |
/**/
|
559 |
-
eval
|
560 |
-
do_action
|
561 |
-
unset
|
562 |
/**/
|
563 |
-
eval
|
564 |
-
do_action
|
565 |
-
unset
|
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("/\[$/", $_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", " ", 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", " ", 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)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '<br />' : '')."\n";
|
379 |
+
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
380 |
+
echo '<br />'."\n";
|
381 |
}
|
382 |
+
unset($__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)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</span></label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />')."\n";
|
530 |
+
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration");
|
531 |
+
echo '</p>'."\n";
|
532 |
}
|
533 |
+
unset($__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
|
18 |
-
exit
|
19 |
/**/
|
20 |
-
if
|
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
|
45 |
{
|
46 |
-
eval
|
47 |
-
do_action
|
48 |
-
unset
|
49 |
/**/
|
50 |
-
$_g = !empty
|
51 |
-
$_g = c_ws_plugin__s2member_utils_strings::trim_deep
|
52 |
/**/
|
53 |
-
$creating = /* Creating URL? */ (is_array
|
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
|
74 |
-
if
|
75 |
{
|
76 |
-
$using_amazon_s3_storage = ((!$req["file_storage"] || strcasecmp
|
77 |
-
$using_amazon_cf_storage = ((!$req["file_storage"] || strcasecmp
|
78 |
$using_amazon_storage = /* Either/or? */ ($using_amazon_s3_storage || $using_amazon_cf_storage) ? true : false;
|
79 |
/**/
|
80 |
-
$excluded = apply_filters
|
81 |
-
$valid_file_download_key = ($req["file_download_key"] && is_string
|
82 |
-
$
|
83 |
-
$
|
|
|
84 |
/**/
|
85 |
-
if
|
86 |
{
|
87 |
-
if
|
88 |
{
|
89 |
-
if /* We only need this section when/if we're actually serving. */
|
90 |
-
status_header
|
91 |
-
.
|
92 |
/**/
|
93 |
else /* Else return false. */
|
94 |
return false;
|
95 |
}
|
96 |
/**/
|
97 |
-
else if
|
98 |
{
|
99 |
-
if /* We only need this section when/if we're actually serving. */
|
100 |
-
status_header
|
101 |
-
.
|
102 |
/**/
|
103 |
else /* Else return false. */
|
104 |
return false;
|
105 |
}
|
106 |
/**/
|
107 |
-
else if
|
108 |
{
|
109 |
-
if /* We only need remote functionality when/if we're actually serving. */
|
110 |
-
if
|
111 |
-
add_filter
|
112 |
/**/
|
113 |
-
if /* We only need remote functionality when/if we're actually serving. */
|
114 |
-
if
|
115 |
-
remove_filter
|
116 |
/**/
|
117 |
-
if
|
118 |
{
|
119 |
-
if /* We only need this section when/if we're actually serving. */
|
120 |
-
status_header
|
121 |
-
.
|
122 |
/**/
|
123 |
else /* Else return false. */
|
124 |
return false;
|
125 |
}
|
126 |
/**/
|
127 |
-
else if
|
128 |
{
|
129 |
-
if
|
130 |
{
|
131 |
-
if /* We only need this section when/if we're actually serving. */
|
132 |
-
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */
|
133 |
/**/
|
134 |
else /* Else return false. */
|
135 |
return false;
|
136 |
}
|
137 |
/**/
|
138 |
-
else if
|
139 |
{
|
140 |
-
if /* We only need this section when/if we're actually serving. */
|
141 |
-
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */
|
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. */
|
148 |
-
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */
|
149 |
/**/
|
150 |
else /* Else return false. */
|
151 |
return false;
|
152 |
}
|
153 |
/**/
|
154 |
-
else if
|
155 |
{
|
156 |
-
if /* We only need this section when/if we're actually serving. */
|
157 |
-
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */
|
158 |
/**/
|
159 |
else /* Else return false. */
|
160 |
return false;
|
161 |
}
|
162 |
/**/
|
163 |
-
else if
|
164 |
{
|
165 |
-
if /* We only need this section when/if we're actually serving. */
|
166 |
-
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars /* Configure MOP Vars here. */
|
167 |
/**/
|
168 |
else /* Else return false. */
|
169 |
return false;
|
170 |
}
|
171 |
/**/
|
172 |
-
else if /* In either case, the following routines apply. */
|
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
|
178 |
-
$user_file_download_access_arc = (is_array
|
179 |
/**/
|
180 |
-
$streaming_file_extns = c_ws_plugin__s2member_utils_strings::preg_quote_deep
|
181 |
-
$streaming_variations = /* Only count one streaming media file variation. */ "/\.("
|
182 |
/**/
|
183 |
-
foreach
|
184 |
{
|
185 |
-
if
|
186 |
{
|
187 |
-
if
|
188 |
{
|
189 |
-
unset /* Remove it from the `log`. */
|
190 |
$user_file_download_access_arc[] = /* Move `log` entry to the `archive` now. */ $user_file_download_access_log_entry;
|
191 |
}
|
192 |
-
else if
|
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. */
|
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
|
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
|
206 |
{
|
207 |
-
$_user_file_download_access_log_entry /* First, we update the last download time for this file. */["ltime"] = time
|
208 |
/**/
|
209 |
-
if
|
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
|
218 |
}
|
219 |
-
if
|
220 |
-
$user_file_download_access_log[] = array
|
221 |
/**/
|
222 |
-
if
|
223 |
{
|
224 |
-
if /* We only need this section when/if we're actually serving. */
|
225 |
-
wp_redirect
|
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. */
|
231 |
-
update_user_option
|
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
|
238 |
{
|
239 |
-
if /* We only need this section when/if we're actually serving. */
|
240 |
-
status_header
|
241 |
-
.
|
242 |
/**/
|
243 |
else /* Else return false. */
|
244 |
return false;
|
245 |
}
|
246 |
}
|
247 |
/**/
|
248 |
-
if /* In either case, the following routines apply. */
|
249 |
{
|
250 |
-
$basename = basename
|
251 |
-
$mimetypes = parse_ini_file
|
252 |
-
$extension = strtolower
|
253 |
/**/
|
254 |
-
$key = ($req["file_download_key"] && is_string
|
255 |
/**/
|
256 |
-
$stream = (isset
|
257 |
-
$inline = (!$stream && isset
|
258 |
-
$ssl = (isset
|
259 |
-
$storage = ($req["file_storage"] && is_string
|
260 |
-
$remote = (isset
|
261 |
/**/
|
262 |
-
$
|
263 |
-
$
|
264 |
-
$
|
|
|
|
|
265 |
/**/
|
266 |
-
$skip_confirmation = (isset
|
267 |
-
$url_to_storage_source = (isset
|
268 |
/**/
|
269 |
-
$pathinfo = (!$using_amazon_storage) ? pathinfo
|
270 |
$mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream";
|
271 |
-
$length = (!$using_amazon_storage && $file) ? filesize
|
272 |
/**/
|
273 |
-
eval
|
274 |
-
do_action
|
275 |
-
unset
|
276 |
/**/
|
277 |
-
if
|
278 |
{
|
279 |
-
if /* We only need this section when/if we're actually serving. */
|
280 |
-
wp_redirect
|
281 |
/**/
|
282 |
else /* Else return File Download URL. */
|
283 |
-
return apply_filters
|
284 |
}
|
285 |
/**/
|
286 |
-
else if
|
287 |
{
|
288 |
-
if /* We only need this section when/if we're actually serving. */
|
289 |
-
wp_redirect
|
290 |
/**/
|
291 |
else /* Else return File Download URL. */
|
292 |
-
return apply_filters
|
293 |
}
|
294 |
/**/
|
295 |
-
else if /* Creating a rewrite URL, pointing to local storage. */
|
296 |
{
|
297 |
-
$url = ($rewrite_base) ? rtrim
|
298 |
-
$url .= (isset
|
299 |
-
$url .= (isset
|
300 |
-
$url .= (isset
|
301 |
-
$url .= (isset
|
302 |
-
$url .= (isset
|
303 |
-
$url .= (isset
|
304 |
/**/
|
305 |
-
$url = /* File Download Access URL via `mod_rewrite` functionality. */ $url
|
306 |
-
$url = ($ssl) ? preg_replace
|
307 |
/**/
|
308 |
-
return apply_filters
|
309 |
}
|
310 |
/**/
|
311 |
-
else if /* Else we're creating a URL w/ a query-string; w/ local storage. */
|
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
|
314 |
-
$_url_e_storage = ($storage) ? c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep
|
315 |
-
$_url_e_file = c_ws_plugin__s2member_utils_strings::urldecode_ur_chars_deep
|
316 |
/**/
|
317 |
-
$url = (isset
|
318 |
-
$url .= (isset
|
319 |
-
$url .= (isset
|
320 |
-
$url .= (isset
|
321 |
-
$url .= (isset
|
322 |
-
$url .= (isset
|
323 |
/**/
|
324 |
-
$url = site_url
|
325 |
-
$url = ($ssl) ? preg_replace
|
326 |
/**/
|
327 |
-
return apply_filters
|
328 |
}
|
329 |
/**/
|
330 |
else /* Else, ``if ($serving)``, use local storage option. */
|
331 |
{
|
332 |
-
@set_time_limit
|
333 |
/**/
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
/**/
|
336 |
-
header
|
337 |
-
header
|
338 |
-
header
|
339 |
-
header
|
340 |
-
header
|
341 |
-
header
|
342 |
-
header
|
343 |
-
header
|
344 |
/**/
|
345 |
-
header
|
346 |
/**/
|
347 |
-
eval /* End/clean any output buffers that may exist already. Prep for content delivery. */
|
348 |
/**/
|
349 |
-
$
|
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
|
354 |
/**/
|
355 |
-
if
|
356 |
-
header
|
357 |
/**/
|
358 |
-
header /* `Transfer-Encoding: chunked` conserves memory. */
|
359 |
/**/
|
360 |
-
while
|
361 |
-
eval
|
362 |
/**/
|
363 |
-
fclose
|
364 |
}
|
365 |
-
else if
|
366 |
{
|
367 |
-
$_flush_size = apply_filters
|
368 |
/**/
|
369 |
-
if
|
370 |
-
header
|
371 |
/**/
|
372 |
-
while
|
373 |
-
eval /* Conserves memory. */
|
374 |
}
|
375 |
-
else if /* Else, use: ``file_get_contents()``. */
|
376 |
{
|
377 |
-
@ini_set
|
378 |
-
header
|
379 |
}
|
380 |
else /* Else, we have an empty file with no length. */
|
381 |
{
|
382 |
-
header
|
383 |
}
|
384 |
}
|
385 |
}
|
386 |
}
|
387 |
/**/
|
388 |
-
else if /* We only need this section when/if we're actually serving. */
|
389 |
-
status_header
|
390 |
-
.
|
391 |
/**/
|
392 |
-
else if /* We only need this section when/if we're creating a URL. */
|
393 |
return false;
|
394 |
/**/
|
395 |
-
do_action
|
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
|
413 |
{
|
414 |
-
eval
|
415 |
-
do_action
|
416 |
-
unset
|
417 |
/**/
|
418 |
-
$config = (is_array
|
419 |
/**/
|
420 |
-
$config["file_download"] = (isset
|
421 |
-
$config["file_download_key"] = (isset
|
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
|
427 |
{
|
428 |
-
eval
|
429 |
-
do_action
|
430 |
-
unset
|
431 |
/**/
|
432 |
-
$extension = strtolower
|
433 |
-
$streaming = (isset
|
434 |
-
$ssl = (isset
|
435 |
/**/
|
436 |
-
if
|
437 |
-
$return = array
|
438 |
/**/
|
439 |
-
else if
|
440 |
-
$return = array
|
441 |
/**/
|
442 |
-
else if /* If streamer, we MUST return false here; unable to acquire streamer/file. */
|
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
|
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
|
463 |
{
|
464 |
-
eval
|
465 |
-
do_action
|
466 |
-
unset
|
467 |
/**/
|
468 |
-
$_g = c_ws_plugin__s2member_utils_strings::trim_deep
|
469 |
/**/
|
470 |
-
if
|
471 |
{
|
472 |
-
do_action
|
473 |
/**/
|
474 |
-
if
|
475 |
{
|
476 |
-
header
|
477 |
/**/
|
478 |
-
status_header /* Send an unauthorized 401 status header now. */
|
479 |
-
header /* Content-Type with UTF-8. */
|
480 |
-
eval /* End/clean any output buffers that may exist. */
|
481 |
/**/
|
482 |
-
exit
|
483 |
}
|
484 |
-
else if
|
485 |
$user = /* Now assign ``$user``. */ $_user;
|
486 |
/**/
|
487 |
-
do_action
|
488 |
}
|
489 |
-
return apply_filters
|
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
|
502 |
{
|
503 |
-
eval
|
504 |
-
do_action
|
505 |
-
unset
|
506 |
/**/
|
507 |
-
if
|
508 |
{
|
509 |
-
if
|
510 |
$valid = /* File Download Key is valid. */ true;
|
511 |
-
else if
|
512 |
$valid = /* File Download Key is valid. */ true;
|
513 |
-
else if
|
514 |
$valid = /* File Download Key is valid. */ true;
|
515 |
}
|
516 |
-
return apply_filters
|
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
|
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
|
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
|
548 |
{
|
549 |
-
$file = /* Trim / force string. */ trim
|
550 |
/**/
|
551 |
-
foreach
|
552 |
-
if
|
553 |
$s3c[$option] = $option_value;
|
554 |
/**/
|
555 |
-
$s3c["expires"] = strtotime
|
556 |
/**/
|
557 |
-
$s3_file = add_query_arg
|
558 |
-
$s3_raw_file = add_query_arg
|
559 |
-
$s3_signature = base64_encode
|
560 |
/**/
|
561 |
-
$s3_url = ((strtolower
|
562 |
/**/
|
563 |
-
return add_query_arg
|
564 |
-
(urlencode_deep
|
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
|
578 |
-
if
|
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. */
|
584 |
{
|
585 |
-
$s3_date = gmdate
|
586 |
-
$s3_location = ((strtolower
|
587 |
-
$s3_domain = ((strtolower
|
588 |
-
$s3_signature = base64_encode
|
589 |
-
$s3_args = array
|
590 |
/**/
|
591 |
-
if
|
592 |
{
|
593 |
-
if
|
594 |
{
|
595 |
-
$s3_owner = array
|
596 |
-
$s3_acls_xml = '<AccessControlPolicy><Owner><ID>'
|
597 |
-
$s3_signature = base64_encode
|
598 |
-
$s3_args = array
|
599 |
/**/
|
600 |
-
if
|
601 |
{
|
602 |
-
$s3_location = ((strtolower
|
603 |
-
($s3_policy_id = md5
|
604 |
-
$s3_policy_json = '{"Version":"2008-10-17","Id":"'
|
605 |
-
$s3_signature = base64_encode
|
606 |
-
$s3_args = array
|
607 |
/**/
|
608 |
-
if
|
609 |
{
|
610 |
-
$s3_location = ((strtolower
|
611 |
-
$s3_policy_xml = trim
|
612 |
-
$s3_signature = base64_encode
|
613 |
-
$s3_args = array
|
614 |
/**/
|
615 |
-
if
|
616 |
-
return /* Successfully configured Amazon® S3 Bucket ACLs and Policy. */ array
|
617 |
/**/
|
618 |
-
else if
|
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
|
621 |
/**/
|
622 |
else /* Else, we use a default error code and message. */
|
623 |
-
return array
|
624 |
}
|
625 |
-
else if
|
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
|
628 |
/**/
|
629 |
else /* Else, we use a default error code and message. */
|
630 |
-
return array
|
631 |
}
|
632 |
-
else if
|
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
|
635 |
/**/
|
636 |
else /* Else, we use a default error code and message. */
|
637 |
-
return array
|
638 |
}
|
639 |
else /* Else, we use a default error code and message. */
|
640 |
-
return array
|
641 |
}
|
642 |
-
else if
|
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
|
645 |
/**/
|
646 |
else /* Else, we use a default error code and message. */
|
647 |
-
return array
|
648 |
}
|
649 |
else /* Else, we use a default error code and message. */
|
650 |
-
return array
|
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
|
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
|
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񅷦}
|
678 |
*/
|
679 |
-
public static function amazon_cf_rsa_sign
|
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
|
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
|
700 |
{
|
701 |
-
$file = /* Trim / force string. */ trim
|
702 |
/**/
|
703 |
-
foreach
|
704 |
-
if
|
705 |
$cfc[$option] = $option_value;
|
706 |
/**/
|
707 |
-
$cfc["expires"] = strtotime
|
708 |
/**/
|
709 |
-
$cf_extn = /* Parses the file extension out so we can scan it in some special scenarios. */ strtolower
|
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
|
711 |
-
$cf_stream_extn_resource_exclusions = array_unique
|
712 |
-
$cf_resource = ($stream) ? ((in_array
|
713 |
-
$cf_url = ($stream) ? "rtmp"
|
714 |
-
$cf_policy = '{"Statement":[{"Resource":"'
|
715 |
/**/
|
716 |
-
$cf_signature = c_ws_plugin__s2member_files_in::amazon_cf_rsa_sign
|
717 |
-
$cf_base64_url_safe_policy = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode
|
718 |
-
$cf_base64_url_safe_signature = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode
|
719 |
/**/
|
720 |
-
return add_query_arg
|
721 |
-
(urlencode_deep
|
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
|
735 |
-
if
|
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. */
|
743 |
{
|
744 |
-
if /* We MUST have Amazon® CloudFront Keys in order to auto-configure. */
|
745 |
{
|
746 |
-
if
|
747 |
{
|
748 |
-
if
|
749 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
750 |
/**/
|
751 |
-
else if
|
752 |
-
return array
|
753 |
/**/
|
754 |
-
else if
|
755 |
$cf_distro_downloads_clear = /* Clear, ready for a new one. */ true;
|
756 |
/**/
|
757 |
-
else if
|
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
|
760 |
/**/
|
761 |
-
if /* Successfully cleared? Ready for a new one? */
|
762 |
{
|
763 |
-
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */
|
764 |
/**/
|
765 |
-
if
|
766 |
{
|
767 |
-
if
|
768 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
769 |
/**/
|
770 |
-
else if
|
771 |
-
return array
|
772 |
/**/
|
773 |
-
else if
|
774 |
$cf_distro_streaming_clear = /* Clear, ready for a new one. */ true;
|
775 |
/**/
|
776 |
-
else if
|
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
|
779 |
/**/
|
780 |
-
if /* Successfully cleared? Ready for a new one? */
|
781 |
{
|
782 |
-
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */
|
783 |
/**/
|
784 |
-
if
|
785 |
{
|
786 |
-
if
|
787 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
788 |
/**/
|
789 |
-
else if
|
790 |
$cf_distros_access_clear = /* Clear, ready for a new one. */ true;
|
791 |
/**/
|
792 |
-
else if
|
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
|
795 |
/**/
|
796 |
-
if /* Successfully cleared? Ready for a new one? */
|
797 |
{
|
798 |
-
unset /* Unset these before processing additional routines. Prevents problems in error reporting. */
|
799 |
/**/
|
800 |
-
$cfc = array_merge
|
801 |
-
$cf_options = array
|
802 |
-
c_ws_plugin__s2member_menu_pages::update_all_options
|
803 |
/**/
|
804 |
-
if
|
805 |
{
|
806 |
-
$cfc = array_merge
|
807 |
-
$cf_options = array
|
808 |
-
c_ws_plugin__s2member_menu_pages::update_all_options
|
809 |
/**/
|
810 |
-
if
|
811 |
{
|
812 |
-
$cfc = array_merge
|
813 |
-
$cf_options = array
|
814 |
-
c_ws_plugin__s2member_menu_pages::update_all_options
|
815 |
/**/
|
816 |
-
if
|
817 |
{
|
818 |
-
$cfc = array_merge
|
819 |
-
$cf_options = array
|
820 |
-
c_ws_plugin__s2member_menu_pages::update_all_options
|
821 |
/**/
|
822 |
-
for
|
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
|
827 |
{
|
828 |
-
$cfc = array_merge
|
829 |
-
$cf_options = array
|
830 |
-
c_ws_plugin__s2member_menu_pages::update_all_options
|
831 |
-
return /* Successfully configured Amazon® S3/CloudFront distros. */ array
|
832 |
}
|
833 |
-
if
|
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
|
836 |
/**/
|
837 |
else /* Else, we use a default error code and message. */
|
838 |
-
return array
|
839 |
}
|
840 |
-
else if
|
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
|
843 |
/**/
|
844 |
else /* Else, we use a default error code and message. */
|
845 |
-
return array
|
846 |
}
|
847 |
-
else if
|
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
|
850 |
/**/
|
851 |
else /* Else, we use a default error code and message. */
|
852 |
-
return array
|
853 |
}
|
854 |
-
else if
|
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
|
857 |
/**/
|
858 |
else /* Else, we use a default error code and message. */
|
859 |
-
return array
|
860 |
}
|
861 |
else /* Else, we use a default error code and message. */
|
862 |
-
return array
|
863 |
}
|
864 |
-
else if
|
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
|
867 |
/**/
|
868 |
else /* Else, we use a default error code and message. */
|
869 |
-
return array
|
870 |
}
|
871 |
else /* Else, we use a default error code and message. */
|
872 |
-
return array
|
873 |
}
|
874 |
-
else if
|
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
|
877 |
/**/
|
878 |
else /* Else, we use a default error code and message. */
|
879 |
-
return array
|
880 |
}
|
881 |
else /* Else, we use a default error code and message. */
|
882 |
-
return array
|
883 |
}
|
884 |
-
else if
|
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
|
887 |
/**/
|
888 |
else /* Else, we use a default error code and message. */
|
889 |
-
return array
|
890 |
}
|
891 |
else /* Else, we use a default error code and message. */
|
892 |
-
return array
|
893 |
}
|
894 |
else /* Else, we use a default error code and message. */
|
895 |
-
return array
|
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
|
908 |
{
|
909 |
-
if /* Valid parameters? */
|
910 |
{
|
911 |
-
foreach
|
912 |
-
if
|
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
|
921 |
-
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/"
|
922 |
-
$cf_signature = base64_encode
|
923 |
-
$cf_args = array
|
924 |
/**/
|
925 |
-
if
|
926 |
{
|
927 |
-
if
|
928 |
-
return array
|
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
|
932 |
}
|
933 |
-
else if
|
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
|
936 |
/**/
|
937 |
else /* Else, we use a default error code and message. */
|
938 |
-
return array
|
939 |
}
|
940 |
else /* Else, we use a default error code and message. */
|
941 |
-
return array
|
942 |
}
|
943 |
/**
|
944 |
* Deletes an Amazon® S3/CloudFront Access Origin Identity.
|
@@ -952,12 +966,12 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
952 |
* @return array Array containing a true `success` element on success, else a failure array.
|
953 |
* Failure array will contain a failure `code`, and a failure `message`.
|
954 |
*/
|
955 |
-
public static function amazon_cf_del_access_origin_identity
|
956 |
{
|
957 |
-
if
|
958 |
{
|
959 |
-
foreach
|
960 |
-
if
|
961 |
$cfc[$option] = $option_value;
|
962 |
/**/
|
963 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
@@ -965,23 +979,23 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
965 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
966 |
/**/
|
967 |
$cf_domain = "cloudfront.amazonaws.com";
|
968 |
-
$cf_date = gmdate
|
969 |
-
$cf_location = "/2010-11-01/origin-access-identity/cloudfront/"
|
970 |
-
$cf_signature = base64_encode
|
971 |
-
$cf_args = array
|
972 |
/**/
|
973 |
-
if
|
974 |
-
return /* Deleted successfully. */ array
|
975 |
/**/
|
976 |
-
else if
|
977 |
/* 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. */
|
978 |
-
return array
|
979 |
/**/
|
980 |
else /* Else, we use a default error code and message. */
|
981 |
-
return array
|
982 |
}
|
983 |
else /* Else, we use a default error code and message. */
|
984 |
-
return array
|
985 |
}
|
986 |
/**
|
987 |
* Creates an Amazon® S3/CloudFront Access Origin Identity for all Distros.
|
@@ -992,10 +1006,10 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
992 |
* @return array Array containing a true `success` and `distros_access_id`, `distros_s3_access_id` elements on success, else a failure array.
|
993 |
* Failure array will contain a failure `code`, and a failure `message`.
|
994 |
*/
|
995 |
-
public static function amazon_cf_create_distros_access_origin_identity
|
996 |
{
|
997 |
-
foreach
|
998 |
-
if
|
999 |
$cfc[$option] = $option_value;
|
1000 |
/**/
|
1001 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
@@ -1003,27 +1017,27 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
1003 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1004 |
/**/
|
1005 |
$cf_domain = "cloudfront.amazonaws.com";
|
1006 |
-
$cf_date = gmdate
|
1007 |
$cf_location = "/2010-11-01/origin-access-identity/cloudfront";
|
1008 |
-
$cf_signature = base64_encode
|
1009 |
-
$cf_distros_access_reference = time
|
1010 |
-
$cf_distros_access_xml = '<?xml version="1.0" encoding="UTF-8"?><CloudFrontOriginAccessIdentityConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"><CallerReference>'
|
1011 |
-
$cf_args = array
|
1012 |
/**/
|
1013 |
-
if
|
1014 |
{
|
1015 |
-
if
|
1016 |
-
return array
|
1017 |
/**/
|
1018 |
else /* Else, we use a default error code and message. */
|
1019 |
-
return array
|
1020 |
}
|
1021 |
-
else if
|
1022 |
/* 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. */
|
1023 |
-
return array
|
1024 |
/**/
|
1025 |
else /* Else, we use a default error code and message. */
|
1026 |
-
return array
|
1027 |
}
|
1028 |
/**
|
1029 |
* Acquires an Amazon® S3/CloudFront Distro.
|
@@ -1036,12 +1050,12 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
1036 |
* @return array Array containing a true `success` and `etag`, `xml`, `deployed` elements on success, else a failure array.
|
1037 |
* Failure array will contain a failure `code`, and a failure `message`.
|
1038 |
*/
|
1039 |
-
public static function amazon_cf_get_distro
|
1040 |
{
|
1041 |
-
if
|
1042 |
{
|
1043 |
-
foreach
|
1044 |
-
if
|
1045 |
$cfc[$option] = $option_value;
|
1046 |
/**/
|
1047 |
$s3c["bucket"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"];
|
@@ -1049,28 +1063,28 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
|
|
1049 |
$cfc["secret_key"] = $s3c["secret_key"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
|
1050 |
/**/
|
1051 |
$cf_domain = "cloudfront.amazonaws.com";
|
1052 |
-
$cf_date = gmdate
|
1053 |
-
$cf_signature = base64_encode
|
1054 |
-
$cf_location = ($distro_type === "streaming") ? "/2010-11-01/streaming-distribution/"
|
1055 |
-
$cf_args = array
|
1056 |
/**/
|
1057 |
-
if
|
1058 |
{
|
1059 |
-
if
|
1060 |
-
return array
|
1061 |
/**/
|
1062 |
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. */
|
1063 |
-
return array
|
1064 |
}
|
1065 |
-
else if
|
1066 |
/* 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. */
|
1067 |