Example #1
0
 /**
  * Handles URI Level Access *(for specific URIs)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @param string $uri A URI, or a full URL is also fine.
  * @param bool   $check_user Test permissions against the current User? Defaults to true.
  *
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ruri_level_access($uri = '', $check_user = TRUE)
 {
     do_action('ws_plugin__s2member_before_check_specific_ruri_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : FALSE;
     $excluded = apply_filters('ws_plugin__s2member_check_specific_ruri_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && !empty($uri) && is_string($uri) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0'))) {
                 return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $uri)) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_specific_ruri_level_access', get_defined_vars());
         }
     }
     return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', NULL, get_defined_vars());
 }
 /**
  * Resolution SMIL Files.
  *
  * @package s2Member\Shortcodes
  * @since 140814
  *
  * @see http://tools.ietf.org/html/rfc4536
  */
 public static function serve()
 {
     if (empty($_GET['s2member_rsf_file'])) {
         return;
     }
     // Nothing to do here.
     header('Content-Type: application/smil+xml; charset=UTF-8');
     while (@ob_end_clean()) {
     }
     // Clean any existing output buffers.
     $smil_file_id = trim(stripslashes((string) $_GET['s2member_rsf_file']));
     if (empty($_GET['s2member_rsf_file_ip']) || trim(stripslashes($_GET['s2member_rsf_file_ip'])) !== $_SERVER['REMOTE_ADDR']) {
         exit;
     }
     // Invalid and/or missing IP address.
     if (!c_ws_plugin__s2member_utils_urls::s2member_sig_ok($_SERVER['REQUEST_URI'], TRUE, 86400)) {
         exit;
     }
     // Fail here. Invalid and/or expired SMIL file ID.
     if (!($smil_file = get_transient('s2m_rsf_' . $smil_file_id))) {
         exit;
     }
     // Fail here. Invalid and/or expired SMIL file ID.
     exit($smil_file);
 }
 /**
  * Verifies a reCAPTCHA™ code via Google®.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param str $challenge The value of `recaptcha_challenge_field` during form submisson.
  * @param str $response The value of `recaptcha_response_field` during form submission. 
  * @return bool True if ``$response`` is valid, else false.
  */
 public static function recaptcha_code_validates($challenge = FALSE, $response = FALSE)
 {
     $keys = c_ws_plugin__s2member_utils_captchas::recaptcha_keys();
     $post_vars = array("privatekey" => $keys["private"], "remoteip" => $_SERVER["REMOTE_ADDR"], "challenge" => $challenge, "response" => $response);
     /**/
     return preg_match("/^true/i", trim(c_ws_plugin__s2member_utils_urls::remote("http://www.google.com/recaptcha/api/verify", $post_vars)));
 }
 /**
  * Handles Registration Links.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection.
  */
 public static function register()
 {
     do_action("ws_plugin__s2member_before_register", get_defined_vars());
     /**/
     if (!empty($_GET["s2member_register"])) {
         eval('while (@ob_end_clean ());');
         /* First we end/clean any output buffers that may exist already. */
         /**/
         $msg_503 = _x('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
         /**/
         if (is_array($register = preg_split("/\\:\\.\\:\\|\\:\\.\\:/", c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes((string) $_GET["s2member_register"])))))) {
             if (count($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time") {
                 if (is_numeric($register[5]) && $register[5] <= strtotime("now") && $register[5] >= strtotime("-" . apply_filters("ws_plugin__s2member_register_link_exp_time", "2 days", get_defined_vars()))) {
                     $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[1]);
                     $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[2]);
                     $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[3]);
                     $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[4]);
                     /**/
                     if (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                         status_header(200);
                         /* Send a 200 OK status header. */
                         header("Content-Type: text/html; charset=utf-8");
                         /* Content-Type with UTF-8. */
                         /**/
                         setcookie("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("s2member_custom", $_COOKIE["s2member_custom"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_custom", $_COOKIE["s2member_custom"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("s2member_item_number", $_COOKIE["s2member_item_number"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_item_number", $_COOKIE["s2member_item_number"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         /**/
                         do_action("ws_plugin__s2member_during_register", get_defined_vars());
                         /**/
                         if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site() && ($location = c_ws_plugin__s2member_utils_urls::wp_signup_url())) {
                             echo '<script type="text/javascript">' . "\n";
                             echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($location) . "';";
                             echo '</script>' . "\n";
                         } else {
                             if ($location = c_ws_plugin__s2member_utils_urls::wp_register_url()) {
                                 echo '<script type="text/javascript">' . "\n";
                                 echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($location) . "';";
                                 echo '</script>' . "\n";
                             }
                         }
                         exit;
                         /* Clean exit. The browser will now be redirected to ``$location``. */
                     } else {
                         status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
                     }
                 } else {
                     status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
                 }
             } else {
                 status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
             }
         } else {
             status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
         }
     }
     /**/
     do_action("ws_plugin__s2member_after_register", get_defined_vars());
 }
 /**
  * Handles URI Level Access *(for specific URIs)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @param string $uri A URI, or a full URL is also fine.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ruri_level_access($uri = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars());
     $uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : false;
     $excluded = apply_filters("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars());
     if (!$excluded && !empty($uri) && is_string($uri) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(null, $uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0"))) {
                 return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(null, $uri)) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             // URIs configured at this Level?
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars());
         }
     }
     return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars());
 }
 /**
  * Handles Google Return URL processing.
  *
  * @package s2Member\Google
  * @since 131123
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection.
  */
 public static function google_return()
 {
     global $current_site, $current_blog;
     if (!empty($_GET["s2member_pro_google_return"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]) {
         $google["s2member_log"][] = "Return URL processed on: " . date("D M j, Y g:i:s a T");
         $google["s2member_log"][] = "Piping through s2Member's core/standard PayPal processor with `proxy_use` ( `ty-email` ).";
         $google["s2member_log"][] = "Please check PayPal RTN logs for further processing details.";
         $rtn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-emails,ty-email";
         if (!empty($_GET["s2member_pro_google_return_success"])) {
             $rtn_q .= "&s2member_paypal_return_success=" . rawurlencode(trim(stripslashes($_GET["s2member_pro_google_return_success"])));
         }
         $rtn_r = home_url("/?s2member_pro_google_return&s2member_paypal_return=1" . $rtn_q);
         $rtn_r = c_ws_plugin__s2member_utils_urls::add_s2member_sig($rtn_r, "s2member_paypal_proxy_verification");
         $google["s2member_log"][] = $rtn_r;
         wp_redirect($rtn_r);
         $logt = c_ws_plugin__s2member_utilities::time_details();
         $logv = c_ws_plugin__s2member_utilities::ver_details();
         $logm = c_ws_plugin__s2member_utilities::mem_details();
         $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . @$_SERVER["HTTP_USER_AGENT"];
         $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
         $log2 = is_multisite() && !is_main_site() ? "google-rtn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "google-rtn.log";
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
             if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
                 if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                     file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($google, true)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         exit;
         // Exit now.
     }
 }
 /**
  * Handles Category Level Access *( for specific Categories )*.
  *
  * @package s2Member\Categories
  * @since 3.5
  *
  * @param int|str $cat_id Numeric Category ID.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
  */
 public static function check_specific_catg_level_access($cat_id = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars());
     /**/
     $excluded = apply_filters("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars());
     /**/
     if (!$excluded && is_numeric($cat_id) && ($cat_id = (int) $cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         $cat_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_category_link($cat_id));
         /* Get a full valid URI for this Category. */
         /**/
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(null, $cat_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             /* Current User's object. */
             /**/
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $cat_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0"))) {
                 return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(null, $cat_uri)) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                             return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                         } else {
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array($cat_id, $catgs = preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                 return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                             } else {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) {
                                     /* Check Category ancestry. */
                                     foreach (preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg) {
                                         if ($catg && cat_is_ancestor_of($catg, $cat_id) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     /**/
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             /* URIs configured at this Level? */
                             /**/
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $cat_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             /**/
             do_action("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars());
         }
     }
     /**/
     return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars());
 }
 /**
  * Currency converter.
  *
  * Uses the Google currency conversion API.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param int|float|string $a The amount, in ``$from``.
  * @param string           $from Three character currency code.
  * @param string           $to Three character currency code.
  *
  * @return string A numeric amount in ``$to``, after having been converted. Else false.
  */
 public static function convert($a = 0, $from = '', $to = '')
 {
     if (is_numeric($a) && strlen($from) === 3 && strlen($to) === 3) {
         $q = strtoupper($from . '-' . $to);
         // Also need this to test the return value.
         $endpoint = 'http://www.freecurrencyconverterapi.com/api/convert?q=' . urlencode($q) . '&compact=y';
         if (($json = c_ws_plugin__s2member_utils_urls::remote($endpoint)) && is_object($json = json_decode($json)) && isset($json->{$q}->val) && is_float($conversion = (double) $a * (double) $json->{$q}->val)) {
             return number_format($conversion, 2, '.', '');
         }
     }
     return '';
     // Default return value.
 }
Example #9
0
 /**
  * Currency converter.
  *
  * Uses the Google currency conversion API.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param int|str $a The amount, in ``$from``.
  * @param str $from A 3 character Currency Code.
  * @param str $to A 3 character Currency Code.
  * @return float|str|bool A numeric amount in ``$to``,
  * 	after having been converted. Else false.
  *
  * @see http://www.techmug.com/ajax-currency-converter-with-google-api/
  */
 public static function convert($a = FALSE, $from = FALSE, $to = FALSE)
 {
     if (is_numeric($a) && strlen($from = strtoupper($from)) === 3 && strlen($to = strtoupper($to)) === 3) {
         $q = number_format($a, 2, ".", "") . $from . "=?" . $to;
         $api = "http://www.google.com/ig/calculator?hl=en&q=" . urlencode($q);
         if (($json = preg_replace('/([{,])\\s*([^"]+?)\\s*:/', '$1"$2":', c_ws_plugin__s2member_utils_urls::remote($api))) && is_array($json = json_decode($json, true)) && !empty($json["icc"]) && isset($json["rhs"]) && strlen($json["rhs"])) {
             if (is_numeric($c_a = preg_replace("/ .*\$/", "", trim($json["rhs"]))) && $c_a >= 0) {
                 return number_format($c_a, 2, ".", "");
             }
         }
     }
     return false;
     // Default return value.
 }
 /**
  * Shortcode `[s2Member-Pro-Google-Button /]`.
  *
  * @package s2Member\Google
  * @since 1.5
  *
  * @attaches-to ``add_shortcode("s2Member-Pro-Google-Button");``
  *
  * @param array $attr An array of Attributes.
  * @param string $content Content inside the Shortcode.
  * @param string $shortcode The actual Shortcode name itself.
  * @return string The resulting Google Button Code; HTML markup.
  */
 public static function sc_google_button($attr = FALSE, $content = FALSE, $shortcode = FALSE)
 {
     c_ws_plugin__s2member_no_cache::no_cache_constants(true);
     $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr);
     $jwt_attr = c_ws_plugin__s2member_utils_encryption::encrypt(serialize($attr));
     $attr = shortcode_atts(array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "rrt" => "", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "anchor", "success" => "", "failure" => ""), $attr);
     if ($attr["modify"] || $attr["cancel"]) {
         $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/google-edit-button.png";
         $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/google-cancellation-button.php")));
         $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
         $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code);
         $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code);
         $code = $attr["output"] === "anchor" ? $code : $code;
         if ($attr["output"] === "url" && preg_match('/ href\\="(.*?)"/', $code, $m) && ($href = $m[1])) {
             $code = $url = c_ws_plugin__s2member_utils_urls::n_amps($href);
         }
         unset($href, $url, $m);
     } else {
         if ($attr["sp"]) {
             $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/google-wallet-co.png";
             $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/google-sp-checkout-button.php")));
             $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
             $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code);
             $code = preg_replace("/%%jwt_attr%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($jwt_attr)), $code);
             $code = preg_replace(array("/%%success%%/", "/%%failure%%/"), array($attr["success"], $attr["failure"]), $code);
             $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code);
         } else {
             if ($attr["level"] === "*") {
                 $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/google-wallet-co.png";
                 $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/google-ccaps-checkout-button.php")));
                 $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
                 $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code);
                 $code = preg_replace("/%%jwt_attr%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($jwt_attr)), $code);
                 $code = preg_replace(array("/%%success%%/", "/%%failure%%/"), array($attr["success"], $attr["failure"]), $code);
                 $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code);
             } else {
                 $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/google-wallet-co.png";
                 $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/google-checkout-button.php")));
                 $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
                 $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code);
                 $code = preg_replace("/%%jwt_attr%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($jwt_attr)), $code);
                 $code = preg_replace(array("/%%success%%/", "/%%failure%%/"), array($attr["success"], $attr["failure"]), $code);
                 $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code);
             }
         }
     }
     return $code;
 }
 /**
  * Generates Registration Access Links.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @param string     $subscr_gateway Payment Gateway associated with a Customer.
  * @param string     $subscr_id Unique Subscr. ID associated with Payment Gateway; associated with a Customer.
  * @param string     $custom Custom String value *(as supplied in Shortcode)*; must start with installation domain name.
  * @param int|string $item_number An s2Member-generated `item_number` *( i.e., `1` for Level 1, or `level|ccaps|fixed-term`, or `sp|ids|expiration` )*.
  * @param bool       $shrink Optional. Defaults to true. If false, the raw registration link will NOT be reduced in size through the tinyURL API.
  *
  * @return string|bool A Registration Access Link on success, else false on failure.
  */
 public static function register_link_gen($subscr_gateway = '', $subscr_id = '', $custom = '', $item_number = '', $shrink = TRUE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_register_link_gen', get_defined_vars());
     unset($__refs, $__v);
     if ($subscr_gateway && is_string($subscr_gateway) && $subscr_id && is_string($subscr_id) && $custom && is_string($custom) && $item_number && (is_string($item_number) || is_numeric($item_number))) {
         $register = c_ws_plugin__s2member_utils_encryption::encrypt('subscr_gateway_subscr_id_custom_item_number_time:.:|:.:' . $subscr_gateway . ':.:|:.:' . $subscr_id . ':.:|:.:' . $custom . ':.:|:.:' . $item_number . ':.:|:.:' . strtotime('now'));
         $register_link = home_url('/?s2member_register=' . urlencode($register));
         // Generate long URL/link.
         if ($shrink && ($shorter_url = c_ws_plugin__s2member_utils_urls::shorten($register_link))) {
             $register_link = $shorter_url . '#' . $_SERVER['HTTP_HOST'];
         }
     }
     return apply_filters('ws_plugin__s2member_register_link_gen', !empty($register_link) ? $register_link : FALSE, get_defined_vars());
 }
 /**
  * Generates Registration Access Links.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @param string $subscr_gateway Payment Gateway associated with a Customer.
  * @param string $subscr_id Unique Subscr. ID associated with Payment Gateway; associated with a Customer.
  * @param string $custom Custom String value *(as supplied in Shortcode)*; must start with installation domain name.
  * @param int|string $item_number An s2Member-generated `item_number` *( i.e. `1` for Level 1, or `level|ccaps|fixed-term`, or `sp|ids|expiration` )*.
  * @param bool $shrink Optional. Defaults to true. If false, the raw registration link will NOT be reduced in size through the tinyURL API.
  * @return string|bool A Registration Access Link on success, else false on failure.
  */
 public static function register_link_gen($subscr_gateway = FALSE, $subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_register_link_gen", get_defined_vars());
     unset($__refs, $__v);
     if ($subscr_gateway && is_string($subscr_gateway) && $subscr_id && is_string($subscr_id) && $custom && is_string($custom) && $item_number && (is_string($item_number) || is_numeric($item_number))) {
         $register = c_ws_plugin__s2member_utils_encryption::encrypt("subscr_gateway_subscr_id_custom_item_number_time:.:|:.:" . $subscr_gateway . ":.:|:.:" . $subscr_id . ":.:|:.:" . $custom . ":.:|:.:" . $item_number . ":.:|:.:" . strtotime("now"));
         $register_link = site_url("/?s2member_register=" . urlencode($register));
         // Generate long URL/link.
         if ($shrink && ($shorter_url = c_ws_plugin__s2member_utils_urls::shorten($register_link))) {
             $register_link = $shorter_url . "#" . $_SERVER["HTTP_HOST"];
         }
     }
     return apply_filters("ws_plugin__s2member_register_link_gen", !empty($register_link) ? $register_link : false, get_defined_vars());
 }
 /**
  * Generates Specific Post/Page Access links.
  *
  * @package s2Member\SP_Access
  * @since 3.5
  *
  * @param string|int $sp_ids Comma-delimited list of Specific Post/Page IDs *(numerical)*.
  * @param int|string $hours Optional. A numeric expiration time for this link, in hours. Defaults to `72`.
  * @param bool $shrink Optional. Defaults to true. If false, the raw link will NOT be processed by the tinyURL API.
  * @return str|bool A Specific Post/Page Access Link, or false on failure.
  */
 public static function sp_access_link_gen($sp_ids = FALSE, $hours = 72, $shrink = TRUE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_sp_access_link_gen", get_defined_vars());
     unset($__refs, $__v);
     if ((is_string($sp_ids) || is_numeric($sp_ids)) && ($sp_ids = preg_replace("/[^0-9;,]/", "", $sp_ids)) && ($leading_id = preg_replace("/^([0-9]+).*\$/", "\$1", $sp_ids)) && is_numeric($hours)) {
         $sp_access = c_ws_plugin__s2member_utils_encryption::encrypt("sp_time_hours:.:|:.:" . $sp_ids . ":.:|:.:" . strtotime("now") . ":.:|:.:" . $hours);
         $sp_access_link = add_query_arg("s2member_sp_access", urlencode($sp_access), get_permalink($leading_id));
         // Generate long URL/link.
         if ($shrink && ($shorter_url = c_ws_plugin__s2member_utils_urls::shorten($sp_access_link))) {
             $sp_access_link = $shorter_url . "#" . $_SERVER["HTTP_HOST"];
         }
     }
     return apply_filters("ws_plugin__s2member_sp_access_link_gen", !empty($sp_access_link) ? $sp_access_link : false, get_defined_vars());
 }
Example #14
0
 /**
  * Currency converter.
  *
  * Uses the Google currency conversion API.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param int|float|string $a The amount, in ``$from``.
  * @param string           $from Three character currency code.
  * @param string           $to Three character currency code.
  *
  * @return string A numeric amount in ``$to``, after having been converted. Else false.
  */
 public static function convert($a = 0, $from = '', $to = '')
 {
     if (is_numeric($a) && strlen($from) === 3 && strlen($to) === 3) {
         $regex = '/\\<span\\s+class\\s*\\=\\s*(?:["\'])?bld(?:["\'])?\\s*\\>(?P<conversion>[0-9.]+)\\s+' . preg_quote($to, '/') . '\\s*\\<\\/span\\>/i';
         $endpoint = 'http://www.google.com/finance/converter?a=' . urlencode($a) . '&from=' . urlencode($from) . '&to=' . urlencode($to);
         $prefix = 's2m_cur';
         // Transient prefix.
         $transient = $prefix . md5('s2member_cur_convert_' . $endpoint);
         if (!($response = get_transient($transient))) {
             $response = c_ws_plugin__s2member_utils_urls::remote($endpoint);
             set_transient($transient, $response, DAY_IN_SECONDS / 2);
         }
         if ($response && preg_match($regex, $response, $m)) {
             return number_format((double) $m['conversion'], 2, '.', '');
         }
     }
     return '';
     // Default return value.
 }
 /**
  * Handles processing of Pro-Form billing updates.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_update()
 {
     if (!empty($_POST['s2member_pro_stripe_update']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_update']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-update')) {
         $GLOBALS['ws_plugin__s2member_pro_stripe_update_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_update_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_update']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__s2member_pro_stripe_update_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
         // Collect reCAPTCHA™ post vars.
         if (!c_ws_plugin__s2member_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__s2member_pro_stripe_responses::stripe_form_submission_validation_errors('update', $post_vars))) {
                 if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($cur__subscr_cid = get_user_option('s2member_subscr_cid')) && ($cur__subscr_id = get_user_option('s2member_subscr_id'))) {
                         if (is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id)) && !preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
                             unset($_POST['s2member_pro_stripe_update']['source_token']);
                             // These are good one-time only.
                             unset($_POST['s2member_pro_stripe_update']['source_token_summary']);
                             if (is_object($set_customer_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($cur__subscr_cid, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                 $global_response = array('response' => _x('<strong>Confirmed.</strong> Your billing information has been updated.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 $global_response = array('response' => $set_customer_source, 'error' => TRUE);
                             }
                         } else {
                             $global_response = array('response' => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Oops.</strong> No Customer|Subscr. ID. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 } else {
                     $global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
Example #16
0
 public function __construct()
 {
     echo '<div class="wrap ws-menu-page">' . "\n";
     echo '<div class="ws-menu-page-toolbox">' . "\n";
     c_ws_plugin__s2member_menu_pages_tb::display();
     echo '</div>' . "\n";
     echo '<h2>Multisite Config</h2>' . "\n";
     echo '<table class="ws-menu-page-table">' . "\n";
     echo '<tbody class="ws-menu-page-table-tbody">' . "\n";
     echo '<tr class="ws-menu-page-table-tr">' . "\n";
     echo '<td class="ws-menu-page-table-l">' . "\n";
     if (is_multisite() && is_main_site()) {
         echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">' . "\n";
         echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")) . '" />' . "\n";
         echo '<input type="hidden" name="ws_plugin__s2member_configured" id="ws-plugin--s2member-configured" value="1" />' . "\n";
         do_action("ws_plugin__s2member_during_mms_ops_page_before_left_sections", get_defined_vars());
         if (apply_filters("ws_plugin__s2member_during_mms_ops_page_during_left_sections_display_mms_patches", true, get_defined_vars())) {
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_before_mms_patches", get_defined_vars());
             echo '<div class="ws-menu-page-group" title="Multisite WordPress Patches" default-state="open">' . "\n";
             echo '<div class="ws-menu-page-section ws-plugin--s2member-mms-patches-section">' . "\n";
             echo '<img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/small-icon.png" title="s2Member (a Membership management system for WordPress)" alt="" style="float:right; margin:0 0 0 25px; border:0;" />' . "\n";
             echo '<h3>Multisite WordPress Patches (required for compatiblity)</h3>' . "\n";
             echo '<p>In order for s2Member to function properly in a Multisite environment, you MUST implement four patches. One goes into your <code>/wp-login.php</code> file, one into <code>/wp-includes/load.php</code>, one into <code>/wp-includes/ms-functions.php</code>, and another into <code>/wp-admin/user-new.php</code>. Please use the automatic patcher below. All you do is check the box &amp; click Save.</p>' . "\n";
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_during_mms_patches", get_defined_vars());
             echo '<table class="form-table">' . "\n";
             echo '<tbody>' . "\n";
             echo '<tr>' . "\n";
             echo '<th>' . "\n";
             echo '<label for="ws-plugin--s2member-mms-auto-patch">' . "\n";
             echo 'Patch Automatically? (the easiest way)' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             if (defined("DISALLOW_FILE_MODS") && DISALLOW_FILE_MODS) {
                 echo '<select name="ws_plugin__s2member_mms_auto_patch" id="ws-plugin--s2member-mms-auto-patch" disabled="disabled">' . "\n";
                 echo '<option value="0" selected="selected">No (I\'ll patch WordPress myself)</option>' . "\n";
                 echo '</select><br />' . "\n";
                 echo '<em class="ws-menu-page-hilite">This is now locked. Your <code>/wp-config.php</code> file says: <code>DISALLOW_FILE_MODS = true</code></em>.' . "\n";
             } else {
                 echo '<select name="ws_plugin__s2member_mms_auto_patch" id="ws-plugin--s2member-mms-auto-patch">' . "\n";
                 echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] ? ' selected="selected"' : '') . '>Yes (automatically patch WordPress)</option>' . "\n";
                 echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] ? ' selected="selected"' : '') . '>No (I\'ll patch WordPress myself)</option>' . "\n";
                 echo '</select><br />' . "\n";
                 echo '<em class="ws-menu-page-hilite">These files MUST be patched, each time you upgrade the WordPress core. If you set this option to <code>Yes (Patch Automatically)</code>, s2Member will patch your installation now, and also in the future, should you upgrade to newer version. That way, you won\'t need to patch manually each time WordPress is upgraded.</em>' . "\n";
             }
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '<div class="ws-menu-page-hr"></div>' . "\n";
             echo '<div id="ws-plugin--s2member-mms-patches-details-wrapper">' . "\n";
             echo '<h3>Rather Do It Yourself? (<a href="#" onclick="jQuery(\'div#ws-plugin--s2member-mms-patches-details\').toggle(); return false;" class="ws-dotted-link">manual instructions</a>)</h3>' . "\n";
             echo '<div id="ws-plugin--s2member-mms-patches-details" style="display:none;">' . "\n";
             echo '<p><strong>Patch #1</strong> ( /wp-login.php )</p>' . "\n";
             echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/mms-patch-wp-login.x-php")) . '</p>' . "\n";
             echo '<p><strong>Patch #2</strong> ( /wp-includes/load.php )</p>' . "\n";
             echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/mms-patch-load.x-php")) . '</p>' . "\n";
             echo '<p><strong>Patch #3</strong> ( /wp-admin/user-new.php )</p>' . "\n";
             echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/mms-patch-user-new.x-php")) . '</p>' . "\n";
             echo '<p><strong>Patch #4</strong> ( /wp-includes/ms-functions.php )</p>' . "\n";
             echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/mms-patch-ms-functions.x-php")) . '</p>' . "\n";
             echo '<p><em class="ws-menu-page-hilite">Don\'t forget to patch these files again, each time you upgrade the WordPress core.</em></p>' . "\n";
             echo '</div>' . "\n";
             echo '</div>' . "\n";
             echo '</div>' . "\n";
             echo '</div>' . "\n";
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_after_mms_patches", get_defined_vars());
         }
         if (apply_filters("ws_plugin__s2member_during_mms_ops_page_during_left_sections_display_mms_registration", true, get_defined_vars())) {
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_before_mms_registration", get_defined_vars());
             echo '<div class="ws-menu-page-group" title="Multisite Registration Configuration" default-state="open">' . "\n";
             echo '<div class="ws-menu-page-section ws-plugin--s2member-mms-registration-section">' . "\n";
             echo '<img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/large-icon.png" title="s2Member (a Membership management system for WordPress)" alt="" style="float:right; margin:0 0 0 25px; border:0;" />' . "\n";
             echo '<h3>Multisite Registration (Main Site Configuration)</h3>' . "\n";
             echo '<p>s2Member supports Free Subscribers <em>(at Level #0)</em>, and several Primary Roles created by the s2Member plugin (<em> i.e. s2Member Levels 1-4, or up to the number of configured Levels )</em>. If you want your visitors to be capable of registering absolutely free, you will want to "allow" Open Registration. Whenever a visitor registers without paying, they\'ll automatically become a Free Subscriber, at Level #0.</p>' . "\n";
             echo '<p><strong>Running A Multisite Blog Farm?</strong> With Multisite Networking enabled, your Main Site could ALSO offer a Customer access to create a Blog of their own <em>(optional)</em>, where a Customer becomes a "Member" of your Main Site, and also a Blog Owner/Administrator of at least one other Blog on your Network. With s2Member installed <em>(Network wide)</em>, each of your Blog Owners could offer Membership too, using a single copy of the s2Member plugin, which is a great selling point<em>!</em> We refer to this type of installation as a Multisite Blog Farm.</p>' . "\n";
             echo '<p>Multisite Networking makes a new Registration Form available <em>(driven by your theme)</em>; which we refer to as: <code>/wp-signup.php</code>. If, and only if, you\'re planning to offer Blogs, you MUST use <a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::wp_signup_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Multisite Registration Form.\\n* s2Member makes this form available to logged-in Super Administrators, at all times (for testing purposes), regardless of configuration.' . (c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '') . '\');">/wp-signup.php</a>, instead of using the Standard Login/Registration Form. In a Multisite installation, we refer to the Standard Login/Registration Form, as: <a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::wp_register_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Standard Registration Form.\\n* s2Member makes this form available to logged-in Administrators, at all times (for testing purposes), regardless of configuration.' . (c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '') . '\');">/wp-login.php?action=register</a>. If you\'re planning to offer Membership Access only, and NOT Blogs, you can simply use the <a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::wp_register_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Standard Registration Form.\\n* s2Member makes this form available to logged-in Administrators, at all times (for testing purposes), regardless of configuration.' . (c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '') . '\');">Standard Login/Registration Form</a>, which is easily customized through <code>s2Member -› General Options -› Login/Registration Design</code>.</p>' . "\n";
             echo '<p>In either case, s2Member Pro Forms are possible too. If you\'ve purchased s2Member Pro, you could use Pro Forms instead of these WordPress defaults. That being said, even with s2Member Pro Forms, if you are offering Blogs, you will still need to facilitate the actual creation of each Blog through <code>/wp-signup.php</code>. In other words, Customers can register through s2Member Pro Forms, and even checkout. But when it comes time to setup a new Blog, you will need to redirect your Customer to <code>/wp-signup.php</code>, while they are logged-in. This will allow them to create a new Blog on your Network. That is, if they are allowed to <em>(based on your configuration below)</em>.</p>' . "\n";
             echo c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '<p><em><strong>BuddyPress:</strong> BuddyPress will use its own Registration Form, powered by your theme.<br />(BuddyPress can handle both Membership and Blog creation in its integration)<br />(<a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::bp_register_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your BuddyPress Registration Form.\\n* However, you will probably be redirected away from this BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.\');">' . esc_html(c_ws_plugin__s2member_utils_urls::bp_register_url()) . '</a>)</em></p>' . "\n" : '';
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_during_mms_registration", get_defined_vars());
             echo '<div id="ws-plugin--s2member-mms-registration-support-package-details-wrapper">' . "\n";
             echo '<h4 style="margin-bottom:0;">Running a Multisite Blog Farm? (<a href="#" onclick="jQuery(\'div#ws-plugin--s2member-mms-registration-support-package-details\').toggle(); return false;" class="ws-dotted-link">click here / please read</a>)</h4>' . "\n";
             echo '<div id="ws-plugin--s2member-mms-registration-support-package-details" style="display:none;">' . "\n";
             echo '<p>The most important thing to do when setting up a Blog Farm with s2Member, is to add this line to your <code>/wp-config.php</code> file: <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>. This will add a default layer of security, to all Blogs within your Network, with respect to s2Member. <strong>But, before you go live</strong>, please contact <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")) . '" target="_blank" rel="external">s2Member.com</a> for full documentation. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. You will be asked to purchase our <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")) . '" target="_blank" rel="external">Network Support Package</a> when you need assistance in this regard.</p>' . "\n";
             echo '<p>Multisite Blog Farms require a site owner that fully understands the potential security risks associated with Blog Farming. s2Member\'s <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Pro Module / Prices")) . '" target="_blank" rel="external">Network Support Package</a> provides you with the information you need, and priority support for anything about s2Member that you don\'t understand. In addition, our Network Support Package includes a lengthy PDF file that details a list of things affected by <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"MULTISITE_FARM"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>, best practices, and other supplemental documentation focused on Blog Farms.</p>' . "\n";
             echo '<p><em><strong>Definition of a Multisite Blog Farm:</strong> If your Network is making it possible for "Members" of your Main Site, to create and/or manage Blogs (in any way), s2Member will consider your installation to be a Multisite Blog Farm. That being said, some site owners run a Multisite Network for the purpose of maintaining their own sites. The term Multisite Blog Farm does NOT apply to a Network that hosts multiple Child Blogs, all of which are operated by a single site owner and/or a single company. Again, a Multisite Blog Farm (in the eyes of s2Member), is any Network that is making it possible for "Members" of its Main Site, to create and/or manage Blogs; where one or more of these Child Blogs is being administered by a Customer (e.g. if you offer both Membership and Blog creation, as configured below).</em></p>' . "\n";
             echo '<p><em><strong>When NOT to run a Multisite Blog Farm:</strong> If you run a Multisite Network for the purpose of maintaining your own sites. You should NOT run a Multisite Blog Farm. You can still activate s2Member Network-wide, if you like (optional), but the advanced security considerations offered through s2Member\'s Multisite Blog Farm functionality are NOT needed in this case; because all of the Child Blogs in your Network belong to trusted Administrators (i.e. your Customers are NOT going to run Child Blogs on your Network in this case).</em></p>' . "\n";
             echo '</div>' . "\n";
             echo '</div>' . "\n";
             echo '<div class="ws-menu-page-hr"></div>' . "\n";
             echo '<table class="form-table">' . "\n";
             echo '<tbody>' . "\n";
             echo '<tr>' . "\n";
             echo '<th>' . "\n";
             echo '<label for="ws-plugin--s2member-mms-registration-file">' . "\n";
             echo 'What Do You Plan To Offer? (please choose one)' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             if (defined("MULTISITE_FARM") && MULTISITE_FARM) {
                 echo '<select name="ws_plugin__s2member_mms_registration_file" id="ws-plugin--s2member-mms-registration-file" disabled="disabled">' . "\n";
                 echo '<option value="wp-signup" selected="selected">Blog Farm (I plan to offer both Membership &amp; Blog creation)</option>' . "\n";
                 echo '</select><br />' . "\n";
                 echo '<em class="ws-menu-page-hilite">This is now locked. Your <code>/wp-config.php</code> file says: <code>MULTISITE_FARM = true</code></em>.' . "\n";
             } else {
                 echo '<select name="ws_plugin__s2member_mms_registration_file" id="ws-plugin--s2member-mms-registration-file">' . "\n";
                 echo '<option value="wp-login"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-login" ? ' selected="selected"' : '') . '>Membership Only (I\'m NOT offering Blogs)</option>' . "\n";
                 echo '<option value="wp-signup"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup" ? ' selected="selected"' : '') . '>Blog Farm (I plan to offer both Membership &amp; Blog creation)</option>' . "\n";
                 echo '</select><br />' . "\n";
                 echo 'Depending on your selection, the options below may change.' . "\n";
             }
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '<div class="ws-menu-page-hr"></div>' . "\n";
             echo '<table class="form-table ws-plugin--s2member-mms-registration-wp-login" style="margin:0;">' . "\n";
             echo '<tbody>' . "\n";
             echo '<tr>' . "\n";
             echo '<th style="padding-top:0;">' . "\n";
             echo '<label for="ws-plugin--s2member-allow-subscribers-in">' . "\n";
             echo 'Your Main Site / Allow Open Registration? (via <code>wp-login.php?action=register</code>)' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             echo '<select name="ws_plugin__s2member_allow_subscribers_in" id="ws-plugin--s2member-allow-subscribers-in">' . "\n";
             echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"] ? ' selected="selected"' : '') . '>No (do NOT allow Open Registration)</option>' . "\n";
             echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"] ? ' selected="selected"' : '') . '>Yes (allow Open Registration; Free Subscribers at Level #0)</option>' . "\n";
             echo '</select><br />' . "\n";
             echo 'If you set this to <code>Yes</code>, you\'re unlocking <a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::wp_register_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Standard Registration Form.\\n* s2Member makes this form available to logged-in Administrators, at all times (for testing purposes), regardless of configuration.' . (c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '') . '\');">wp-login.php?action=register</a> (on your Main Site). When a visitor registers without paying, they\'ll automatically become a Free Subscriber, at Level #0. The s2Member software reserves Level #0; to be used ONLY for Free Subscribers. All other Membership Levels [1-4] require payment.' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '<table class="form-table ws-plugin--s2member-mms-registration-wp-signup" style="margin:0;">' . "\n";
             echo '<tbody>' . "\n";
             echo '<tr>' . "\n";
             echo '<th style="padding-top:0;">' . "\n";
             echo '<label for="ws-plugin--s2member-mms-registration-grants">' . "\n";
             echo 'Your Main Site / Allow Open Registration? (via <code>wp-signup.php</code>)' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td style="padding-bottom:0;">' . "\n";
             echo '<select name="ws_plugin__s2member_mms_registration_grants" id="ws-plugin--s2member-mms-registration-grants">' . "\n";
             echo '<option value="none"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"] === "none" ? ' selected="selected"' : '') . '>No (do NOT allow Open Registration)</option>' . "\n";
             echo '<option value="user"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"] === "user" ? ' selected="selected"' : '') . '>Yes (allow Open Registration; Free Subscribers at Level #0)</option>' . "\n";
             echo '<option value="all"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"] === "all" ? ' selected="selected"' : '') . '>Yes (allow Open Registration; Free Subscribers, with a free Blog too)</option>' . "\n";
             echo '</select><br />' . "\n";
             echo 'If you set this to <code>Yes</code>, you\'re unlocking <a href="' . esc_attr(c_ws_plugin__s2member_utils_urls::wp_signup_url()) . '" target="_blank" rel="external" onclick="alert(\'s2Member will now open your Multisite Registration Form.\\n* s2Member makes this form available to logged-in Super Administrators, at all times (for testing purposes), regardless of configuration.' . (c_ws_plugin__s2member_utils_conds::bp_is_installed() ? '\\n\\nBuddyPress: * BuddyPress will use its own Registration Form. Please note, you will probably be redirected away from the BuddyPress Registration Form ( ' . c_ws_plugin__s2member_utils_strings::esc_js_sq(c_ws_plugin__s2member_utils_urls::bp_register_url()) . ' ), because you\\\'re ALREADY logged-in. Please log out before testing BuddyPress registration.' : '') . '\');">wp-signup.php</a> (on your Main Site).' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '<table class="form-table ws-plugin--s2member-mms-registration-wp-signup ws-plugin--s2member-mms-registration-wp-signup-blogs-level0">' . "\n";
             echo '<tbody>' . "\n";
             echo '<tr>' . "\n";
             echo '<th>' . "\n";
             echo '<label for="ws-plugin--s2member-mms-registration-blogs-level0">' . "\n";
             echo 'Level #0 (Free Subscribers):' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td style="padding-bottom:0;">' . "\n";
             echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_mms_registration_blogs_level0" id="ws-plugin--s2member-mms-registration-blogs-level0" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level0"]) . '" /><br />' . "\n";
             echo 'How many blogs can a Free Subscriber create?' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '<div class="ws-menu-page-hr ws-plugin--s2member-mms-registration-wp-signup"></div>' . "\n";
             echo '<table class="form-table ws-plugin--s2member-mms-registration-wp-signup" style="margin:0;">' . "\n";
             echo '<tbody>' . "\n";
             for ($n = 1; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) {
                 echo '<tr>' . "\n";
                 echo '<th style="padding-top:0;">' . "\n";
                 echo '<label for="ws-plugin--s2member-mms-registration-blogs-level' . $n . '">' . "\n";
                 echo 'Membership Level #' . $n . ' / Maximum Blogs Allowed:' . "\n";
                 echo '</label>' . "\n";
                 echo '</th>' . "\n";
                 echo '</tr>' . "\n";
                 echo '<tr>' . "\n";
                 echo '<td>' . "\n";
                 echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_mms_registration_blogs_level' . $n . '" id="ws-plugin--s2member-mms-registration-blogs-level' . $n . '" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . $n]) . '" /><br />' . "\n";
                 echo 'How many blogs can a Member ( at Level #' . $n . ' ) create?' . "\n";
                 echo '</td>' . "\n";
                 echo '</tr>' . "\n";
             }
             echo '</tbody>' . "\n";
             echo '</table>' . "\n";
             echo '</div>' . "\n";
             echo '</div>' . "\n";
             do_action("ws_plugin__s2member_during_mms_ops_page_during_left_sections_after_mms_registration", get_defined_vars());
         }
         do_action("ws_plugin__s2member_during_mms_ops_page_after_left_sections", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>' . "\n";
         echo '</form>' . "\n";
     } else {
         echo '<p style="margin-top:0;"><span class="ws-menu-page-hilite">Your WordPress installation does not have Multisite Networking enabled.<br />Which is perfectly OK :-) Multisite Networking is 100% completely optional.</span></p>' . "\n";
         echo '<img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/large-icon.png" title="s2Member (a Membership management system for WordPress)" alt="" style="float:right; margin:0 0 0 25px; border:0;" />' . "\n";
         if (file_exists($ws_plugin__s2member_temp = dirname(dirname(dirname(__FILE__))) . "/readme-ms.txt")) {
             echo '<div class="ws-menu-page-hr"></div>' . "\n";
             if (!function_exists("NC_Markdown")) {
                 include_once dirname(dirname(__FILE__)) . "/externals/markdown/nc-markdown.inc.php";
             }
             $ws_plugin__s2member_temp = file_get_contents($ws_plugin__s2member_temp);
             $ws_plugin__s2member_temp = preg_replace("/(\\=)( )(.+?)( )(\\=)/", "<h3>\$3</h3>", $ws_plugin__s2member_temp);
             $ws_plugin__s2member_temp = NC_Markdown($ws_plugin__s2member_temp);
             echo preg_replace("/(\\<a)( href)/i", "\$1" . ' target="_blank" rel="nofollow external"' . "\$2", $ws_plugin__s2member_temp);
         }
     }
     echo '</td>' . "\n";
     echo '<td class="ws-menu-page-table-r">' . "\n";
     c_ws_plugin__s2member_menu_pages_rs::display();
     echo '</td>' . "\n";
     echo '</tr>' . "\n";
     echo '</tbody>' . "\n";
     echo '</table>' . "\n";
     echo '</div>' . "\n";
 }
 /**
  * Processes List Server removals for s2Member.
  *
  * @package s2Member\List_Servers
  * @since 3.5
  *
  * @param string     $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`.
  * @param int|string $level A numeric s2Member Access Level number.
  * @param string     $login Username for the User.
  * @param string     $pass Plain Text Password for the User.
  * @param string     $email Email address for the User.
  * @param string     $fname First Name for the User.
  * @param string     $lname Last Name for the User.
  * @param string     $ip IP Address for the User.
  * @param bool       $opt_out Defaults to false; must be set to true. Indicates the User IS opting out.
  * @param int|string $user_id A WordPress User ID, numeric string or integer.
  *
  * @return bool True if at least one List Server is processed successfully, else false.
  *
  * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
  * @todo Add a separate option for mail debugging; or consolidate?
  * @todo Integrate AWeber API (much like the MailChimp API).
  */
 public static function process_list_server_removals($role = '', $level = '', $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '', $opt_out = FALSE, $user_id = 0)
 {
     global $current_site, $current_blog;
     // For Multisite support.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_process_list_server_removals', get_defined_vars());
     unset($__refs, $__v);
     if (c_ws_plugin__s2member_list_servers::list_servers_integrated() && ($args = func_get_args()) && $role && is_string($role) && is_numeric($level) && $login && is_string($login) && is_string($pass = (string) $pass) && $email && is_string($email) && is_email($email) && is_string($fname = (string) $fname) && is_string($lname = (string) $lname) && is_string($ip = (string) $ip) && is_bool($opt_out = (bool) $opt_out) && $opt_out && $user_id && is_numeric($user_id) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) {
         $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
         $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
         c_ws_plugin__s2member_email_configs::email_config_release();
         if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_mailchimp_list_ids'])) {
             if (!class_exists('NC_MCAPI')) {
                 // Include the MailChimp API Class here.
                 include_once dirname(dirname(__FILE__)) . '/externals/mailchimp/nc-mcapi.inc.php';
             }
             $mcapi = new NC_MCAPI($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], TRUE);
             foreach (preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_mailchimp_list_ids']) as $mailchimp_list) {
                 $mailchimp = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'listUnsubscribe');
                 if ($mailchimp['list_id'] = trim(preg_replace('/\\:\\:.*$/', '', $mailchimp_list))) {
                     if ($mailchimp['api_removal_response'] = $mcapi->{$mailchimp['api_removal_method']}($mailchimp['list_id'], $email, $mailchimp['api_removal_delete_member'] = apply_filters('ws_plugin__s2member_mailchimp_removal_delete_member', FALSE, get_defined_vars()), $mailchimp['api_removal_send_goodbye'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_goodbye', FALSE, get_defined_vars()), $mailchimp['api_removal_send_notify'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_notify', FALSE, get_defined_vars()))) {
                         $mailchimp['api_removal_success'] = $removal_success = TRUE;
                     }
                     // Flag indicating that we DO have a successful removal; affects the function's overall return value.
                     $mailchimp['api_removal_properties'] = $mcapi;
                     // Include API instance too; as it contains some additional information after each method is processed (need this in the logs).
                     $logt = c_ws_plugin__s2member_utilities::time_details();
                     $logv = c_ws_plugin__s2member_utilities::ver_details();
                     $logm = c_ws_plugin__s2member_utilities::mem_details();
                     $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT'];
                     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                     $log2 = is_multisite() && !is_main_site() ? 'mailchimp-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'mailchimp-api.log';
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) {
                         if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) {
                             if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                                 file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($mailchimp, TRUE)) . "\n\n", FILE_APPEND);
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_getresponse_list_ids'])) {
             foreach (preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_getresponse_list_ids']) as $getresponse_list) {
                 $getresponse = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'delete_contact');
                 if ($getresponse['list_id'] = $getresponse['list'] = trim($getresponse_list)) {
                     $getresponse['api_method'] = 'get_contacts';
                     $getresponse['api_headers'] = array('Content-Type' => 'application/json');
                     $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('campaigns' => array($getresponse['list_id']), 'email' => array('EQUALS' => $email)));
                     $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
                     if (is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && ($getresponse['api_response_contact_ids'] = array_keys((array) $getresponse['api_response']->result)) && ($getresponse['api_response_contact_id'] = $getresponse['api_response_contact_ids'][0])) {
                         $getresponse['api_method'] = 'delete_contact';
                         // Update method now.
                         $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('contact' => $getresponse['api_response_contact_id']));
                         $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE)));
                         if (is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && $getresponse['api_response']->result->deleted) {
                             $getresponse['api_success'] = $success = TRUE;
                         }
                     }
                     $logt = c_ws_plugin__s2member_utilities::time_details();
                     $logv = c_ws_plugin__s2member_utilities::ver_details();
                     $logm = c_ws_plugin__s2member_utilities::mem_details();
                     $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT'];
                     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                     $log2 = is_multisite() && !is_main_site() ? 'getresponse-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'getresponse-api.log';
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) {
                         if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) {
                             if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                                 file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($getresponse, TRUE)) . "\n\n", FILE_APPEND);
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_aweber_list_ids'])) {
             foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_aweber_list_ids']) as $aweber_list) {
                 $aweber = array('function' => __FUNCTION__, 'func_get_args' => $args, 'wp_mail_removal_method' => 'listUnsubscribe');
                 if ($aweber['list_id'] = trim($aweber_list)) {
                     $aweber['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars());
                     c_ws_plugin__s2member_email_configs::email_config();
                     // Email configs MUST be ON for removal requests.
                     // The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
                     if ($aweber['wp_mail_removal_response'] = wp_mail($aweber['list_id'] . '@aweber.com', $aweber['wp_mail_removal_sbj'] = apply_filters('ws_plugin__s2member_aweber_removal_sbj', 'REMOVE#' . $email . '#s2Member#' . $aweber['list_id'], get_defined_vars()), $aweber['wp_mail_removal_msg'] = 'REMOVE', $aweber['wp_mail_removal_headers'] = 'From: "' . preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '" <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>' . ($aweber['removal_bcc'] ? "\r\n" . 'Bcc: ' . $aweber['removal_bcc'] : '') . "\r\n" . 'Content-Type: text/plain; charset=UTF-8')) {
                         $aweber['wp_mail_removal_success'] = $removal_success = TRUE;
                     }
                     // Flag indicating that we DO have a successful removal; affects the function's overall return value.
                     c_ws_plugin__s2member_email_configs::email_config_release();
                     $logt = c_ws_plugin__s2member_utilities::time_details();
                     $logv = c_ws_plugin__s2member_utilities::ver_details();
                     $logm = c_ws_plugin__s2member_utilities::mem_details();
                     $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT'];
                     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                     $log2 = is_multisite() && !is_main_site() ? 'aweber-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'aweber-api.log';
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) {
                         if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) {
                             if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                                 file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($aweber, TRUE)) . "\n\n", FILE_APPEND);
                             }
                         }
                     }
                 }
             }
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_process_list_server_removals', get_defined_vars());
         unset($__refs, $__v);
         if ($email_configs_were_on) {
             c_ws_plugin__s2member_email_configs::email_config();
         }
         if ($user_id) {
             update_user_option($user_id, 's2member_opt_in', '0');
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_after_process_list_server_removals', get_defined_vars());
     unset($__refs, $__v);
     return apply_filters('ws_plugin__s2member_process_list_server_removals', isset($removal_success) && $removal_success, get_defined_vars());
 }
Example #18
0
 /**
  * Redirects to Membership Options Page w/ MOP Vars.
  *
  * Redirection URLs containing array brackets MUST be URL encoded to get through: ``wp_sanitize_redirect()``.
  *   So we pass everything to ``urlencode_deep()``, as an array. It handles this via ``_http_build_query()``.
  *   See bug report here: {@link http://core.trac.wordpress.org/ticket/17052}
  *
  * @package s2Member\Membership_Options_Page
  * @since 111101
  *
  * @param string     $seeking_type Seeking content type. One of: `post|page|catg|ptag|file|ruri`.
  * @param string|int $seeking_type_value Seeking content type data. String, or a Post/Page ID.
  * @param string     $req_type Access requirement type. One of these values: `level|ccap|sp`.
  * @param string|int $req_type_value Access requirement. String, or a Post/Page ID.
  * @param string     $seeking_uri The full URI that access was attempted on.
  * @param string     $res_type Restriction type that's preventing access.
  *   One of: `post|page|catg|ptag|file|ruri|ccap|sp|sys`.
  *   Defaults to ``$seeking_type``.
  *
  * @return bool This function always returns true.
  */
 public static function wp_redirect_w_mop_vars($seeking_type = FALSE, $seeking_type_value = FALSE, $req_type = FALSE, $req_type_value = FALSE, $seeking_uri = FALSE, $res_type = FALSE)
 {
     do_action("ws_plugin__s2member_before_wp_redirect_w_mop_vars", get_defined_vars());
     foreach (array("seeking_type", "seeking_type_value", "req_type", "req_type_value", "seeking_uri", "res_type") as $_param) {
         if ($_param === "seeking_uri" || $_param === "seeking_type_value" && $seeking_type === "ruri") {
             ${$_param} = base64_encode((string) ${$_param});
         } else {
             ${$_param} = str_replace("..", "--", (string) ${$_param});
         }
     }
     unset($_param);
     // Housekeeping.
     if (!$res_type) {
         $res_type = $seeking_type;
     }
     $vars = $res_type . ".." . $req_type . ".." . $req_type_value . "..";
     $vars .= $seeking_type . ".." . $seeking_type_value . ".." . $seeking_uri;
     $vars = array("_s2member_vars" => $vars);
     $status = apply_filters("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars());
     $status = apply_filters("ws_plugin__s2member_wp_redirect_w_mop_vars_status", $status, get_defined_vars());
     $mop_url = get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]);
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page_vars_enable"]) {
         $mop_url = add_query_arg(urlencode_deep($vars), $mop_url);
         $mop_url = c_ws_plugin__s2member_utils_urls::add_s2member_sig($mop_url);
     }
     if (!empty($_GET) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page_ga_vars_enable"]) {
         $ga_vars = array();
         // Initialize.
         foreach (stripslashes_deep($_GET) as $_key => $_value) {
             if (strpos($_key, 'utm_') === 0) {
                 $ga_vars[$_key] = $_value;
             }
         }
         unset($_key, $_value);
         // Housekeeping.
         $mop_url = add_query_arg(urlencode_deep($ga_vars), $mop_url);
     }
     wp_redirect($mop_url, $status);
     // NOTE: we do not exit here (on purpose).
     do_action("ws_plugin__s2member_after_wp_redirect_w_mop_vars", get_defined_vars());
     return TRUE;
     // Always returns true here.
 }
 /**
  * Handles processing of Pro-Forms for Specific Post/Page checkout.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function sp_checkout()
 {
     if (!empty($_POST["s2member_pro_paypal_sp_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-sp-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__s2member_pro_paypal_sp_checkout_response"] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_sp_checkout_response"];
         // This is a shorter reference.
         if (!empty($xco_post_vars)) {
             // A customer is returning from Express Checkout @ PayPal?
             $_POST = $xco_post_vars;
         }
         // POST vars from submission prior to Express Checkout.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_sp_checkout"]));
         $post_vars["attr"] = !empty($post_vars["attr"]) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : array();
         $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_paypal_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars());
         if (!empty($xco_post_vars)) {
             $post_vars["attr"]["captcha"] = "0";
         }
         // No need to revalidate captcha in this case.
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         if (empty($post_vars["card_expiration"]) && isset($post_vars["card_expiration_month"], $post_vars["card_expiration_year"])) {
             $post_vars["card_expiration"] = $post_vars["card_expiration_month"] . "/" . $post_vars["card_expiration_year"];
         }
         $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
         // Collect reCAPTCHA™ post vars.
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])) : null;
         if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__s2member_pro_paypal_utilities::paypal_cost(null, $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 if (empty($_GET["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal" && $cost_calculations["total"] > 0) {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_sp_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_sp_checkout_cancel"), $cancel_url);
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     // Unique invoice w/ IP address too.
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                         $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                         $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                         $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                         $paypal_set_xco["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                         $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                         $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                         $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                         $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                         // Always (1).
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         $paypal_set_xco["EMAIL"] = $post_vars["email"];
                     }
                     if (($paypal_set_xco = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("s2member_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $_POST, 10800);
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         exit;
                         // Clean exit.
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if (empty($post_vars["attr"]["invoice"])) {
                         // Only if it's empty.
                         $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     }
                     if (!($paypal = array())) {
                         if (!empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             // Always (1).
                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         } else {
                             $paypal["METHOD"] = "DoDirectPayment";
                             $paypal["PAYMENTACTION"] = "Sale";
                             $paypal["EMAIL"] = $post_vars["email"];
                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                             $paypal["LASTNAME"] = $post_vars["last_name"];
                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                             $paypal["DESC"] = $cost_calculations["desc"];
                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["INVNUM"] = $post_vars["attr"]["invoice"];
                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                             $paypal["AMT"] = $cost_calculations["total"];
                             $paypal["L_QTY0"] = "1";
                             // Always (1).
                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                             $paypal["CVV2"] = $post_vars["card_verification"];
                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                 } else {
                                     // Otherwise, we assume they provided an Issue Number instead.
                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                 }
                             }
                             $paypal["STREET"] = $post_vars["street"];
                             $paypal["CITY"] = $post_vars["city"];
                             $paypal["STATE"] = $post_vars["state"];
                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                             $paypal["ZIP"] = $post_vars["zip"];
                         }
                     }
                     if ($cost_calculations["total"] <= 0 || ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                         if ($cost_calculations["total"] <= 0) {
                             $new__txn_id = strtoupper('free-' . uniqid());
                         } else {
                             $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                             $new__txn_id = !$new__txn_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__txn_id;
                         }
                         if (!($ipn = array())) {
                             $ipn["txn_type"] = "web_accept";
                             $ipn["txn_id"] = $new__txn_id;
                             $ipn["custom"] = $post_vars["attr"]["custom"];
                             $ipn["invoice"] = $post_vars["attr"]["invoice"];
                             $ipn["mc_gross"] = $cost_calculations["total"];
                             $ipn["mc_currency"] = $cost_calculations["cur"];
                             $ipn["tax"] = $cost_calculations["tax"];
                             $ipn["payer_email"] = $post_vars["email"];
                             $ipn["first_name"] = $post_vars["first_name"];
                             $ipn["last_name"] = $post_vars["last_name"];
                             if (is_user_logged_in() && ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id())) {
                                 $ipn["option_name1"] = "Referencing Customer ID";
                                 $ipn["option_selection1"] = $referencing;
                             } else {
                                 $ipn["option_name1"] = "Originating Domain";
                                 $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                             }
                             $ipn["option_name2"] = "Customer IP Address";
                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                             $ipn["item_name"] = $cost_calculations["desc"];
                             $ipn["item_number"] = $post_vars["attr"]["sp_ids_exp"];
                             $ipn["s2member_paypal_proxy"] = "paypal";
                             $ipn["s2member_paypal_proxy_use"] = "pro-emails";
                             $ipn["s2member_paypal_proxy_coupon"] = array("coupon_code" => $cp_attr["_coupon_code"], "full_coupon_code" => $cp_attr["_full_coupon_code"], "affiliate_id" => $cp_attr["_coupon_affiliate_id"]);
                             $ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                             $ipn["s2member_paypal_proxy_return_url"] = $post_vars["attr"]["success"];
                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                         }
                         if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) {
                             setcookie("s2member_sp_tracking", $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_sp_tracking", $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_sp_tracking);
                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url)));
                             if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         $global_response = array("response" => $paypal["__error"], "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function paypal_checkout()
 {
     if (!empty($_POST["s2member_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["s2member_pro_paypal_checkout"];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($post_vars));
         /* And Filter. */
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__s2member_pro_paypal_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__s2member_pro_paypal_utilities::paypal_cost($cp_2gbp_attr["ta"], $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 $use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
                 $is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
                 /* Selling Independent Custom Capabilities? */
                 /**/
                 if (empty($_GET["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /* No notes. */
                         /**/
                         if ($use_recurring_profile) {
                             $paypal_set_xco["L_BILLINGTYPE0"] = "RecurringPayments";
                             $paypal_set_xco["L_BILLINGAGREEMENTDESCRIPTION0"] = $cost_calculations["desc"];
                             /**/
                             if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                 /**/
                                 $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                 $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                 /**/
                                 if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                     /**/
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                     /* Always (1). */
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                 } else {
                                     $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                     /**/
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                     /* Always (1). */
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                 }
                             }
                         } else {
                             $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         }
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $user ? $user->user_email : $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("s2member_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if ($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (!($cur__subscr_id = get_user_option("s2member_subscr_id")) || !($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                             $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                             /**/
                             if (!($_paypal = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($_paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal_xco_details)) && empty($_paypal_xco_details["__error"])) {
                                     $_paypal["METHOD"] = "DoExpressCheckoutPayment";
                                     /**/
                                     $_paypal["TOKEN"] = $_paypal_xco_details["TOKEN"];
                                     $_paypal["PAYERID"] = $_paypal_xco_details["PAYERID"];
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                     $_paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                 } else {
                                     $_paypal["METHOD"] = "DoDirectPayment";
                                     $_paypal["PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["EMAIL"] = $user->user_email;
                                     $_paypal["FIRSTNAME"] = $post_vars["first_name"];
                                     $_paypal["LASTNAME"] = $post_vars["last_name"];
                                     $_paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $_paypal["DESC"] = $cost_calculations["desc"];
                                     $_paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                     /**/
                                     $_paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $_paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $_paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $_paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $_paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $_paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $_paypal["STREET"] = $post_vars["street"];
                                     $_paypal["CITY"] = $post_vars["city"];
                                     $_paypal["STATE"] = $post_vars["state"];
                                     $_paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $_paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__s2member_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && (!empty($_paypal_xco_details) && empty($_paypal_xco_details["__error"]) && ($paypal_xco_details = $_paypal_xco_details) || ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"]))) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!$_paypal || ($_paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal)) && empty($_paypal["__error"])) {
                                 if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $new__txn_id = $_paypal && !empty($_paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $_paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                     $new__txn_id = !$new__txn_id && $_paypal && !empty($_paypal["TRANSACTIONID"]) ? $_paypal["TRANSACTIONID"] : $new__txn_id;
                                     $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                     $old__subscr_id = get_user_option("s2member_subscr_id");
                                     $new__subscr_id = $paypal["PROFILEID"];
                                     /**/
                                     if (!($ipn = array())) {
                                         $ipn["txn_type"] = "subscr_signup";
                                         $ipn["subscr_id"] = $new__subscr_id;
                                         $ipn["custom"] = $post_vars["attr"]["custom"];
                                         /**/
                                         $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                         /**/
                                         $ipn["period1"] = $period1;
                                         $ipn["period3"] = $period3;
                                         /**/
                                         $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                         $ipn["mc_amount3"] = $cost_calculations["total"];
                                         /**/
                                         $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                         /**/
                                         $ipn["mc_currency"] = $cost_calculations["cur"];
                                         $ipn["tax"] = $cost_calculations["tax"];
                                         /**/
                                         $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                         /**/
                                         $ipn["payer_email"] = $user->user_email;
                                         $ipn["first_name"] = $post_vars["first_name"];
                                         $ipn["last_name"] = $post_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = "Referencing Customer ID";
                                         $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                         /**/
                                         $ipn["option_name2"] = "Customer IP Address";
                                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                         /**/
                                         $ipn["item_name"] = $cost_calculations["desc"];
                                         $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         /**/
                                         $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                         $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                         /* Use as first payment? */
                                         $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         /**/
                                         $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                     }
                                     /**/
                                     if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                         $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                         $paypal["ACTION"] = "Cancel";
                                         /**/
                                         c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                     }
                                     /**/
                                     $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                     /**/
                                     if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 $global_response = array("response" => $_paypal["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         if ($use_recurring_profile && !is_user_logged_in()) {
                             $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             if (!($_paypal = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($_paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal_xco_details)) && empty($_paypal_xco_details["__error"])) {
                                     $_paypal["METHOD"] = "DoExpressCheckoutPayment";
                                     /**/
                                     $_paypal["TOKEN"] = $_paypal_xco_details["TOKEN"];
                                     $_paypal["PAYERID"] = $_paypal_xco_details["PAYERID"];
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                     $_paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                 } else {
                                     $_paypal["METHOD"] = "DoDirectPayment";
                                     $_paypal["PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["EMAIL"] = $post_vars["email"];
                                     $_paypal["FIRSTNAME"] = $post_vars["first_name"];
                                     $_paypal["LASTNAME"] = $post_vars["last_name"];
                                     $_paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $_paypal["DESC"] = $cost_calculations["desc"];
                                     $_paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                     /**/
                                     $_paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $_paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $_paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $_paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $_paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $_paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $_paypal["STREET"] = $post_vars["street"];
                                     $_paypal["CITY"] = $post_vars["city"];
                                     $_paypal["STATE"] = $post_vars["state"];
                                     $_paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $_paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $post_vars["email"];
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__s2member_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && (!empty($_paypal_xco_details) && empty($_paypal_xco_details["__error"]) && ($paypal_xco_details = $_paypal_xco_details) || ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"]))) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!$_paypal || ($_paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal)) && empty($_paypal["__error"])) {
                                 if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $new__txn_id = $_paypal && !empty($_paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $_paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                     $new__txn_id = !$new__txn_id && $_paypal && !empty($_paypal["TRANSACTIONID"]) ? $_paypal["TRANSACTIONID"] : $new__txn_id;
                                     $new__subscr_id = $paypal["PROFILEID"];
                                     /**/
                                     if (!($ipn = array())) {
                                         $ipn["txn_type"] = "subscr_signup";
                                         $ipn["subscr_id"] = $new__subscr_id;
                                         $ipn["custom"] = $post_vars["attr"]["custom"];
                                         /**/
                                         $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                         /**/
                                         $ipn["period1"] = $period1;
                                         $ipn["period3"] = $period3;
                                         /**/
                                         $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                         $ipn["mc_amount3"] = $cost_calculations["total"];
                                         /**/
                                         $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                         /**/
                                         $ipn["mc_currency"] = $cost_calculations["cur"];
                                         $ipn["tax"] = $cost_calculations["tax"];
                                         /**/
                                         $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                         /**/
                                         $ipn["payer_email"] = $post_vars["email"];
                                         $ipn["first_name"] = $post_vars["first_name"];
                                         $ipn["last_name"] = $post_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = "Originating Domain";
                                         $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                         /**/
                                         $ipn["option_name2"] = "Customer IP Address";
                                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                         /**/
                                         $ipn["item_name"] = $cost_calculations["desc"];
                                         $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         /**/
                                         $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                         $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                         /* Use as first payment? */
                                         $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     }
                                     /**/
                                     if (!($create_user = array())) {
                                         $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                         /* Fake this too. */
                                         /**/
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                                 /**/
                                                 if (isset($post_vars["custom_fields"][$field_var])) {
                                                     $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                 }
                                             }
                                         }
                                         /**/
                                         $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("paypal");
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                         /* Fake this too. */
                                         /**/
                                         $create_user["user_login"] = $post_vars["username"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                         $create_user["user_pass"] = wp_generate_password();
                                         /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
                                         $create_user["user_email"] = $post_vars["email"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                     }
                                     /**/
                                     if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     } else {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             update_user_option($new__user_id, "default_password_nag", true, true);
                                             /* Password nag. */
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 $global_response = array("response" => $_paypal["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                                 if ($is_independent_ccaps_sale || !($cur__subscr_id = get_user_option("s2member_subscr_id")) || !($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                                     /**/
                                     if (!($paypal = array())) {
                                         if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $user->user_email;
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $old__subscr_id = get_user_option("s2member_subscr_id");
                                         $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                         $new__subscr_id = $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = $new__txn_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $user->user_email;
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Referencing Customer ID";
                                             $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         }
                                         /**/
                                         if (!$is_independent_ccaps_sale) {
                                             /* Independent? */
                                             if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                                 $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                                 $paypal["ACTION"] = "Cancel";
                                                 /**/
                                                 c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                             }
                                         }
                                         /**/
                                         if ($is_independent_ccaps_sale) {
                                             /* Independent? */
                                             setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
                                         }
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 }
                             } else {
                                 if (!$use_recurring_profile && !is_user_logged_in()) {
                                     if (!($paypal = array())) {
                                         if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $post_vars["email"];
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $new__subscr_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $post_vars["email"];
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Originating Domain";
                                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         }
                                         /**/
                                         if (!($create_user = array())) {
                                             $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                             /* Fake this too. */
                                             /**/
                                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                                     /**/
                                                     if (isset($post_vars["custom_fields"][$field_var])) {
                                                         $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                     }
                                                 }
                                             }
                                             /**/
                                             $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("paypal");
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                             /* Fake this too. */
                                             /**/
                                             $create_user["user_login"] = $post_vars["username"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                             $create_user["user_pass"] = wp_generate_password();
                                             /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
                                             $create_user["user_email"] = $post_vars["email"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                         }
                                         /**/
                                         if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         } else {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 update_user_option($new__user_id, "default_password_nag", true, true);
                                                 /* Password nag. */
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form registrations.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_registration()
 {
     if (!empty($_POST["s2member_pro_paypal_registration"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_registration"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-registration")) {
         $GLOBALS["ws_plugin__s2member_pro_paypal_registration_response"] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_registration_response"];
         // This is a shorter reference.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_registration"]));
         $post_vars["attr"] = !empty($post_vars["attr"]) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : array();
         $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_paypal_registration_post_attr", $post_vars["attr"], get_defined_vars());
         $post_vars["recaptcha_challenge_field"] = isset($_POST["recaptcha_challenge_field"]) ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : "";
         $post_vars["recaptcha_response_field"] = isset($_POST["recaptcha_response_field"]) ? trim(stripslashes($_POST["recaptcha_response_field"])) : "";
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = is_multisite() ? strtolower($post_vars["username"]) : $post_vars["username"];
         // Force lowercase.
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["_o_username"] = $post_vars["username"], is_multisite()));
         if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors("registration", $post_vars))) {
                 if (!($create_user = array())) {
                     $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
                     // Fake this for registration configuration.
                     $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                     // Fake this for registration configuration.
                     $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                     // Fake this for registration configuration.
                     $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                     // Fake this too.
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                             $field_id_class = preg_replace("/_/", "-", $field_var);
                             if (isset($post_vars["custom_fields"][$field_var])) {
                                 $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                             }
                         }
                     }
                     $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_level"] = $post_vars["attr"]["level"];
                     $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_ccaps"] = $post_vars["attr"]["ccaps"];
                     $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"] = $post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"];
                     $_EOT_ =& $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"];
                     // Quick/shorter reference to this var.
                     $_EOT_ = $post_vars["attr"]["tp"] && $post_vars["attr"]["tt"] ? date("Y-m-d H:i:s", c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $_EOT_)) : "";
                     $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_custom"] = $post_vars["attr"]["custom"];
                     unset($_EOT_);
                     // We can unset this shorter/reference variable now.
                     $GLOBALS["ws_plugin__s2member_registration_return_url"] = $post_vars["attr"]["success"];
                     // Custom success return.
                     $create_user["user_login"] = $post_vars["username"];
                     // Copy this into a separate array for `wp_create_user()`.
                     $create_user["user_pass"] = wp_generate_password();
                     // Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
                     $create_user["user_email"] = $post_vars["email"];
                     // Copy this into a separate array for `wp_create_user()`.
                 }
                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", false, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__s2member_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__s2member_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", true, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         $global_response = array("response" => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__s2member_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__s2member_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 public function __construct()
 {
     echo '<div class="wrap ws-menu-page">' . "\n";
     echo '<div class="ws-menu-page-toolbox">' . "\n";
     c_ws_plugin__s2member_menu_pages_tb::display();
     echo '</div>' . "\n";
     echo '<h2>Download Options</h2>' . "\n";
     echo '<table class="ws-menu-page-table">' . "\n";
     echo '<tbody class="ws-menu-page-table-tbody">' . "\n";
     echo '<tr class="ws-menu-page-table-tr">' . "\n";
     echo '<td class="ws-menu-page-table-l">' . "\n";
     echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">' . "\n";
     echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")) . '" />' . "\n";
     echo '<input type="hidden" name="ws_plugin__s2member_amazon_cf_files_distros_auto_config_status" id="ws-plugin--s2member-amazon-cf-files-distros-auto-config-status" value="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_auto_config_status"]) . '" />' . "\n";
     echo '<input type="hidden" name="ws_plugin__s2member_configured" id="ws-plugin--s2member-configured" value="1" />' . "\n";
     do_action("ws_plugin__s2member_during_down_ops_page_before_left_sections", get_defined_vars());
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_restrictions", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_restrictions", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Basic Download Restrictions">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-restrictions-section">' . "\n";
         echo '<h3>File Download Restrictions (required, if providing access to protected files)</h3>' . "\n";
         echo '<p>If your Membership offering allows access to restricted files, you\'ll want to configure these options.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_restrictions", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><strong>Upload restricted files to this security-enabled directory:</strong><br /><code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '</code></p>' . "\n";
         echo '<p>- Now, you can link to any protected file, using this special format:<br />&nbsp;&nbsp;<code>' . esc_html(site_url("/?s2member_file_download=example-file.zip")) . '</code><br />&nbsp;&nbsp;<small><em><strong>s2member_file_download</strong> = file, relative to the /' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/ directory. In other words, just the file name.</em></small></p>' . "\n";
         echo '<p>- Or, use: <code>[s2File download="example-file.zip" /]</code> <em>(easier Shortcode if you prefer)</em><br />&nbsp;&nbsp;<small><em><strong>Shortcode equivalent:</strong> <code>[s2File /]</code> produces the entire URL for you, easier.</em></small></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p>s2Member will allow access to these protected files, based on the configuration you specify below. Repeated downloads of the same exact file are NOT tabulated against the totals below. Once a file has been downloaded, future downloads of the same exact file, by the same exact Member will not be counted against them. In other words, if a Member downloads the same file three times, the system only counts that as one unique download. In addition, multiple variations of popular media formats are only counted once. This is because many site owners provide multiple download options to their Users/Members, for compatibility purposes. Files that have the same exact name, with one of these extensions, will only be counted ONE time: <code>' . esc_html(implode(",", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["streaming_file_extns"])) . '</code>.</p>' . "\n";
         echo '<p>s2Member will automatically detect links, anywhere in your content, and/or anywhere in your theme files, that contain <code>s2member_file_download</code> or <code>s2member-files</code>. Whenever a logged-in Member clicks a link that contains <code>s2member_file_download</code> or <code>s2member-files</code>, the system will politely ask the user to confirm the download using a very intuitive JavaScript confirmation prompt, which contains specific details about your configured download limitations. This way your Members will be aware of how many files they\'ve downloaded in the current period; and they\'ll be able to make a conscious decision about whether to proceed with a specific download or not. If you want to suppress this JavaScript confirmation prompt, you can add this to the end of your links: <code>&amp;s2member_skip_confirmation</code>. Shortcode alternative: <code>[s2File skip_confirmation="yes" /]</code>.</p>' . "\n";
         echo '<p><em>* The above only applies to Users who are logged in as Members. For all other visitors in the general public, the <code>?s2member_file_download</code> links will redirect them your Membership Options Page, so that new visitors can signup, in order to gain access, by becoming a Member. You may also want to have a look down below at s2Member\'s "Advanced Download Restrictions", which provides a greater degree of flexibility.</em></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) {
             echo '<tr>' . "\n";
             echo '<th style="padding-top:0;">' . "\n";
             echo '<label for="ws-plugin--s2member-level' . $n . '-file-downloads-allowed">' . "\n";
             echo $n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] ? 'File Downloads ( Highest Level #' . $n . ' ):' . "\n" : 'File Downloads (Level #' . $n . ' Or Higher):' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             echo '<input type="text" maxlength="9" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_file_downloads_allowed" id="ws-plugin--s2member-level' . $n . '-file-downloads-allowed" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"]) . '" style="width:200px;" /> every <input type="text" maxlength="3" autocomplete="off" name="ws_plugin__s2member_level' . $n . '_file_downloads_allowed_days" id="ws-plugin--s2member-level' . $n . '-file-downloads-allowed-days" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]) . '" style="width:200px;" onkeyup="if(this.value > 365){ alert(\'(365 days is the maximum).\\nThis keeps the logs optimized.\'); this.value = 365; }" /> day(s).<br />' . "\n";
             echo 'Only this many unique downloads will be permitted every X day(s), at ' . ($n === $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] ? 'highest Level #' . $n : 'Level #' . $n . ' or higher') . '.<br />' . "\n";
             echo '<em>* To allow UNLIMITED downloads, use: <code>999999999</code> (i.e. <code>999999999</code> = unlimited).</em>' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo $n < $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] ? '<tr><td><div class="ws-menu-page-hr" style="margin:10px 0 10px 0;"></div></td></tr>' : '';
         }
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_restrictions", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_limit_exceeded_page", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_limit_exceeded_page", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Download Limit Exceeded Page">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-limit-exceeded-page-section">' . "\n";
         echo '<h3>Download Limit Exceeded Page (required, if providing access to protected files)</h3>' . "\n";
         echo '<p>This Page will be shown when/if a Member reaches their download limit, based on your configuration of <strong>Basic Download Restrictions</strong> above. This Page should be created by you, in WordPress. This Page should provide an informative message to the Member, describing your file access restrictions. Just tell them a little bit about your policy on file downloads, and why they might have reached this Page.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_limit_exceeded_page", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-file-download-limit-exceeded-page">' . "\n";
         echo 'Download Limit Exceeded Page:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_file_download_limit_exceeded_page" id="ws-plugin--s2member-file-download-limit-exceeded-page">' . "\n";
         echo '<option value="">&mdash; Select &mdash;</option>' . "\n";
         foreach ($ws_plugin__s2member_temp_a = array_merge((array) get_pages()) as $ws_plugin__s2member_temp_o) {
             echo '<option value="' . esc_attr($ws_plugin__s2member_temp_o->ID) . '"' . ($ws_plugin__s2member_temp_o->ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] ? ' selected="selected"' : '') . '>' . esc_html($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
         }
         echo '</select><br />' . "\n";
         echo 'We recommend the following title: <code>Download Limit Exceeded</code>.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_limit_exceeded_page", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_advanced_restrictions", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_advanced_restrictions", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Advanced Download Restrictions">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-restrictions-section">' . "\n";
         echo '<h3>Advanced Download Restrictions (optional, for greater flexibility)</h3>' . "\n";
         echo '<p>By default, s2Member uses your Basic Download Restrictions, as configured above. However, you can force s2Member to allow File Downloads, using an extra query string parameter: <code>&amp;s2member_file_download_key=[Key]</code>. A File Download `Key` is passed through this parameter; it tells s2Member to allow the download of this particular file, regardless of Membership Level; and WITHOUT checking any Basic Restrictions, that you may or may not have configured above. The creation of a File Download `Key`, requires a small PHP code snippet. In order to use PHP scripting inside your Posts/Pages, you\'ll need to install this handy plugin (<a href="http://wordpress.org/extend/plugins/ezphp/" target="_blank" rel="external">ezPHP</a>). There is also a Shortcode equivalent, which does NOT require PHP at all, as seen below.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_advanced_restrictions", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p>' . esc_html(site_url("/?s2member_file_download=example-file.zip")) . '<code>&amp;s2member_file_download_key=&lt;?php echo s2member_file_download_key("example-file.zip"); ?&gt;</code><br />&nbsp;&nbsp;<small><em><strong>s2member_file_download_key</strong> = &lt;?php echo s2member_file_download_key("file, relative to the /' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/ directory"); ?&gt;</em></small></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p>' . esc_html(site_url("/?s2member_file_download=example-file.zip")) . '<code>&amp;s2member_file_download_key=[s2Key file_download="example-file.zip" /]</code><br />&nbsp;&nbsp;<small><em><strong>Shortcode equivalent:</strong> <code>[s2Key file_download="example-file.zip" /]</code></em></small></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><code>[s2File download="example-file.zip" download_key="true" /]</code> <em>(Key is auto-generated in this case)</em><br />&nbsp;&nbsp;<small><em><strong>Shortcode equivalent:</strong> <code>[s2File /]</code> produces the entire URL, no need to generate a Key yourself.</em></small></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p>The function <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_file_download_key()" target="_blank" rel="external">s2member_file_download_key()</a>, is part of the s2Member API. It produces a time-sensitive File Download Key that is unique to each and every visitor. Each Key it produces <em>(at the time it is produced)</em>, will be valid for the current day, and only for a specific IP address and User-Agent string; as detected by s2Member. This makes it possible for you to create links on your site, which provide access to protected file downloads; and without having to worry about one visitor sharing their link with another. So let\'s take a quick look at what <code>s2member_file_download_key()</code> actually produces.</p>' . "\n";
         echo '<p><code>s2member_file_download_key("example-file.zip")</code> = a site-specific hash of: <code>date("Y-m-d").$_SERVER["REMOTE_ADDR"].$_SERVER["HTTP_USER_AGENT"].$file</code></p>' . "\n";
         echo '<p>When <code>s2member_file_download_key = <em>a valid Key</em></code>, it works independently from Member Level Access. That is, a visitor does NOT have to be logged in to receive access; they just need a valid Key. Using this advanced technique, you could extend s2Member\'s file protection routines, or even combine them with Specific Post/Page Access, and more. The possibilities are limitless really.</p>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_advanced_restrictions", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_inline_extensions", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_inline_extensions", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Inline File Extensions">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-inline-extensions-section">' . "\n";
         echo '<h3>Inline File Extensions (optional, for content-disposition)</h3>' . "\n";
         echo '<p>There are two ways to serve files. Inline, or as an Attachment. By default, s2Member will serve all of your protected files, as downloadable attachments. Meaning, visitors will be given a file download prompt. Otherwise known as <code>Content-Disposition: attachment</code>. In some cases though, you may wish to serve files inline. For example, PDF files and images should usually be served inline. When you serve a file inline, it is displayed in your browser immediately, rather than your browser prompting you to download the file as an attachment.</p>' . "\n";
         echo '<p>Using the field below, you can list all of the extensions that you want s2Member to serve inline (ex: <code>htm,html,pdf,jpg,jpeg,jpe,gif,png,mp3,mp4,flv,ogg,webm</code>). Please understand, some files just cannot be displayed inline. For instance, there is no way to display an <code>exe</code> file inline. So only specify extensions that can, and should be displayed inline by a web browser. Alternatively, if you would rather handle this on a case-by-case basis, you can simply add the following to the end of your download links: <code>&amp;s2member_file_inline=yes</code>. Shortcode alternative: <code>[s2File download="example-file.zip" inline="yes" /]</code>.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_inline_extensions", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-file-download-inline-extensions">' . "\n";
         echo 'Default Inline File Extensions (comma-delimited):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_file_download_inline_extensions" id="ws-plugin--s2member-file-download-inline-extensions" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]) . '" /><br />' . "\n";
         echo 'Inline extensions, comma-delimited. Ex: <code>htm,html,pdf,jpg,jpeg,jpe,gif,png,mp3,mp4,flv,ogg,webm</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_inline_extensions", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_remote_authorization", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_remote_authorization", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Remote Auth / Podcasting">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-remote-authorization-section">' . "\n";
         echo '<h3>Remote Header Authorization (optional)</h3>' . "\n";
         echo '<p>This can be enabled on a case-by-case basis. Just add this to the end of your download links: <code>&amp;s2member_file_remote=yes</code>. Shortcode alternative: <code>[s2File download="example-file.zip" remote="yes" /]</code>.</p>' . "\n";
         echo '<p>Remote Header Authorization allows access to file downloads through an entirely different approach. Instead of asking the Member to log into your site through a browser, a Member will be prompted automatically, to log in through HTTP Header Authorization prompts; which is the same technique used in more traditional security systems via .htaccess files. In other words, Remote Header Authorization makes it possible for your Members to access files through remote applications that may NOT use a browser. This is often the case when a Member needs to access protected files through a software client like iTunes; typical with podcasts. See <a href="http://www.s2member.com/videos/71F49478D6983A9C/" target="_blank" rel="external">tutorial video here</a> for details about how to setup a Podcast for iTunes.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_remote_authorization", get_defined_vars());
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_remote_authorization", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_amazon_s3", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_amazon_s3", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Amazon S3/CDN Storage Option"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) ? ' default-state="open"' : '') . '>' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-amazon-s3-section">' . "\n";
         echo '<h3>Amazon S3/CDN Storage &amp; Delivery (optional)</h3>' . "\n";
         echo '<a href="http://aws.amazon.com/s3/" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/amazon-logo.png" class="ws-menu-page-right" style="width:250px; height:100px; border:0;" alt="." /></a>' . "\n";
         echo '<p>Please note, all of this is optional. s2Member can be configured here to ONLY use Amazon S3 <em>(i.e. without Amazon CloudFront)</em>. Or, s2Member can be configured to use BOTH Amazon S3 and Amazon CloudFront together. If you want to use Amazon S3 Storage, but you don\'t care about Amazon CloudFront, feel free to leave the entire Amazon CloudFront section empty. The configuration options in the Amazon CloudFront section are ONLY required if you are planning to use both Amazon S3 and Amazon CloudFront together.</p>' . "\n";
         echo '<p>Amazon Simple Storage Service (<a href="http://aws.amazon.com/s3/" target="_blank" rel="external">Amazon S3</a>). Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers. Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives developers access to the same highly scalable, reliable, secure, fast, inexpensive infrastructure that Amazon uses to run its own global network of web sites. s2Member has been integrated with Amazon S3, so that <em>(if you wish)</em>, instead of using the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory, you can store all of your protected files inside an Amazon S3 Bucket.</p>' . "\n";
         echo '<p>If you configure the options below, s2Member will assume all protected files are inside your Amazon S3 Bucket; and the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory is no longer used at all. That being said, all other aspects of s2Member\'s File Download protection remain the same. The only thing that changes, is the location of your protected files. In other words, Basic Download Restrictions, Download Keys, Inline Extensions, Custom Capability and/or Membership Level Files will all continue to work just as before. The only difference is that s2Member will use your Amazon S3 Bucket as a CDN <em>(i.e. Content Delivery Network)</em> instead of the local <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory.</p>' . "\n";
         echo '<p>s2Member assumes that you\'re creating a new Amazon S3 Bucket, specifically for this installation; and that your Bucket is NOT available publicly. In other words, if you type this URL into your browser <em>(i.e. <code>http://your-bucket-name.s3.amazonaws.com/</code>)</em>, you should get an error that says: <code>Access Denied</code>. That\'s good, that\'s exactly what you want. You can create your Amazon S3 Bucket using the <a href="https://console.aws.amazon.com/s3/home" target="_blank" rel="external">Amazon interface</a>. Or, some people prefer to use this popular Firefox extension (<a href="http://www.s3fox.net/" target="_blank" rel="external">S3 Fox Organizer</a>).</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_amazon_s3", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><em><strong>Dev Note w/Technical Details:</strong> s2Member uses "Digitally Signed URLs", authenticated by the Amazon S3 API. Documented for developers <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html" target="_blank" rel="external">here</a>. To put it simply, s2Member will generate Amazon S3 URLs (internally); which allow Customers temporary access to specific files inside your S3 Bucket. s2Member\'s Digitally Signed URLs leading to Amazon S3, give a Customer 24 hours to connect to the file inside your S3 Bucket. This connection period of 24 hours is largely irrelevant when used in combination with s2Member, because access is renewed for another 24 hours each time you make a file available to a User/Member, and they are authenticated by your configuration of s2Member. This connection period of 24 hours is just a secondary line of defense to further prevent the possibility of link sharing. If you need to change this connection timeout of <code>24 hours</code> for some reason (not likely), you can use this WordPress Filter: <code>ws_plugin__s2member_amazon_s3_file_expires_time</code>.</em></p>' . "\n";
         echo '<p><em><strong>Linking To Protected Files:</strong> Nothing changes. s2Member\'s integration with Amazon S3 serves protected files through the same links that all s2Member site owners use. For example, you might use: <code>' . esc_html(site_url("/?s2member_file_download=example-file.zip")) . '</code>, where <strong>s2member_file_download</strong> = the file, relative to the root of your Amazon S3 Bucket. In other words, just the file name in most cases. s2Member will redirect Users/Members to a digitally signed Amazon S3 URL, which allows them access to a particular file via Amazon S3. For further details, please review this section of your Dashboard: <code>s2Member -› Download Options -› Basic Download Restrictions</code>. Also see: <code>s2Member -› Download Options -› Advanced Mod-Rewrite Linkage</code>.</em></p>' . "\n";
         echo '<p><em><strong>Content Type, Disposition &amp; Inline Files:</strong> The query string parameter <code>&amp;s2member_file_inline=yes</code> DOES work for files served directly through Amazon S3. s2Member DOES have control over the <code>Content-Type</code> and <code>Content-Disposition</code> headers for files being served through Amazon S3. However, Amazon CloudFront servers do NOT automatically determine the MIME type for the objects they serve. If you integrate both Amazon S3 and CloudFront, s2Member will NOT have control over headers. Therefore, when you upload a file to your Amazon S3 Bucket, you should set its Content-Type header. Again, with the Amazon S3/CloudFront combination, you MUST configure headers yourself (such as <code>Content-Type: video/webm</code>, or <code>Content-Disposition: inline|attachment</code>) that you want Amazon CloudFront to send for a particular file. It\'s quite easy. You do this by setting <code>Properties -› Metadata (i.e. headers)</code> on a per-file basis, from inside your Amazon S3 Management Console. In short, when you upload a file to your Amazon S3 Bucket, if you want that file to be served a certain way, be sure to configure its <code>Properties -› Metadata</code> accordingly.</em></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th style="padding-top:0;">' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-s3-files-bucket">' . "\n";
         echo 'Amazon S3 File Bucket Name (where protected files are):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_s3_files_bucket" id="ws-plugin--s2member-amazon-s3-files-bucket" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"]) . '" /><br />' . "\n";
         echo 'Your Amazon S3 Bucket will be used, instead of the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory.<br />' . "\n";
         echo 'Please type the name of your Bucket. Ex: <code>mys3bucket</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-s3-files-access-key">' . "\n";
         echo 'Amazon Access Key (Access Key ID):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_amazon_s3_files_access_key" id="ws-plugin--s2member-amazon-s3-files-access-key" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"]) . '" /><br />' . "\n";
         echo 'See: <code>Amazon Web Services Account -› Security Credentials -› Access Keys</code>.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-s3-files-secret-key">' . "\n";
         echo 'Amazon Secret Key (Secret Access Key):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_amazon_s3_files_secret_key" id="ws-plugin--s2member-amazon-s3-files-secret-key" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"]) . '" /><br />' . "\n";
         echo 'See: <code>Amazon Web Services Account -› Security Credentials -› Access Keys (leading to: Legacy Security Credentials)</code>.<br />' . "\n";
         echo 'Amazon is deprecating Secret Access Keys, but they ARE still required for digitally signed URLs.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_amazon_s3", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_amazon_cf", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_amazon_cf", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Amazon S3/CloudFront CDN Storage Option"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) ? ' default-state="open"' : '') . '>' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-amazon-cf-section">' . "\n";
         echo '<h3>Amazon S3/CloudFront CDN Storage &amp; Delivery (optional)</h3>' . "\n";
         echo '<a href="http://aws.amazon.com/cloudfront/" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/amazon-logo.png" class="ws-menu-page-right" style="width:250px; height:100px; border:0;" alt="." /></a>' . "\n";
         echo '<p>Please note, all of this is optional. s2Member can be configured to ONLY use Amazon S3 <em>(i.e. without Amazon CloudFront)</em>. Or, s2Member can be configured to use BOTH Amazon S3 and Amazon CloudFront together. If you don\'t want to use Amazon CloudFront, please leave this entire section empty. The configuration options in this section are ONLY required if you are planning to use both Amazon S3 and Amazon CloudFront together.</p>' . "\n";
         echo '<p>Amazon Simple Storage Service (<a href="http://aws.amazon.com/s3/" target="_blank" rel="external">Amazon S3</a>) combined with <a href="http://aws.amazon.com/cloudfront/" target="_blank" rel="external">Amazon CloudFront</a>. Amazon CloudFront is a web service for content delivery. It integrates with other Amazon Web Services <em>(i.e. Amazon S3 Storage)</em> to give developers and businesses an easy way to distribute content to end users with low latency, and with high data transfer speeds. Amazon CloudFront delivers your static and streaming content using a global network of edge locations. Requests for your Amazon S3 Bucket Objects <em>(i.e. your protected files)</em> are automatically routed to the nearest edge location, so content is delivered with the best possible performance. s2Member has been integrated with both Amazon S3 and with Amazon CloudFront. So <em>(if you wish)</em>, instead of using the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory, you can store all of your protected files inside an Amazon S3 Bucket and serve them via Amazon CloudFront. But again, please understand, the configuration options in this section are ONLY required if you\'re going to use both Amazon S3 &amp; CloudFront together.</p>' . "\n";
         echo '<p><strong>One of the great things about Amazon CloudFront</strong>, is its ability to <strong>stream/seek media files</strong> in the truest sense of the word. For sites delivering protected <em>FLV/MP4/OGG/WEBM</em> and other streaming audio/video file types over the <em>RTMP</em> protocol, Amazon CloudFront is our recommendation. Once you\'ve successfully configured s2Member to use both Amazon S3 and Amazon CloudFront together, please review the section below regarding <code>JW Player &amp; RTMP Protocol Examples</code>. s2Member will automatically serve your protected files over the <em>RTMP</em> protocol using an Amazon CloudFront Streaming Distribution.</p>' . "\n";
         echo '<p>If you configure the options below, s2Member will assume all protected files are inside your Amazon S3 Bucket; and the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory is no longer used at all. That being said, all other aspects of s2Member\'s File Download protection remain the same. The only thing that changes, is the location of your protected files. In other words, Basic Download Restrictions, Download Keys, Custom Capability and/or Membership Level Files will all continue to work just as before. The only difference is that s2Member will use your Amazon S3 Bucket, automatically connecting it to both of the Amazon CloudFront Distributions, which s2Member auto-configures for you <em>(see below)</em>. In this way, s2Member uses Amazon CloudFront as a CDN <em>(i.e. Content Delivery Network)</em> for your protected files.</p>' . "\n";
         echo '<p>s2Member assumes that you\'re creating a new Amazon S3 Bucket, specifically for this installation; and that your Bucket is NOT available publicly. In other words, if you type this URL into your browser <em>(i.e. <code>http://your-bucket-name.s3.amazonaws.com/</code>)</em>, you should get an error that says: <code>Access Denied</code>. That\'s good, that\'s exactly what you want. You can create your Amazon S3 Bucket using the <a href="https://console.aws.amazon.com/s3/home" target="_blank" rel="external">Amazon interface</a>. Or, some people prefer to use this popular Firefox extension (<a href="http://www.s3fox.net/" target="_blank" rel="external">S3 Fox Organizer</a>). You will also need to enable CloudFront inside your Web Services account at Amazon. Don\'t worry about creating or configuring any CloudFront Distributions, s2Member will auto-create and auto-configure those for you, allowing you to serve protected files.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_amazon_cf", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><em><strong>Dev Note w/Technical Details:</strong> s2Member\'s auto-configuration routines for Amazon CloudFront (below), are designed to create &amp; configure various components on your Amazon Web Services account, which are all requirements for you to <a href="http://docs.amazonwebservices.com/AmazonCloudFront/2010-11-01/DeveloperGuide/index.html?HowToPrivateContent.html" target="_blank" rel="external">serve protected files through the Amazon S3/CloudFront combination</a>. These components include: an Origin Access Identity, read permissions for the Origin Access Identity, and two private content Distributions. One private content Distribution for file downloads, and another private content Distribution for streaming media files; both connected to and sourced by your Amazon S3 Bucket. In addition, s2Member will automatically configure an ACL &amp; Policy (i.e. permissions) on your Amazon S3 Bucket to make sure your protected object/files are NOT available to the public.</em></p>' . "\n";
         echo '<p><em><strong>Dev Note w/Technical Details:</strong> s2Member uses "Digitally Signed URLs", authenticated by the Amazon CloudFront API. Documented for developers <a href="http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html" target="_blank" rel="external">here</a>. To put it simply, s2Member will generate Amazon CloudFront URLs (internally); which allow Customers temporary access to specific files inside your S3 Bucket — via CloudFront Distributions. s2Member\'s Digitally Signed URLs leading to Amazon S3/CloudFront, give a Customer 24 hours to connect to the file inside your S3 Bucket. This connection period of 24 hours is largely irrelevant when used in combination with s2Member, because access is renewed for another 24 hours each time you make a file available to a User/Member, and they are authenticated by your configuration of s2Member. This connection period of 24 hours is just a secondary line of defense to further prevent the possibility of link sharing. If you need to change this connection timeout of <code>24 hours</code> for some reason (not likely), you can use this WordPress Filter: <code>ws_plugin__s2member_amazon_cf_file_expires_time</code>.</em></p>' . "\n";
         echo '<p><em><strong>Linking To Protected Files:</strong> RTMP streams are special, but nothing else changes. s2Member\'s integration with Amazon S3/CloudFront serves protected files through the same links that all s2Member site owners use. For example, you might use: <code>' . esc_html(site_url("/?s2member_file_download=example-file.zip")) . '</code>, where <strong>s2member_file_download</strong> = the file, relative to the root of your Amazon S3 Bucket. In other words, just the file name in most cases. s2Member will redirect Users/Members to a digitally signed Amazon CloudFront URL, which allows them access to a particular file via Amazon CloudFront. For further details, please review this section of your Dashboard: <code>s2Member -› Download Options -› Basic Download Restrictions</code>. Also see: <code>s2Member -› Download Options -› Advanced Mod-Rewrite Linkage</code>. If you\'re streaming audio/video files over the RTMP protocol, please review the section below: <code>JW Player &amp; RTMP Protocol Examples</code>.</em></p>' . "\n";
         echo '<p><em><strong>Content Type, Disposition &amp; Inline Files:</strong> An IMPORTANT issue. The query string parameter <code>&amp;s2member_file_inline=yes</code> does NOTHING for files served via Amazon CloudFront. s2Member has NO control over the <code>Content-Type</code> and/or <code>Content-Disposition</code> headers for a file being served through Amazon CloudFront, and CloudFront servers do NOT automatically determine the MIME type for the objects they serve. Therefore, when you upload a file to your Amazon S3 Bucket, you should set its Content-Type header. That is, you MUST configure headers yourself (such as <code>Content-Type: video/webm</code>, or <code>Content-Disposition: inline|attachment</code>) that you want Amazon CloudFront to send for a particular file. It\'s quite easy. You do this by setting <code>Properties -› Metadata (i.e. headers)</code> on a per-file basis, from inside your Amazon S3 Management Console. In short, when you upload a file to your Amazon S3 Bucket, if you want that file to be served a certain way, be sure to configure its <code>Properties -› Metadata</code> accordingly.</em></p>' . "\n";
         echo stripos(PHP_OS, "win") === 0 && c_ws_plugin__s2member_utils_conds::is_localhost() ? '<p><em><strong>Localhost Developers:</strong> s2Member\'s Amazon CloudFront integration requires the <a href="http://php.net/manual/en/function.openssl-sign.php" target="_blank" rel="external">openssl_sign()</a> function in PHP so it can digitially sign CloudFront URLs. This function is sometimes problematic on localhost servers such as WAMP &amp; EasyPHP. We recommend installing <a href="http://www.slproweb.com/products/Win32OpenSSL.html" target="_blank" rel="external">this lightweight alternative for Windows</a> while you\'re developing. s2Member will automatically find it here: <code>C:\\OpenSSL-Win[32/64]\\bin\\openssl.exe</code>.' . (file_exists("c:\\openssl-win32\\bin\\openssl.exe") || file_exists("c:\\openssl-win64\\bin\\openssl.exe") ? ' <strong class="ws-menu-page-hilite">( s2Member has detected that OpenSSL-Win[32/64] IS installed in the correct location, thank you! )</strong>' : ' <strong class="ws-menu-page-hilite">(s2Member has detected that OpenSSL-Win[32/64] is NOT currently available)</strong>') . '</em></p>' . "\n" : '';
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_auto_config_status"] === "configured") {
             echo '<p><em class="ws-menu-page-hilite"><strong>Your Amazon CloudFront Distributions are: ( ALREADY configured! )</strong></em>' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"] ? '<br /><em class="ws-menu-page-hilite">Downloads Distribution CNAME:</em> <em><code>' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]) . ' &mdash;&raquo; ' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_dname"]) . '</code></em>' : '') . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"] ? '<br /><em class="ws-menu-page-hilite">Streaming Distribution CNAME:</em> <em><code>' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) . ' &mdash;&raquo; ' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_dname"]) . '</code></em>' : '') . '</p>' . "\n";
         } else {
             if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distros_auto_config_status"]) {
                 echo '<p><em class="ws-menu-page-hilite"><strong>Your Amazon CloudFront Distributions are: (NOT yet auto-configured).</strong></em></p>' . "\n";
             }
         }
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th style="padding-top:0;">' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-cf-files-private-key-id">' . "\n";
         echo 'Amazon CloudFront Key Pair ID (your Key Pair ID):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_cf_files_private_key_id" id="ws-plugin--s2member-amazon-cf-files-private-key-id" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key_id"]) . '" data-s-prev-config-value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key_id"]) . '" /><br />' . "\n";
         echo 'See: <code>Amazon Web Services Account -› Security Credentials -› Key Pairs</code>.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-cf-files-private-key-entry">' . "\n";
         echo 'Amazon CloudFront Private Key (contents of your <code>pk-[***].pem</code> file):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="hidden" name="ws_plugin__s2member_amazon_cf_files_private_key" id="ws-plugin--s2member-amazon-cf-files-private-key" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"]) . '" data-s-prev-config-value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"]) . '" />' . "\n";
         echo '<textarea name="ws_plugin__s2member_amazon_cf_files_private_key_entry" id="ws-plugin--s2member-amazon-cf-files-private-key-entry" rows="3" wrap="off" spellcheck="false" class="monospace">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_private_key"]) . '</textarea><br />' . "\n";
         echo 'See: <code>Amazon Web Services Account -› Security Credentials -› Key Pairs</code>.<br />' . "\n";
         echo '<em>* Note, s2Member needs your <strong>Private Key file</strong>, NOT your Public Key file.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros">' . "\n";
         echo 'Auto-Configure your Amazon S3/CloudFront combination?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="checkbox" name="ws_plugin__s2member_amazon_cf_files_auto_configure_distros" id="ws-plugin--s2member-amazon-cf-files-auto-configure-distros" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-amazon-cf-files-auto-configure-distros")) . '"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros"><strong>Yes</strong>, automatically configure my Amazon CloudFront Distributions &amp; Amazon S3 ACLs for me.</label><br />' . "\n";
         echo '<em>s2Member will auto-configure and/or delete &amp; re-configure your Amazon CloudFront Distributions for you.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="checkbox" name="ws_plugin__s2member_amazon_cf_files_auto_configure_distros_w_cnames" id="ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames")) . '"' . (!empty(c_ws_plugin__s2member_menu_pages::$pre_display_errors["cf_files_auto_configure_distros"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames"><strong>Yes</strong>, I want s2Member to auto-configure using custom CNAMES that I\'ll setup.</label><br />' . "\n";
         echo '<em>* Optional, do NOT check this box unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div id="ws-plugin--s2member-amazon-cf-files-auto-configure-distro-cnames" style="display:none;">' . "\n";
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-cf-files-downloads-distro-cname">' . "\n";
         echo 'Amazon CloudFront CNAME for File Downloads (optional):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_cf_files_distro_downloads_cname" id="ws-plugin--s2member-amazon-cf-files-downloads-distro-cname" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_downloads_cname"]) . '" /><br />' . "\n";
         echo 'Example: <code>s2-file-downloads.' . esc_html(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) . '</code>.<br />' . "\n";
         echo '<em>* Optional, do NOT fill this in unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-amazon-cf-files-streaming-distro-cname">' . "\n";
         echo 'Amazon CloudFront CNAME for Streaming Files (optional):' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_amazon_cf_files_distro_streaming_cname" id="ws-plugin--s2member-amazon-cf-files-streaming-distro-cname" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_cf_files_distro_streaming_cname"]) . '" /><br />' . "\n";
         echo 'Example: <code>s2-streaming-files.' . esc_html(c_ws_plugin__s2member_utils_urls::parse_url(site_url(), PHP_URL_HOST)) . '</code>.<br />' . "\n";
         echo '<em>* Optional, do NOT fill this in unless you know what you\'re doing. This requires DNS changes.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_amazon_cf", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_rtmp_streaming", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_rtmp_streaming", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="JW Player v6 &amp; RTMP Protocol Examples">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-rtmp-streaming-section">' . "\n";
         echo '<h3>JW Player v6 &amp; RTMP Protocol Examples</h3>' . "\n";
         echo '<a href="http://www.longtailvideo.com/players/" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/jwplayer-logo.png" class="ws-menu-page-right" style="width:179px; height:58px; border:0; border-radius:3px; background:#FFFFFF; padding:15px;" alt="." /></a>' . "\n";
         echo '<p>While it is possible to serve audio/video files protected by s2Member, without needing to integrate Amazon S3 or CloudFront; we DO highly recommend that you integrate both Amazon S3 and Amazon CloudFront in order to maximize speed and compatibility across various viewing platforms. That being said, there are code samples below that will serve audio/video files both with and without Amazon S3/CloudFront. You can also check the <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value("Forum URI")) . '" target="_blank" rel="external">s2Member Support Forums</a> for tips/tricks if you like.</p>' . "\n";
         echo '<p><strong>One of the great things about Amazon CloudFront</strong>, is its ability to <strong>stream/seek media files</strong> in the truest sense of the word. For sites delivering protected <em>FLV/MP4/OGG/WEBM</em> and other streaming audio/video file types over the <em>RTMP</em> protocol, Amazon CloudFront is our recommendation. Once you\'ve successfully configured s2Member to use both Amazon S3 and Amazon CloudFront together, please review the code samples below. s2Member can automatically serve your protected files over the <em>RTMP</em> protocol using an Amazon CloudFront Streaming Distribution.</p>' . "\n";
         echo '<p><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/jwplayer-s2stream-shortcodes/" target="_blank" rel="external">JW Player w/ <code>[s2Stream /]</code> Shortcodes</a>.</p>' . "\n";
         if (stripos(wp_get_theme(), 'infocus') !== FALSE) {
             echo '<p><strong>Note:</strong> It appears that you\'re using the inFocus WordPress theme. If you experience trouble with the shortcodes below, try wrapping the shortcode in <code>[raw][/raw]</code> tags (e.g., <code>[raw][s2Stream ... /][/raw]</code>).</p>' . "\n";
         }
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_rtmp_streaming", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h3><code>[s2Stream /]</code> Video Shortcode Examples (recommended — it\'s the easiest way)</h3>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4\').toggle(); return false;" class="ws-dotted-link">JW Player (MP4 file, via Rewrite URLs. Amazon S3/CloudFront NOT required)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Works with any audio/video file. This does NOT require s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp4.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4-rtmp\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP4, via s2Member\'s Amazon S3/CloudFront integration)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4-rtmp" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Streams with the RTMP protocol, plus there is a full download fallback of the MP4 source file if streaming is not possible on a particular device.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp4-rtmp.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4-rtmp-only\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP4 only, via s2Member\'s Amazon S3/CloudFront integration)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp4-rtmp-only" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Streams with the RTMP protocol only, with no access to the source file, only to the RTMP stream.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp4-rtmp-only.x-php")) . '</p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h3><code>[s2Stream /]</code> Audio Shortcode Examples (recommended — it\'s the easiest way)</h3>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3\').toggle(); return false;" class="ws-dotted-link">JW Player (MP3 file, via Rewrite URLs. Amazon S3/CloudFront NOT required)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Works with any audio/video file. This does NOT require s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp3.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3-rtmp\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP3, via s2Member\'s Amazon S3/CloudFront integration)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3-rtmp" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Streams with the RTMP protocol, plus there is a full download fallback of the MP3 source file if streaming is not possible on a particular device.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp3-rtmp.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3-rtmp-only\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP3 only, via s2Member\'s Amazon S3/CloudFront integration)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-s2stream-mp3-rtmp-only" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />Streams with the RTMP protocol only, with no access to the source file, only to the RTMP stream.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-s2stream-mp3-rtmp-only.x-php")) . '</p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h3>PHP Code Examples (for more advanced integrations via PHP — in WordPress themes)</h3>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-standard-mp4\').toggle(); return false;" class="ws-dotted-link">JW Player (MP4 file, via Rewrite URLs. Amazon S3/CloudFront NOT required)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-standard-mp4" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />This does NOT require s2Member to be integrated with Amazon S3/CloudFront.<br />Also see: <code>s2Member -› Download Options -› Advanced Mod Rewrite Linkage</code>.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-standard-mp4.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP4, via s2Member\'s Amazon S3/CloudFront integration)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br />Also see: <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-summary/" target="_blank" rel="external">s2Member Codex -› API Functions</a>.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-streaming-mp4.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4-sca\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP4, via s2Member\'s JSON/Shortcode alternative)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4-sca" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br />Also see: <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-summary/" target="_blank" rel="external">s2Member Codex -› API Functions</a>.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-streaming-mp4-sca.x-php")) . '</p>' . "\n";
         echo '<p style="font-size:110%;"><a href="#" onclick="jQuery(\'p#ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4-webm\').toggle(); return false;" class="ws-dotted-link">JW Player (RTMP streaming MP4, advanced w/ multiple fallbacks)</a></p>' . "\n";
         echo '<p id="ws-plugin--s2member-rtmp-streaming-details-jwplayer-streaming-mp4-webm" style="display:none;">Download <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">JW Player here</a>, and upload <code>/jwplayer/</code> to your website\'s root directory.<br />This requires s2Member to be integrated with Amazon S3/CloudFront.<br />Also see: <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-summary/" target="_blank" rel="external">s2Member Codex -› API Functions</a>.<br /><br />' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/jwplayer-streaming-mp4-webm.x-php")) . '</p>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_rtmp_streaming", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_rewrite_linkage", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_rewrite_linkage", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Advanced Mod-Rewrite Linkage">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-rewrite-linkage-section">' . "\n";
         echo '<h3>Advanced Mod-Rewrite Linkage</h3>' . "\n";
         echo '<p>s2Member automatically creates <code>mod_rewrite</code> rules inside your <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory, which provide additional flexibility in the way protected files can be served to your Customers. With s2Member\'s <code>mod_rewrite</code> rules, it is now possible to link directly to a protected file, avoiding the use of query string variables <em>(it\'s completely optional though, i.e. NOT required)</em>.</p>' . "\n";
         echo '<p>This new flexibility may come in handy for site owners serving files through media playback devices that have issues with query string variables. For instance, it is now possible to link to an s2Member-protected file directly, like this: <code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/example-file.zip</code> instead of <code>... /?s2member_file_download=example-file.zip</code>. Either way works, but the direct link might be easier for some.</p>' . "\n";
         echo '<p>It is also possible to pass query string parameters through a direct link:<br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/example-file.zip?s2member_file_inline=yes&amp;s2member_file_download_key=[key]</code>.</p>' . "\n";
         echo '<p>That being said, s2Member\'s <code>mod_rewrite</code> rules allow for more advanced control over s2Member-specific parameters.</p>' . "\n";
         echo '<p>For example, you could just do this for inline files:<br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-inline</strong>/example-file.zip</code></p>' . "\n";
         echo '<p>Or, if you really want to get advanced, you could do something like this:<br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-inline-[yes|no]/s2member-file-download-key-[key]</strong>/example-file.zip</code><br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-inline-yes/s2member-file-download-key-xS54df5ER4d5x</strong>/example-file.zip</code><br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-inline-yes/s2member-skip-confirmation</strong>/example-file.zip</code></p>' . "\n";
         echo '<p>Or even this, if you\'re using Remote Header Authorization:<br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-remote</strong>/example-file.zip</code></p>' . "\n";
         echo '<p>Specifying storage location option dynamically:<br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-storage-[local|s3|cf]</strong>/example-file.zip</code><br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-storage-cf</strong>/example-cloudfront-file.zip</code><br /><code>... /wp-content/plugins/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '<strong class="ws-menu-page-hilite">/s2member-file-storage-s3/s2member-file-inline</strong>/example-s3-file.html</code></p>' . "\n";
         echo '<p><em>* Note, the order of your s2Member-specific parameters with Advanced Mod-Rewrite Linkage is irrelevant. Feel free to add/remove, or even change the order. Everything discussed here is also Multisite compatible. Everything discussed here is also compatible when/if combined with Amazon S3/CDN Storage. However, NONE of this will work on servers that do NOT support <code>mod_rewrite</code>. Almost all web servers do though.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_rewrite_linkage", get_defined_vars());
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_rewrite_linkage", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_shortcode_attrs", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_shortcode_attrs", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Shortcode Attributes &amp; API Functions (Explained)">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-shortcode-attrs-section">' . "\n";
         echo '<h3>Shortcode Attributes &amp; API Functions (Explained In Full Detail)</h3>' . "\n";
         echo '<p>s2Member makes <a href="http://codex.wordpress.org/Shortcode_API#Overview" target="_blank" rel="external">Shortcodes</a> available to you, which allow you to generate File Download URLs and/or File Download Keys. Like most Shortcodes for WordPress, s2Member reads Attributes in your Shortcode. Many site owners like to know exactly how these Shortcode Attributes work. Below, is a brief overview of each possible Shortcode Attribute.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_shortcode_attrs", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h4 style="margin:0;"><code>[s2File /]</code> &amp; <code>[s2Stream /]</code> Shortcode Attributes:</h4>' . "\n";
         echo '<p style="margin:0;"><strong>See also:</strong> API Function <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_file_download_url()" target="_blank" rel="external">s2member_file_download_url()</a> for PHP integration.</p>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr style="padding-top:0;">' . "\n";
         echo '<td style="padding-top:0;">' . "\n";
         echo '<ul>' . "\n";
         echo '<li><code>download="file.zip"</code> Location of the file, relative to the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory; or, relative to the root of your Amazon S3 Bucket, when applicable.</li>' . "\n";
         echo '<li><code>download_key="no"</code> Defaults to <code>no</code>. If <code>download_key="1|on|yes|true|ip-forever|universal"</code>, s2Member will return a URL with an s2Member-generated File Download Key. You don\'t need to generate the File Download Key yourself, s2Member does it for you. If you set <code>download_key="ip-forever"</code>, the File Download Key that s2Member generates will last forever, for a specific IP Address; otherwise, by default, all File Download Keys expire after 24 hours automatically. If you set <code>download_key="universal"</code>, s2Member will generate a File Download Key that is good for anyone/everyone forever, with NO restrictions on who/where/when a file is accessed <em>(e.g. be careful with this one)</em>.</li>' . "\n";
         echo '<li><code>stream="no"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>stream="1|on|yes|true"</code>, s2Member will return a URL containing a parameter/directive, which forces the File Download to take place over the RTMP protocol if at all possible. This ONLY works when/if s2Member is configured to run with both Amazon S3/CloudFront. Please note however, it\'s better to use the example code provided in the section above, regarding: <code>JW Player and the RTMP Protocol</code>. Also note, if <code>get_streamer_json="1|on|yes|true"</code>, s2Member will automatically force <code>stream="yes"</code> for you.</li>' . "\n";
         echo '<li><code>inline=""</code> Defaults to <code>[empty]</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>inline="1|on|yes|true"</code>, s2Member will serve the file inline, instead of as an actual File Download. If empty, s2Member will look at your <code>Inline File Extensions</code> configuration above, and serve the file inline; if, and only if, its extension matches one found in your configuration. By default, s2Member serves all files as attachments <em>(i.e. downloads)</em>, except in the case of the <code>[s2Stream /]</code> Shortcode where this defaults to <code>yes</code>. Please read the section above regarding <code>Inline File Extensions</code> for further details. Also note, this Shortcode Attribute does NOTHING for files served via Amazon CloudFront. See the tech-notes listed in the Amazon CloudFront section for further details and workarounds.</li>' . "\n";
         echo '<li><code>storage=""</code> Defaults to <code>[empty]</code>. If <code>storage="local|s3|cf"</code>, s2Member will serve the file from a specific source location, based on the value of this Shortcode Attribute. For example, if you\'ve configured Amazon S3 and/or CloudFront; but, there are a few files that you want to upload locally to the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory; you can force s2Member to serve a file from local storage by setting <code>storage="local"</code> explicitly.</li>' . "\n";
         echo '<li><code>remote="no"</code> Defaults to <code>no</code>. If <code>remote="1|on|yes|true"</code>, s2Member will authenticate access to the File Download via Remote Header Authorization, instead of through your web site. This is similar to <code>.htaccess</code> protection routines of yester-year</code>. Please check the <code>Remote Authorization and Podcasting</code> section for further details about how this works.</li>' . "\n";
         echo '<li><code>ssl=""</code> Defaults to <code>[empty]</code>. If <code>ssl="1|on|yes|true"</code>, s2Member will generate a File Download URL with an SSL protocol <em>(i.e. the URL will start with <code>https://</code> or <code>rtmpe://</code>)</em>. If empty, s2Member will only generate a File Download URL with an SSL protocol, when/if the Post/Page/URL firing the Shortcode itself, is also being viewed over SSL. Otherwise, s2Member will use a non-SSL protocol by default.</li>' . "\n";
         echo '<li><code>rewrite="no"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>rewrite="1|on|yes|true"</code>, s2Member will generate a File Download URL that takes full advantage of s2Member\'s Advanced Mod Rewrite functionality. If you\'re running an Apache web server, or another server that supports <code>mod_rewrite</code>, we highly recommend turning this on. s2Member\'s <code>mod_rewrite</code> URLs do NOT contain query string parameters, making them more portable/compatible with other software applications and/or plugins for WordPress. If you\'re integrating with JW Player, you MUST use <code>rewrite="yes"</code>.</li>' . "\n";
         echo '<li><code>rewrite_base=""</code> Defaults to <code>[empty]</code>. If <code>rewrite_base="' . esc_attr(site_url("/")) . '"</code>, s2Member will generate a File Download URL that takes full advantage of s2Member\'s Advanced Mod Rewrite functionality, and it will use the rewrite base URL as a prefix. This could be useful on some WordPress installations that use advanced directory structures. It could also be useful for site owners using virtual directories that point to <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code>. Note, if <code>rewrite_base</code> is set, s2Member will automatically force <code>rewrite="yes"</code> for you.</li>' . "\n";
         echo '<li><code>skip_confirmation="no"</code> Defaults to <code>no</code>. If <code>skip_confirmation="1|on|yes|true"</code>, s2Member will generate a File Download URL which contains a directive, telling s2Member NOT to introduce any JavaScript confirmation prompts on your site, for this File Download URL. Please note, s2Member will automatically detect links, anywhere in your content, and/or anywhere in your theme files, that contain <code>s2member_file_download</code> or <code>s2member-files</code>. Whenever a logged-in Member clicks a link that contains <code>s2member_file_download</code> or <code>s2member-files</code>, the system will politely ask the User to confirm the download using a very intuitive JavaScript confirmation prompt, which contains specific details about your configured download limitations. This way your Members will be aware of how many files they\'ve downloaded in the current period; and they\'ll be able to make a conscious decision about whether to proceed with a specific download or not.</li>' . "\n";
         echo '<li><code>url_to_storage_source="no"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>url_to_storage_source="1|on|yes|true"</code>, s2Member will generate a File Download URL which points directly to the storage source. This is only functional with Amazon S3 and/or CloudFront integrations. If you create a URL that points directly to the storage source <em>(i.e. points directly to Amazon S3 or CloudFront)</em>, s2Member will NOT be able to further authenticate the current User/Member; and, s2Member will NOT be able to count the File Download against the current User\'s account record, because the URL being generated does not pass back through s2Member at all, it points directly to the storage source. For this reason, if you set <code>url_to_storage_source="true"</code>, you should also set <code>check_user="******"</code> and <code>count_against_user="******"</code>, telling s2Member to authenticate the current User, and if authenticated, count this File Download URL against the current User\'s account record in real-time <em>(i.e. as the URL is being generated) </em>, while it still has a chance to do so. This Shortcode Attribute is useful when you stream files over the RTMP protocol; where an <code>http://</code> URL is not feasible. It also helps in situations where a 3rd-party software application will not work as intended, with s2Member\'s internal redirection to Amazon S3/CloudFront files. Important, when <code>check_user="******"</code> and/or <code>count_against_user="******"</code>, the Shortcode will return an empty and/or null object value in situations where the current User/Member does NOT have access to the file.</li>' . "\n";
         echo '<li><code>count_against_user="******"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>count_against_user="******"</code>, it will automatically force <code>check_user="******"</code> as well. In other words, s2Member will authenticate the current User, and if authenticated, count this File Download URL against the current User\'s account record in real-time <em>(i.e. as the URL is being generated) </em>. This is off by default with the <code>[s2File /]</code> Shortcode. By default, s2Member will simply generate a File Download URL, and upon a User/Member clicking the URL, s2Member will authenticate the User/Member at that time, count the File Download against their account record, and serve the File Download. In other words, under normal circumstances, there is no reason to set <code>check_user="******"</code> and/or <code>count_against_user="******"</code> when generating the URL itself. However, this is a useful Shortcode Attribute when <code>url_to_storage_source="true"</code>. Please note, when <code>check_user="******"</code> and/or <code>count_against_user="******"</code>, the Shortcode will return an empty and/or null object value in situations where the current User/Member does NOT have access to the file.</li>' . "\n";
         echo '<li><code>check_user="******"</code> Defaults to <code>no</code> with <code>[s2File /]</code> Shortcode. Defaults to <code>yes</code> with <code>[s2Stream /]</code> Shortcode. If <code>check_user="******"</code>, s2Member will authenticate the current User before allowing the File Download URL to be generated. This is off by default with the <code>[s2File /]</code> Shortcode. By default, s2Member will simply generate a File Download URL, and upon a User/Member clicking the URL, s2Member will authenticate the User/Member at that time, and serve the File Download to the User/Member. In other words, under normal circumstances, there is no reason to set <code>check_user="******"</code> and/or <code>count_against_user="******"</code> when generating the URL itself. However, this IS a useful Shortcode Attribute when <code>url_to_storage_source="true"</code>. Please note, when <code>check_user="******"</code> and/or <code>count_against_user="******"</code>, the Shortcode will return an empty and/or null object value in situations where the current User/Member does NOT have access to the file.</li>' . "\n";
         echo '<li><code>get_streamer_json="no"</code> Defaults to <code>no</code>. N/A with <code>[s2Stream /]</code> Shortcode. If <code>get_streamer_json="1|on|yes|true"</code>, the <code>[s2File /]</code> Shortcode will return a JSON object for JavaScript notation, making it possible to integrate the <code>[s2File /]</code> Shortcode into JavaScript routines that configure streaming media players. For further details, please review the section above: <code>JW Player &amp; RTMP Protocol Examples</code>. Note, if you set <code>get_streamer_json="true"</code>, s2Member will automatically force <code>url_to_storage_source="true"</code> and <code>stream="true"</code>. For that reason, you should carefully review the details and warning above regarding <code>url_to_storage_source</code>. If you set <code>get_streamer_json="true"</code>, you should also set <code>check_user="******"</code> and <code>count_against_user="******"</code>.</li>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_shortcode_attrs_s2file_lis", get_defined_vars());
         echo '</ul>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h4 style="margin:0;">Additional <code>[s2Stream /]</code> Shortcode Attributes:</h4>' . "\n";
         echo '<p style="margin:0;"><strong>See also:</strong> This KB article: <a href="http://www.s2member.com/kb/jwplayer-s2stream-shortcodes/" target="_blank" rel="external">JW Player w/ <code>[s2Stream /]</code> Shortcodes</a>.</p>' . "\n";
         echo '<p style="margin:0;"><strong>See also:</strong> API Function <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_file_download_url()" target="_blank" rel="external">s2member_file_download_url()</a> for PHP integration.</p>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr style="padding-top:0;">' . "\n";
         echo '<td style="padding-top:0;">' . "\n";
         echo '<ul>' . "\n";
         echo '<li><code>file_download="video.mp4"</code> Location of the audio/video file, relative to the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory; or, relative to the root of your Amazon S3 Bucket, when applicable.</li>' . "\n";
         echo '<li><code>player="jwplayer-v6-rtmp"</code> Required. Current supported players in this Shortcode include: <code>jwplayer-v6</code> (works with any audio/video file, and you do NOT need to have Amazon  S3 or CloudFront integrated for this to work), <code>jwplayer-v6-rtmp</code> (streams with the RTMP protocol, plus there is a full download fallback of the source file if streaming is not possible on a particular device; this requires both Amazon S3 and CloudFront integration), <code>jwplayer-v6-rtmp-only</code> (streams with the RTMP protocol only, with no access to the source file, only to the RTMP stream; this requires both Amazon S3 and CloudFront integration).</li>' . "\n";
         echo '<li><code>player_id=""</code> Optional. HTML div ID for the audio/video player. Defaults to a unique ID generated by s2Member for each instance of your Shortcode.</li>' . "\n";
         echo '<li><code>player_path="/jwplayer/jwplayer.js"</code> Required. Path to the player\'s JavaScript file (ex: <code>/jwplayer/jwplayer.js</code> — you should upload the <a href="http://www.longtailvideo.com/players/" target="_blank" rel="external">/jwplayer</a> folder to the root of your web directory).</li>' . "\n";
         echo '<li><code>player_{setting}=""</code> Optional. Any additional configuration attributes supported by your audio/video player, prefixed with <code>player_</code>. For JW Player v6, see <a href="http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player" target="_blank" rel="external">this article please</a>. Examples: <code>player_width="480"</code>, <code>player_height="270"</code>, <code>player_title="My Video"</code>, <code>player_description="A video about something."</code>, <code>player_image="http://www.example.com/wp-content/uploads/video-preview.jpg"</code>, <code>player_mediaid="video_ei0wsx23"</code>, <code>player_autostart="true"</code>, <code>player_skin="/jwplayer/my-skin.xml"</code>, <code>player_key="my-license-key"</code>, <code>player_captions="{file:\'/assets/captions-en.vtt\',label:\'English\'}"</code> (<em>With <a href="http://www.longtailvideo.com/support/jw-player/28845/adding-video-captions" target="_blank" rel="external">Captions</a>, you can exclude the square array brackets to avoid Shortcode parsing issues. s2Member will automatically wrap your Caption objects with square array brackets.</em>). Please note that "Advanced Options Blocks" listed on <a href="http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player" target="_blank" rel="external">this page</a> are NOT supported here. For those, please use: <code>player_option_blocks=""</code> (see below).</li>' . "\n";
         echo '<li><code>player_option_blocks=""</code> Optional. Any "Advanced Option Blocks" supported by your audio/video player. For JW Player v6, see <a href="http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player" target="_blank" rel="external">this article please</a>. Here are some examples: <code>player_option_blocks="sharing:{}"</code>, <code>player_option_blocks="sharing:{}, logo: {file: \'/logo.png\', link: \'http://example.com\'}"</code>. Or: <code>player_option_blocks="c2hhcmluZzoge30="</code> (base64 encoded version of <code>sharing:{}</code>). Please note that "Advanced Options Blocks" can be defined in plain text or with a <a href="http://www.base64encode.org/" target="_blank" rel="external">base64 encoded string</a>. Advanced Option Blocks are JavaScript objects with properties. If you have trouble defining JavaScript object properties inside a Shortcode Attribute, please use <a href="http://www.base64encode.org/" target="_blank" rel="external">this tool</a> to base64 encode your Advanced Option Blocks, so that you end up with a string that\'s compatible with Shortcode Attributes.</li>' . "\n";
         echo '<li>Please check the <strong>Shortcode Attributes</strong> Tab in <a href="http://www.s2member.com/kb/jwplayer-s2stream-shortcodes/#using-s2stream-shortcodes" target="_blank" rel="external">this KB article</a> for further details on everything here.</li>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_shortcode_attrs_s2stream_lis", get_defined_vars());
         echo '</ul>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h4 style="margin:0;"><code>[s2Key /]</code> Shortcode Attributes:</h4>' . "\n";
         echo '<p style="margin:0;"><strong>See also:</strong> API Function <a href="http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_file_download_key()" target="_blank" rel="external">s2member_file_download_key()</a> for PHP integration.</p>' . "\n";
         echo '<table class="form-table" style="margin-top:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr style="padding-top:0;">' . "\n";
         echo '<td style="padding-top:0;">' . "\n";
         echo '<ul>' . "\n";
         echo '<li><code>file_download="file.zip"</code> Location of the file, relative to the <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/</code> directory; or, relative to the root of your Amazon S3 Bucket, when applicable.</li>' . "\n";
         echo '<li><code>directive=""</code> Defaults to <code>[empty]</code>. If <code>directive="ip-forever|universal"</code>, s2Member will return a special File Download Key. If you set <code>directive="ip-forever"</code>, the File Download Key that s2Member generates will last forever, for a specific IP Address; otherwise, by default, all File Download Keys expire after 24 hours automatically. If you set <code>directive="universal"</code>, s2Member will generate a File Download Key that is good for anyone/everyone forever, with NO restrictions on who/where/when a file is accessed <em>(e.g. be careful with this one)</em>.</li>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_shortcode_attrs_s2key_lis", get_defined_vars());
         echo '</ul>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_shortcode_attrs", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_gzip_conflicts", true, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_gzip_conflicts", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Preventing GZIP Conflicts On Server">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-gzip-conflicts-section">' . "\n";
         echo '<h3>Preventing GZIP Conflicts On Server (Instructions)</h3>' . "\n";
         echo '<p>Protected files served by s2Member through PHP scripts, are already compressed. Therefore, <a href="http://code.google.com/speed/articles/gzip.html" target="_blank" rel="nofollow external xlink">GZIP compression</a> is not needed during protected file delivery. Some web servers (i.e. Apache, LiteSpeed, and similar) include GZIP compression rules through server-side extensions, like <code>mod_deflate</code> for example. While s2Member encourages the use of extensions like <code>mod_deflate</code>, it is best to disable GZIP automatically (i.e. temporarily) during s2Member\'s delivery of a protected file through a PHP script. This avoids conflicts on the server which might otherwise lead to corrupted file downloads. s2Member makes a valiant effort to accomplish this via PHP, all on its own. However, it never hurts to add this section of code to the root <code>.htaccess</code> file for your WordPress installation. Optional, but highly recommended.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_gzip_conflicts", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p style="margin:0; font-weight:bold;">s2Member automatically adds this to your <code>.htaccess</code> file upon activation of the plugin.</p>' . "\n";
         echo '<p style="margin:0;">The following <code>mod_rewrite</code> rule goes inside this file: <code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path(ABSPATH . ".htaccess")) . '</code></p>' . "\n";
         echo '<pre class="code"><code>' . esc_html(trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_no_gzip_htaccess"])))) . '</code></pre>';
         echo '<p><strong>* Tip:</strong> this covers all types of integration with s2Member File Downloads, even if you\'re using s2Member\'s Advanced Mod Rewrite Linkage.</p>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_gzip_conflicts", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_down_ops_page_during_left_sections_display_custom_capability_files", !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site(), get_defined_vars())) {
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_before_custom_capability_files", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Custom Capability &amp; Member Level Files">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-custom-capability-files-section">' . "\n";
         echo '<h3>Restricting Files, Based On Custom Capabilities</h3>' . "\n";
         echo '<p>If you\'re NOT familiar with Custom Capabilities yet, please read: <code>Dashboard -› s2Member -› API Scripting -› Custom Capability Packages</code>. Once you understand the basic concept of Custom Capabilities &amp; Protected File Downloads, you\'ll see that (by default) s2Member does NOT handle File Download Protection with respect to Custom Capabilities. That\'s where Custom Capability Sub-directories come in.</p>' . "\n";
         echo '<p>You can create Custom Capability Sub-directories under: <code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '</code>. For instance, if you have a Custom Capability <code>music</code>, you can place protected files that should ONLY be accessible to Members with <code>access_s2member_ccap_music</code>, inside: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-ccap-music/</code>. Some examples are provided below.</p>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_during_custom_capability_files", get_defined_vars());
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><strong>Custom Capabilities:</strong> (music,videos)</p>' . "\n";
         echo '<p>Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-ccap-music</code><br />Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-ccap-videos</code></p>' . "\n";
         echo '<p>Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-ccap-music/file.mp3</code><br />Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-ccap-videos/file.avi</code></p>' . "\n";
         echo '<p>Now, here are some link examples, using Custom Capability Sub-directories:</p>' . "\n";
         echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/ccap-file-downloads.x-php")) . '</p>' . "\n";
         echo '<p><em>These links will ONLY work for Members who are logged-in, with the proper Capabilities.</em></p>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><strong>Membership Levels:</strong> (this also works fine)</p>' . "\n";
         echo '<p>Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level0</code><br />Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level1</code><br />Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level2</code><br />Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level3</code><br />Sub-Directory: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level4</code></p>' . "\n";
         echo '<p>Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level0/tiger.doc</code><br />Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level1/zebra.pdf</code><br />Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level2/elephant.doc</code><br />Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level3/rhino.pdf</code><br />Protected File: <code>/' . esc_html(c_ws_plugin__s2member_utils_dirs::basename_dir_app_data($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) . '/access-s2member-level4/lion.doc</code></p>' . "\n";
         echo '<p>Now, here are some link examples, using Member Level Sub-directories:</p>' . "\n";
         echo '<p>' . c_ws_plugin__s2member_utils_strings::highlight_php(file_get_contents(dirname(__FILE__) . "/code-samples/level-file-downloads.x-php")) . '</p>' . "\n";
         echo '<p><em>These links will ONLY work for Members who are logged-in, with an adequate Membership Level.</em></p>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_down_ops_page_during_left_sections_after_custom_capability_files", get_defined_vars());
     }
     do_action("ws_plugin__s2member_during_down_ops_page_after_left_sections", get_defined_vars());
     echo '<div class="ws-menu-page-hr"></div>' . "\n";
     echo '<p class="submit"><input type="submit" value="Save All Changes" /></p>' . "\n";
     echo '</form>' . "\n";
     echo '</td>' . "\n";
     echo '<td class="ws-menu-page-table-r">' . "\n";
     c_ws_plugin__s2member_menu_pages_rs::display();
     echo '</td>' . "\n";
     echo '</tr>' . "\n";
     echo '</tbody>' . "\n";
     echo '</table>' . "\n";
     echo '</div>' . "\n";
 }
Example #23
0
 /**
  * Handles Page Level Access *(for specific Pages)*.
  *
  * @package s2Member\Pages
  * @since 3.5
  *
  * @param int|str $page_id Numeric Page ID.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array (with details) if access is denied, else null if access is allowed.
  *
  * @todo Provide more information in the return array (like MOP Vars).
  */
 public static function check_specific_page_level_access($page_id = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars());
     $excluded = apply_filters("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars());
     if (!$excluded && is_numeric($page_id) && ($page_id = (int) $page_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         $page_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_page_link($page_id));
         // Get a full valid URI for this Page now.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($page_id, $page_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                 return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $page_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
                 } else {
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
                     } else {
                         if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($page_id, $page_uri)) {
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 } else {
                                     if (strpos($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") !== false && (in_array("all-page", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) || in_array("all-pages", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]))) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (has_tag("", $page_id)) {
                                 for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag(preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $page_id) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                                     // URIs configured at this Level?
                                     foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                         if ($str && preg_match("/" . preg_quote($str, "/") . "/", $page_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (is_array($ccaps_req = get_post_meta($page_id, "s2member_ccaps_req", true)) && !empty($ccaps_req)) {
                                 foreach ($ccaps_req as $ccap) {
                                     // The ``$user`` MUST satisfy ALL Custom Capabilities.
                                     if (strlen($ccap) && (!$check_user || !$user || !$user->has_cap("access_s2member_ccap_" . $ccap))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_ccap_req" => $ccap), get_defined_vars());
                                     }
                                 }
                             }
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access($page_id, "read-only"))) {
                                 return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_sp_req" => $page_id), get_defined_vars());
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars());
         }
     }
     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars());
 }
 /**
  * Calls upon the PayPal PayFlow API, and returns the response.
  *
  * @package s2Member\PayPal
  * @since 120514
  *
  * @param array $post_vars An array of variables to send through the PayPal PayFlow API call.
  * @return array An array of variables returned by the PayPal PayFlow API.
  */
 public static function paypal_payflow_api_response($post_vars = FALSE)
 {
     global $current_site, $current_blog;
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_paypal_payflow_api_response", get_defined_vars());
     unset($__refs, $__v);
     $url = "https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "pilot-payflowpro.paypal.com" : "payflowpro.paypal.com");
     $post_vars = apply_filters("ws_plugin__s2member_paypal_payflow_api_post_vars", $post_vars, get_defined_vars());
     $post_vars = is_array($post_vars) ? $post_vars : array();
     $post_vars["VERBOSITY"] = "HIGH";
     $post_vars["USER"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"];
     $post_vars["PARTNER"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_partner"];
     $post_vars["VENDOR"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_vendor"];
     $post_vars["PWD"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_password"];
     foreach ($post_vars as $_key => &$_value) {
         $_value = c_ws_plugin__s2member_paypal_utilities::paypal_payflow_api_nv_cleanup($_key, $_value);
     }
     unset($_key, $_value);
     $input_time = date("D M j, Y g:i:s a T");
     $nvp_post_vars = "";
     foreach ($post_vars as $_key => $_value) {
         $nvp_post_vars .= ($nvp_post_vars ? "&" : "") . $_key . "[" . strlen($_value) . "]=" . $_value;
     }
     unset($_key, $_value);
     $nvp = trim(c_ws_plugin__s2member_utils_urls::remote($url, $nvp_post_vars, array("timeout" => 20, "headers" => array("Content-Type" => "text/namevalue"))));
     $output_time = date("D M j, Y g:i:s a T");
     wp_parse_str($nvp, $response);
     $response = c_ws_plugin__s2member_utils_strings::trim_deep($response);
     if ($response["RESULT"] !== "0") {
         if (strlen($response["RESPMSG"])) {
             /* translators: Exclude `%2$s`. These are English details returned by PayPal. Replace `%2$s` with: `Unable to process, please try again`, or something to that affect. Or, if you prefer, you could Filter ``$response["__error"]`` with `ws_plugin__s2member_paypal_payflow_api_response`. */
             $response["__error"] = sprintf(_x('Error #%1$s. %2$s.', "s2member-front", "s2member"), $response["RESULT"], rtrim($response["RESPMSG"], "."));
         } else {
             $response["__error"] = _x("Error. Please contact Support for assistance.", "s2member-front", "s2member");
         }
     } else {
         if (isset($response["TRXRESULT"]) && $response["TRXRESULT"] !== "0") {
             if (strlen($response["TRXRESPMSG"])) {
                 /* translators: Exclude `%2$s`. These are English details returned by PayPal. Replace `%2$s` with: `Unable to process, please try again`, or something to that affect. Or, if you prefer, you could Filter ``$response["__error"]`` with `ws_plugin__s2member_paypal_payflow_api_response`. */
                 $response["__error"] = sprintf(_x('Error #%1$s. %2$s.', "s2member-front", "s2member"), $response["TRXRESULT"], rtrim($response["TRXRESPMSG"], "."));
             } else {
                 $response["__error"] = _x("Error. Please contact Support for assistance.", "s2member-front", "s2member");
             }
         }
     }
     $logt = c_ws_plugin__s2member_utilities::time_details();
     $logv = c_ws_plugin__s2member_utilities::ver_details();
     $logm = c_ws_plugin__s2member_utilities::mem_details();
     $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . @$_SERVER["HTTP_USER_AGENT"];
     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
     $log2 = is_multisite() && !is_main_site() ? "paypal-payflow-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-payflow-api.log";
     if (isset($post_vars["ACCT"]) && strlen($post_vars["ACCT"]) > 4) {
         $post_vars["ACCT"] = str_repeat("*", strlen($post_vars["ACCT"]) - 4) . substr($post_vars["ACCT"], -4);
     }
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
         if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
             if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                 if ($log = "-------- Input vars: ( " . $input_time . " ) --------\n" . $nvp_post_vars . "\n" . var_export($post_vars, true) . "\n") {
                     if ($log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export($response, true)) {
                         file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info($log) . "\n\n", FILE_APPEND);
                     }
                 }
             }
         }
     }
     return apply_filters("ws_plugin__s2member_paypal_payflow_api_response", c_ws_plugin__s2member_paypal_utilities::_paypal_payflow_api_response_filters($response), get_defined_vars());
 }
 /**
  * Handles processing of Pro-Form cancellations.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action('init');``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_cancellation()
 {
     if (!empty($_POST['s2member_pro_paypal_cancellation']['nonce']) && ($nonce = $_POST['s2member_pro_paypal_cancellation']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-paypal-cancellation')) {
         $GLOBALS['ws_plugin__s2member_pro_paypal_cancellation_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_paypal_cancellation_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_paypal_cancellation']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__s2member_pro_paypal_cancellation_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
         // Collect reCAPTCHA™ post vars.
         if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars['attr'])) {
             if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors('cancellation', $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if ($cur__subscr_id = get_user_option('s2member_subscr_id')) {
                         if (($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($cur__subscr_id)) && @$paypal['TENDER'] !== 'P') {
                             if (preg_match('/^(Active|ActiveProfile)$/i', $paypal['STATUS'])) {
                                 if (!($ipn = array())) {
                                     $ipn['txn_type'] = 'subscr_cancel';
                                     $ipn['subscr_id'] = $paypal['PROFILEID'];
                                     $ipn['custom'] = get_user_option('s2member_custom');
                                     $ipn['period1'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal);
                                     $ipn['period3'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal);
                                     $ipn['payer_email'] = $paypal['EMAIL'];
                                     $ipn['first_name'] = $paypal['NAME'];
                                     $ipn['last_name'] = $paypal['LASTNAME'];
                                     $ipn['option_name1'] = 'Referencing Customer ID';
                                     $ipn['option_selection1'] = $paypal['PROFILEID'];
                                     $ipn['option_name2'] = 'Customer IP Address';
                                     // IP Address.
                                     $ipn['option_selection2'] = get_user_option('s2member_registration_ip');
                                     $ipn['item_name'] = !empty($paypal['DESC']) ? $paypal['DESC'] : $paypal['PROFILENAME'];
                                     $ipn['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal);
                                     $ipn['s2member_paypal_proxy'] = 'paypal';
                                     $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                     $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                     c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                 }
                                 c_ws_plugin__s2member_pro_paypal_utilities::payflow_cancel_profile($paypal['PROFILEID'], !empty($paypal['BAID']) ? $paypal['BAID'] : '');
                                 $global_response = array('response' => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         } else {
                             if ($paypal && $paypal['TENDER'] === 'P') {
                                 $global_response = array('response' => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', 's2member-front', 's2member'), esc_attr('https://' . ($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_sandbox'] ? 'www.sandbox.paypal.com' : 'www.paypal.com') . '/cgi-bin/webscr?cmd=_subscr-find&amp;alias=' . urlencode($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_merchant_id']))), 'error' => TRUE);
                             } else {
                                 $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                         if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     }
                     if ($post_vars['attr']['unsub']) {
                         c_ws_plugin__s2member_list_servers::process_list_server_removals_against_current_user(TRUE);
                     }
                 } else {
                     $global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Verifies an s2Member-generated signature; in a full URL, a partial URI, or in just a query string.
  *
  * @package s2Member\Utilities
  * @since 111106
  *
  * @param str $url_uri_query A full URL, a partial URI, or just a query string. Must have an s2Member-generated signature to validate.
  * @param bool $check_time Optional. Defaults to false. If true, s2Member will also check if the signature has expired, based on ``$exp_secs``.
  * @param str|int $exp_secs Optional. Defaults to (int)10. If ``$check_time`` is true, s2Member will check if the signature has expired, based on ``$exp_secs``.
  * @param str $sig_var Optional. The name of the s2Member-generated signature variable. Defaults to `_s2member_sig`.
  * @return bool True if the s2Member-generated signature is OK, else false.
  */
 public static function s2member_sig_ok($url_uri_query = FALSE, $check_time = FALSE, $exp_secs = FALSE, $sig_var = FALSE)
 {
     $url_uri_query = $query = c_ws_plugin__s2member_utils_strings::trim((string) $url_uri_query, false, "?&=");
     if (preg_match("/^(?:[a-z]+\\:\\/\\/|\\/)/i", $url_uri_query)) {
         $query = trim(c_ws_plugin__s2member_utils_urls::parse_url($url_uri_query, PHP_URL_QUERY), "?&=");
     }
     /**/
     $check_time = $check_time ? true : false;
     $exp_secs = is_numeric($exp_secs) ? (int) $exp_secs : 10;
     $sig_var = $sig_var && is_string($sig_var) ? $sig_var : "_s2member_sig";
     /**/
     $key = c_ws_plugin__s2member_utils_encryption::key();
     /**/
     if (preg_match_all("/" . preg_quote($sig_var, "/") . "\\=([0-9]+)-([^&\$]+)/", $query, $sigs)) {
         $query = c_ws_plugin__s2member_utils_urls::remove_s2member_sigs($query, $sig_var);
         /**/
         wp_parse_str($query, $vars);
         $vars = c_ws_plugin__s2member_utils_arrays::remove_0b_strings(c_ws_plugin__s2member_utils_strings::trim_deep($vars));
         $vars = serialize(c_ws_plugin__s2member_utils_arrays::ksort_deep($vars));
         /**/
         ($time = $sigs[1][$i = count($sigs[1]) - 1]) . ($sig = $sigs[2][$i]) . ($valid_sig = md5($key . $time . $vars));
         /**/
         if ($check_time) {
             return $sig === $valid_sig && $time >= strtotime("-" . $exp_secs . " seconds");
         } else {
             /* Ignoring time? Just need to compare signatures in this case. */
             return $sig === $valid_sig;
         }
     } else {
         /* Return false. No ``$query``, or no ``$sigs``. */
         return false;
     }
 }
 /**
  * Determines if the current page is WordPress® Systematic.
  *
  * @package s2Member\Systematics
  * @since 111002
  *
  * @return bool True if WordPress® Systematic, else false.
  *
  * @note The results of this function are cached staticially.
  * 	Do NOT call upon this until the `init` Hook is fired.
  */
 public static function is_wp_systematic_use_page()
 {
     static $is_wp_systematic;
     /* For optimization. */
     /**/
     if (isset($is_wp_systematic)) {
         return $is_wp_systematic;
         /* Filters will have already been applied here. */
     } else {
         if (is_admin()) {
             return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
         } else {
             if (defined("WP_INSTALLING") && WP_INSTALLING) {
                 return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
             } else {
                 if (defined("APP_REQUEST") && APP_REQUEST) {
                     return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
                 } else {
                     if (defined("XMLRPC_REQUEST") && XMLRPC_REQUEST) {
                         return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
                     } else {
                         if (defined("DOING_CRON") && DOING_CRON || strcasecmp(PHP_SAPI, "CLI") === 0) {
                             return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
                         } else {
                             if (preg_match("/^\\/(?:wp-.+?|xmlrpc)\\.php\$/", c_ws_plugin__s2member_utils_urls::parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH))) {
                                 return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars());
                             } else {
                                 /* Otherwise, we return false ( it's NOT a WordPress® Systematic Use Page ). */
                                 return $is_wp_systematic = apply_filters("ws_plugin__s2member_is_wp_systematic_use_page", false, get_defined_vars());
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #28
0
 /**
  * Handles processing of Pro-Form checkouts.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_checkout()
 {
     if (!empty($_POST['s2member_pro_stripe_checkout']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_checkout']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-checkout')) {
         $GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_checkout']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__s2member_pro_stripe_checkout_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email(@$post_vars['email']), get_defined_vars());
         $post_vars['username'] = is_multisite() ? strtolower(@$post_vars['username']) : @$post_vars['username'];
         // Force lowercase.
         $post_vars['username'] = sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite());
         $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
         // Collect reCAPTCHA™ post vars.
         if (!c_ws_plugin__s2member_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__s2member_pro_stripe_responses::stripe_form_submission_validation_errors('checkout', $post_vars))) {
                 unset($_POST['s2member_pro_stripe_checkout']['source_token']);
                 // Good one-time only.
                 unset($_POST['s2member_pro_stripe_checkout']['source_token_summary']);
                 // Good one-time only.
                 $is_bitcoin = !empty($post_vars['source_token']) && stripos($post_vars['source_token'], 'btcrcv_') === 0;
                 $cp_attr = c_ws_plugin__s2member_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post'));
                 $cost_calculations = c_ws_plugin__s2member_pro_stripe_utilities::cost($cp_attr['ta'], $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc'], $is_bitcoin);
                 if ($cost_calculations['total'] <= 0 && $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0) {
                     $post_vars['attr']['tp'] = '0';
                     // Ditch the trial period completely.
                     $cost_calculations['sub_total'] = $cost_calculations['trial_sub_total'];
                     // Use as regular sub-total (ditch trial sub-total).
                     $cost_calculations['tax'] = $cost_calculations['trial_tax'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['tax_per'] = $cost_calculations['trial_tax_per'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['total'] = $cost_calculations['trial_total'];
                     // Use as regular total (ditch trial).
                     $cost_calculations['trial_sub_total'] = '0.00';
                     // Ditch the initial total (using as grand total).
                     $cost_calculations['trial_tax'] = '0.00';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_tax_per'] = '';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_total'] = '0.00';
                     // Ditch this calculation now also.
                 }
                 $use_subscription = $post_vars['attr']['rr'] === 'BN' || !$post_vars['attr']['tp'] && !$post_vars['attr']['rr'] ? FALSE : TRUE;
                 $is_independent_ccaps_sale = $post_vars['attr']['level'] === '*' ? TRUE : FALSE;
                 // Selling Independent Custom Capabilities?
                 if ($use_subscription && $cost_calculations['trial_total'] <= 0 && $cost_calculations['total'] <= 0) {
                     if (!$post_vars['attr']['rr'] && $post_vars['attr']['rt'] !== 'L') {
                         if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                             $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                         } else {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                             }
                         }
                     } else {
                         if ($post_vars['attr']['rr'] && $post_vars['attr']['rrt'] && $post_vars['attr']['rt'] !== 'L') {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                             } else {
                                 if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                     $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                                 }
                             }
                         }
                     }
                 }
                 if ($use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     $plan_attr = $cp_attr;
                     // For the subscription plan.
                     $plan_attr['ta'] = $cost_calculations['trial_total'];
                     $plan_attr['ra'] = $cost_calculations['total'];
                     $plan_attr['desc'] = $cost_calculations['desc'];
                     update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                     update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                     $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                     $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                     $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__s2member_pro_stripe_utilities::start_time($period1) : c_ws_plugin__s2member_pro_stripe_utilities::start_time($period3);
                     // Or next billing cycle.
                     if (!$global_response) {
                         if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                             if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                             } else {
                                 if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                         $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                     } else {
                                         $new__txn_cid = $stripe_customer->id;
                                         $new__txn_id = $stripe_charge->id;
                                     }
                                 }
                             }
                         }
                     }
                     if (!$global_response) {
                         if ($cost_calculations['total'] > 0) {
                             if (!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr))) {
                                 $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                             } else {
                                 if ((empty($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if ((empty($stripe_customer_with_source) || !is_object($stripe_customer_with_source)) && !is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id, array(), $post_vars, $cost_calculations))) {
                                             $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                         } else {
                                             $new__subscr_cid = $stripe_customer->id;
                                             $new__subscr_id = $stripe_subscription->id;
                                         }
                                     }
                                 }
                             }
                             if ($global_response && !empty($new__txn_id)) {
                                 $global_response = array();
                                 $stripe_subscription_failed_charge_succeeded = TRUE;
                             }
                         }
                     }
                     if (!$global_response) {
                         $old__subscr_cid = get_user_option('s2member_subscr_cid');
                         $old__subscr_id = get_user_option('s2member_subscr_id');
                         $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                         if (empty($new__subscr_cid)) {
                             $new__subscr_cid = strtoupper('free-' . uniqid());
                         }
                         if (empty($new__subscr_id)) {
                             $new__subscr_id = strtoupper('free-' . uniqid());
                         }
                         $ipn['txn_type'] = 'subscr_signup';
                         $ipn['subscr_cid'] = $new__subscr_cid;
                         $ipn['subscr_id'] = $new__subscr_id;
                         $ipn['custom'] = $post_vars['attr']['custom'];
                         $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                         $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                         $ipn['period1'] = $period1;
                         $ipn['period3'] = $period3;
                         $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                         $ipn['mc_amount3'] = $cost_calculations['total'];
                         $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                         $ipn['mc_currency'] = $cost_calculations['cur'];
                         $ipn['tax'] = $cost_calculations['tax'];
                         $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                         $ipn['payer_email'] = $user->user_email;
                         $ipn['first_name'] = $post_vars['first_name'];
                         $ipn['last_name'] = $post_vars['last_name'];
                         $ipn['option_name1'] = 'Referencing Customer ID';
                         $ipn['option_selection1'] = $old__subscr_or_wp_id;
                         $ipn['option_name2'] = 'Customer IP Address';
                         $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                         $ipn['item_name'] = $cost_calculations['desc'];
                         $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                         $ipn['s2member_paypal_proxy'] = 'stripe';
                         $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                         $ipn['s2member_paypal_proxy_use'] .= $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                         $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                         $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                         $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                         $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                         if (!empty($stripe_subscription_failed_charge_succeeded)) {
                             update_user_option($user_id, 's2member_auto_eot_time', $start_time);
                         }
                         if ($old__subscr_cid && $old__subscr_id && apply_filters('s2member_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                             c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                         }
                         c_ws_plugin__s2member_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                         setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                         if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     }
                 } else {
                     if ($use_subscription && !is_user_logged_in()) {
                         $plan_attr = $cp_attr;
                         // For the subscription plan.
                         $plan_attr['ta'] = $cost_calculations['trial_total'];
                         $plan_attr['ra'] = $cost_calculations['total'];
                         $plan_attr['desc'] = $cost_calculations['desc'];
                         $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                         $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                         $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__s2member_pro_stripe_utilities::start_time($period1) : c_ws_plugin__s2member_pro_stripe_utilities::start_time($period3);
                         // Or next billing cycle.
                         if (!$global_response) {
                             if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                             $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                         } else {
                                             $new__txn_cid = $stripe_customer->id;
                                             $new__txn_id = $stripe_charge->id;
                                         }
                                     }
                                 }
                             }
                         }
                         if (!$global_response) {
                             if ($cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr))) {
                                     $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                                 } else {
                                     if ((empty($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if ((empty($stripe_customer_with_source) || !is_object($stripe_customer_with_source)) && !is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id, array(), $post_vars, $cost_calculations))) {
                                                 $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                             } else {
                                                 $new__subscr_cid = $stripe_customer->id;
                                                 $new__subscr_id = $stripe_subscription->id;
                                             }
                                         }
                                     }
                                 }
                                 if ($global_response && !empty($new__txn_id)) {
                                     $global_response = array();
                                     $stripe_subscription_failed_charge_succeeded = TRUE;
                                 }
                             }
                         }
                         if (!$global_response) {
                             if (empty($new__subscr_cid)) {
                                 $new__subscr_cid = strtoupper('free-' . uniqid());
                             }
                             if (empty($new__subscr_id)) {
                                 $new__subscr_id = strtoupper('free-' . uniqid());
                             }
                             $ipn['txn_type'] = 'subscr_signup';
                             $ipn['subscr_cid'] = $new__subscr_cid;
                             $ipn['subscr_id'] = $new__subscr_id;
                             $ipn['custom'] = $post_vars['attr']['custom'];
                             $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                             $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                             $ipn['period1'] = $period1;
                             $ipn['period3'] = $period3;
                             $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                             $ipn['mc_amount3'] = $cost_calculations['total'];
                             $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                             $ipn['mc_currency'] = $cost_calculations['cur'];
                             $ipn['tax'] = $cost_calculations['tax'];
                             $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                             $ipn['payer_email'] = $post_vars['email'];
                             $ipn['first_name'] = $post_vars['first_name'];
                             $ipn['last_name'] = $post_vars['last_name'];
                             $ipn['option_name1'] = 'Originating Domain';
                             $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                             $ipn['option_name2'] = 'Customer IP Address';
                             $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                             $ipn['item_name'] = $cost_calculations['desc'];
                             $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                             $ipn['s2member_paypal_proxy'] = 'stripe';
                             $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                             $ipn['s2member_paypal_proxy_use'] .= $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                             $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                             $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                             $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'] = @$post_vars['password1'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_first_name'] = $post_vars['first_name'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_last_name'] = $post_vars['last_name'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                 foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                     $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                     $field_id_class = preg_replace('/_/', '-', $field_var);
                                     if (isset($post_vars['custom_fields'][$field_var])) {
                                         $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                     }
                                 }
                             }
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'] = 'stripe';
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'] = $new__subscr_cid;
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'] = $new__subscr_id;
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_level'] = $post_vars['attr']['level'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_ccaps'] = $post_vars['attr']['ccaps'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_custom'] = $post_vars['attr']['custom'];
                             @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                             if (!empty($eotper)) {
                                 $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper));
                             }
                             $create_user['user_email'] = $post_vars['email'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_login'] = $post_vars['username'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_pass'] = wp_generate_password();
                             // Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
                             $has_custom_password = !empty($post_vars['password1']) && $post_vars['password1'] === $create_user['user_pass'];
                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                 update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                 wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                 if (!empty($stripe_subscription_failed_charge_succeeded)) {
                                     update_user_option($new__user_id, 's2member_auto_eot_time', $start_time);
                                 }
                                 $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                 if ($has_custom_password) {
                                     $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">log in</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 } else {
                                     $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                 }
                                 if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                 $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     } else {
                         if (!$use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                             update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                             update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                             if (!$global_response) {
                                 if ($cost_calculations['total'] > 0) {
                                     if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                                 $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                             } else {
                                                 $new__txn_cid = $stripe_customer->id;
                                                 $new__txn_id = $stripe_charge->id;
                                             }
                                         }
                                     }
                                 }
                             }
                             if (!$global_response) {
                                 $old__subscr_cid = get_user_option('s2member_subscr_cid');
                                 $old__subscr_id = get_user_option('s2member_subscr_id');
                                 $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                 if (empty($new__txn_cid)) {
                                     $new__txn_cid = strtoupper('free-' . uniqid());
                                 }
                                 if (empty($new__txn_id)) {
                                     $new__txn_id = strtoupper('free-' . uniqid());
                                 }
                                 $ipn['txn_type'] = 'web_accept';
                                 $ipn['txn_cid'] = $new__txn_cid;
                                 $ipn['txn_id'] = $new__txn_id;
                                 $ipn['custom'] = $post_vars['attr']['custom'];
                                 $ipn['mc_gross'] = $cost_calculations['total'];
                                 $ipn['mc_currency'] = $cost_calculations['cur'];
                                 $ipn['tax'] = $cost_calculations['tax'];
                                 $ipn['payer_email'] = $user->user_email;
                                 $ipn['first_name'] = $post_vars['first_name'];
                                 $ipn['last_name'] = $post_vars['last_name'];
                                 $ipn['option_name1'] = 'Referencing Customer ID';
                                 $ipn['option_selection1'] = $old__subscr_or_wp_id;
                                 $ipn['option_name2'] = 'Customer IP Address';
                                 $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                 $ipn['item_name'] = $cost_calculations['desc'];
                                 $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                 $ipn['s2member_paypal_proxy'] = 'stripe';
                                 $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                 $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                 $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                 $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                 $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 if (!$is_independent_ccaps_sale) {
                                     // Independent?
                                     if ($old__subscr_cid && $old__subscr_id && apply_filters('s2member_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                                         c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                                     }
                                 }
                                 c_ws_plugin__s2member_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                                 setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                 $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         } else {
                             if (!$use_subscription && !is_user_logged_in()) {
                                 if (!$global_response) {
                                     if ($cost_calculations['total'] > 0) {
                                         if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                             } else {
                                                 if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                                     $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                                 } else {
                                                     $new__txn_cid = $stripe_customer->id;
                                                     $new__txn_id = $stripe_charge->id;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if (!$global_response) {
                                     if (empty($new__txn_cid)) {
                                         $new__txn_cid = strtoupper('free-' . uniqid());
                                     }
                                     if (empty($new__txn_id)) {
                                         $new__txn_id = strtoupper('free-' . uniqid());
                                     }
                                     $ipn['txn_type'] = 'web_accept';
                                     $ipn['txn_cid'] = $new__txn_cid;
                                     $ipn['txn_id'] = $new__txn_id;
                                     $ipn['custom'] = $post_vars['attr']['custom'];
                                     $ipn['mc_gross'] = $cost_calculations['total'];
                                     $ipn['mc_currency'] = $cost_calculations['cur'];
                                     $ipn['tax'] = $cost_calculations['tax'];
                                     $ipn['payer_email'] = $post_vars['email'];
                                     $ipn['first_name'] = $post_vars['first_name'];
                                     $ipn['last_name'] = $post_vars['last_name'];
                                     $ipn['option_name1'] = 'Originating Domain';
                                     $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                                     $ipn['option_name2'] = 'Customer IP Address';
                                     $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                     $ipn['item_name'] = $cost_calculations['desc'];
                                     $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                     $ipn['s2member_paypal_proxy'] = 'stripe';
                                     $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                     $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                     $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                     $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'] = @$post_vars['password1'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_first_name'] = $post_vars['first_name'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_last_name'] = $post_vars['last_name'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                         foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                             $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                             $field_id_class = preg_replace('/_/', '-', $field_var);
                                             if (isset($post_vars['custom_fields'][$field_var])) {
                                                 $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                             }
                                         }
                                     }
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'] = 'stripe';
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'] = $new__txn_cid;
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'] = $new__txn_id;
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_level'] = $post_vars['attr']['level'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_ccaps'] = $post_vars['attr']['ccaps'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_custom'] = $post_vars['attr']['custom'];
                                     @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                                     if (!empty($eotper)) {
                                         $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper));
                                     }
                                     $create_user['user_email'] = $post_vars['email'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_login'] = $post_vars['username'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_pass'] = wp_generate_password();
                                     // Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
                                     $has_custom_password = !empty($post_vars['password1']) && $post_vars['password1'] === $create_user['user_pass'];
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                         wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                         $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                         setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                         if ($has_custom_password) {
                                             $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">log in</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                         } else {
                                             $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                         }
                                         if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                         $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                                     }
                                 }
                             } else {
                                 $global_response = array('response' => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
 /**
  * Fills Replacement Codes in Special Redirection URLs.
  *
  * @package s2Member\Login_Redirects
  * @since 3.5
  *
  * @param string $url A URL with possible Replacement Codes in it.
  * @param object $user Optional. A `WP_User` object. Defaults to the current User, if logged-in.
  * @param bool   $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
  *
  * @return string|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
  */
 public static function fill_login_redirect_rc_vars($url = '', $user = NULL, $root_returns_false = FALSE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_fill_login_redirect_rc_vars', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     $url = (string) $url;
     // Force ``$url`` to a string value.
     $orig_url = $url;
     // Record the original URL that was passed in.
     $user = (is_object($user) || is_object($user = wp_get_current_user())) && !empty($user->ID) ? $user : NULL;
     $user_id = $user ? (string) $user->ID : '';
     $user_login = $user ? (string) strtolower($user->user_login) : '';
     $user_nicename = $user ? (string) strtolower($user->user_nicename) : '';
     $user_level = (string) c_ws_plugin__s2member_user_access::user_access_level($user);
     $user_role = (string) c_ws_plugin__s2member_user_access::user_access_role($user);
     $user_ccaps = (string) implode('-', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
     $user_logins = $user ? (string) (int) get_user_option('s2member_login_counter', $user_id) : '-1';
     $url = preg_replace('/%%current_user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_login)), $url);
     $url = preg_replace('/%%current_user_nicename%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_nicename)), $url);
     $url = preg_replace('/%%current_user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url);
     $url = preg_replace('/%%current_user_level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_level)), $url);
     $url = preg_replace('/%%current_user_role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_role)), $url);
     $url = preg_replace('/%%current_user_ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_ccaps)), $url);
     $url = preg_replace('/%%current_user_logins%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_logins)), $url);
     if ($url !== $orig_url && (!($parse = c_ws_plugin__s2member_utils_urls::parse_url($url, -1, FALSE)) || !empty($parse['path']) && strpos($parse['path'], '//') !== FALSE)) {
         $url = home_url('/');
     }
     // Defaults to Home Page. We don't return invalid URLs produced by empty Replacement Codes ( i.e., with `//` ).
     if ($root_returns_false && c_ws_plugin__s2member_utils_conds::is_site_root($url)) {
         // Used by s2Member's security gate.
         $url = FALSE;
     }
     // In case we need to return false on root URLs (i.e., don't protect the Home Page inadvertently).
     return apply_filters('ws_plugin__s2member_fill_login_redirect_rc_vars', $url, get_defined_vars());
 }
 /**
  * Connect to and process ARB service information for Authorize.Net®.
  *
  * s2Member's Auto EOT System must be enabled for this to work properly.
  *
  * If you have a HUGE userbase, increase the max IPNs per process.
  * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network.
  * To increase, use: ``add_filter ("ws_plugin__s2member_pro_arb_service_ipns_per_process");``.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("ws_plugin__s2member_after_auto_eot_system");``
  *
  * @param array $vars Expects an array of defined variables to be passed in by the Action Hook.
  * @return null
  */
 public static function authnet_arb_service($vars = FALSE)
 {
     global $wpdb;
     /* Need global DB obj. */
     global $current_site, $current_blog;
     /* For Multisite support. */
     /**/
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_authnet_api_login_id"]) {
         $scan_time = apply_filters("ws_plugin__s2member_pro_arb_service_status_scan_time", strtotime("-1 day"), get_defined_vars());
         $per_process = apply_filters("ws_plugin__s2member_pro_arb_service_ipns_per_process", $vars["per_process"], get_defined_vars());
         /**/
         if (is_array($objs = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_gateway' AND `meta_value` = 'authnet' AND `user_id` NOT IN(SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_last_status_scan' AND `meta_value` > '" . esc_sql($scan_time) . "')"))) {
             foreach ($objs as $obj) {
                 if (($user_id = $obj->ID) && ($counter = (int) $counter + 1)) {
                     unset($authnet, $subscr_id, $ipn_sv, $processing, $processed, $ipn, $ipn_q, $log4, $_log4, $log2, $logs_dir);
                     /* Unset these. */
                     /**/
                     if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $subscr_id = get_user_option("s2member_subscr_id", $user_id))) {
                         if (!get_user_option("s2member_auto_eot_time", $user_id) && is_array($ipn_sv = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(false, $subscr_id))) {
                             if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"] && is_array($authnet["arb_ipn_signup_vars"] = $ipn_sv)) {
                                 if (preg_match("/^expired\$/i", $authnet["subscription_status"])) {
                                     $authnet["s2member_log"][] = "Authorize.Net® ARB/IPN processed on: " . date("D M j, Y g:i:s a T");
                                     /**/
                                     $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `SUBSCRIPTION EXPIRATION` ).";
                                     $authnet["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_eot` ).";
                                     $authnet["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                                     /**/
                                     $processing = $processed = true;
                                     $ipn = array();
                                     /* Reset. */
                                     /**/
                                     $ipn["txn_type"] = "subscr_eot";
                                     $ipn["subscr_id"] = $authnet["arb_ipn_signup_vars"]["subscr_id"];
                                     /**/
                                     $ipn["custom"] = $authnet["arb_ipn_signup_vars"]["custom"];
                                     /**/
                                     $ipn["period1"] = $authnet["arb_ipn_signup_vars"]["period1"];
                                     $ipn["period3"] = $authnet["arb_ipn_signup_vars"]["period3"];
                                     /**/
                                     $ipn["payer_email"] = $authnet["arb_ipn_signup_vars"]["payer_email"];
                                     $ipn["first_name"] = $authnet["arb_ipn_signup_vars"]["first_name"];
                                     $ipn["last_name"] = $authnet["arb_ipn_signup_vars"]["last_name"];
                                     /**/
                                     $ipn["option_name1"] = $authnet["arb_ipn_signup_vars"]["option_name1"];
                                     $ipn["option_selection1"] = $authnet["arb_ipn_signup_vars"]["option_selection1"];
                                     /**/
                                     $ipn["option_name2"] = $authnet["arb_ipn_signup_vars"]["option_name2"];
                                     $ipn["option_selection2"] = $authnet["arb_ipn_signup_vars"]["option_selection2"];
                                     /**/
                                     $ipn["item_number"] = $authnet["arb_ipn_signup_vars"]["item_number"];
                                     $ipn["item_name"] = $authnet["arb_ipn_signup_vars"]["item_name"];
                                     /**/
                                     $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
                                     $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                     /**/
                                     c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                 } else {
                                     if (preg_match("/^(suspended|canceled|terminated)\$/i", $authnet["subscription_status"])) {
                                         $authnet["s2member_log"][] = "Authorize.Net® ARB/IPN processed on: " . date("D M j, Y g:i:s a T");
                                         /**/
                                         $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `SUBSCRIPTION " . strtoupper($authnet["subscription_status"]) . "` ).";
                                         $authnet["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_cancel` ).";
                                         $authnet["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                                         /**/
                                         $processing = $processed = true;
                                         $ipn = array();
                                         /* Reset. */
                                         /**/
                                         $ipn["txn_type"] = "subscr_cancel";
                                         $ipn["subscr_id"] = $authnet["arb_ipn_signup_vars"]["subscr_id"];
                                         /**/
                                         $ipn["custom"] = $authnet["arb_ipn_signup_vars"]["custom"];
                                         /**/
                                         $ipn["period1"] = $authnet["arb_ipn_signup_vars"]["period1"];
                                         $ipn["period3"] = $authnet["arb_ipn_signup_vars"]["period3"];
                                         /**/
                                         $ipn["payer_email"] = $authnet["arb_ipn_signup_vars"]["payer_email"];
                                         $ipn["first_name"] = $authnet["arb_ipn_signup_vars"]["first_name"];
                                         $ipn["last_name"] = $authnet["arb_ipn_signup_vars"]["last_name"];
                                         /**/
                                         $ipn["option_name1"] = $authnet["arb_ipn_signup_vars"]["option_name1"];
                                         $ipn["option_selection1"] = $authnet["arb_ipn_signup_vars"]["option_selection1"];
                                         /**/
                                         $ipn["option_name2"] = $authnet["arb_ipn_signup_vars"]["option_name2"];
                                         $ipn["option_selection2"] = $authnet["arb_ipn_signup_vars"]["option_selection2"];
                                         /**/
                                         $ipn["item_number"] = $authnet["arb_ipn_signup_vars"]["item_number"];
                                         $ipn["item_name"] = $authnet["arb_ipn_signup_vars"]["item_name"];
                                         /**/
                                         $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
                                         $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         /**/
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                     } else {
                                         if (!$processed) {
                                             /* If nothing was processed, here we add a message to the logs indicating the status; which is being ignored by s2Member. */
                                             $authnet["s2member_log"][] = "Ignoring this ARB/Status ( `" . $authnet["subscription_status"] . "` ). It does NOT require any action on the part of s2Member.";
                                         }
                                     }
                                 }
                                 /**/
                                 $logv = c_ws_plugin__s2member_utilities::ver_details();
                                 $logm = c_ws_plugin__s2member_utilities::mem_details();
                                 $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
                                 $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                                 $log2 = is_multisite() && !is_main_site() ? "authnet-arb-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "authnet-arb-ipn.log";
                                 /**/
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
                                     if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
                                         if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                                             file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($authnet, true) . "\n\n", FILE_APPEND);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     /**/
                     update_user_option($user_id, "s2member_last_status_scan", time());
                     /**/
                     if ($counter >= $per_process) {
                         /* Only this many. */
                         break;
                     }
                     /* Break the loop now. */
                 }
             }
         }
     }
     /**/
     return;
     /* Return for uniformity. */
 }