/**
  * Handles PayPal® Button encryption.
  *
  * This uses the PayPal® API. s2Member will NOT attempt to encrypt Buttons until there is at least a Business Email Address and API Username configured.
  * s2Member also maintains a log of communication with the PayPal® API. If logging is enabled, check: `/wp-content/plugins/s2member-logs/paypal-api.log`.
  *
  * @package s2Member\PayPal
  * @since 3.5
  *
  * @param str $code The PayPal® Button Code before encryption.
  * @param array $vars An array of defined variables in the scope of the calling Filter.
  * @return str The Resulting PayPal® Button Code *( possibly encrypted, depending on configuration )*.
  */
 public static function sc_paypal_button_encryption($code = FALSE, $vars = FALSE)
 {
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__s2member_before_sc_paypal_button_encryption", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_btn_encryption"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]) {
         $cache = apply_filters("ws_plugin__s2member_sc_paypal_button_encryption_cache", true, get_defined_vars());
         /**/
         eval('$_code = $vars["_code"]; $attr = $vars["attr"];');
         /* Let's unpack ( i.e. use shorter references ) to these two important vars. */
         /**/
         if ($cache && ($transient = "s2m_btn_" . md5($code . c_ws_plugin__s2member_utilities::ver_checksum())) && ($cache = get_transient($transient))) {
             $code = $cache;
         } else {
             if (is_array($inputs = c_ws_plugin__s2member_utils_forms::form_whips_2_array($_code)) && !empty($inputs)) {
                 $paypal = array("METHOD" => "BMCreateButton", "BUTTONCODE" => "ENCRYPTED", "BUTTONTYPE" => $attr["sp"] || $attr["rr"] === "BN" ? "BUYNOW" : "SUBSCRIBE");
                 /**/
                 $i = 0;
                 /* Initialize incremental variable counter. PayPal® wants these numbered using L_BUTTONVAR{n}; where {n} starts at zero. */
                 foreach ($inputs as $input => $value) {
                     /* Now run through each of the input variables that we parsed from the Full Button Code */
                     if (!preg_match("/^cmd\$/i", $input)) {
                         /* The PayPal® API method `BMCreateButton` expects (amount|a1|a3) to include 2 decimal places. */
                         if (preg_match("/^(amount|a1|a3)\$/i", $input)) {
                             $value = number_format($value, 2, ".", "");
                         }
                         /**/
                         $paypal["L_BUTTONVAR" . $i] = $input . "=" . $value;
                         $i++;
                         /* Increment variable counter. */
                     }
                 }
                 /**/
                 if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"]) && !empty($paypal["WEBSITECODE"]) && ($code = $paypal["WEBSITECODE"])) {
                     $default_image = "https://www.paypal.com/" . _x("en_US", "s2member-front paypal-button-lang-code", "s2member") . "/i/btn/btn_xpressCheckout.gif";
                     /**/
                     $code = preg_replace("/\\<img[^\\>]+\\>/i", "", $code);
                     /* Remove the 1x1 pixel tracking image that PayPal® sticks in there. */
                     $code = preg_replace("/(\\<input)([^\\>]+)(\\>)/ie", "'\\1'.rtrim(stripslashes('\\2'),'/').' /\\3'", $code);
                     /* Use XHTML! */
                     /**/
                     $code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($default_image)) . '"', $code);
                     /**/
                     $code = $attr["output"] === "anchor" ? '<a href="' . esc_attr(c_ws_plugin__s2member_utils_forms::form_whips_2_url($code)) . '"><img src="' . esc_attr($attr["image"] && $attr["image"] !== "default" ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal®" /></a>' : $code;
                     $code = $attr["output"] === "url" ? c_ws_plugin__s2member_utils_forms::form_whips_2_url($code) : $code;
                     /**/
                     $cache && $transient ? set_transient($transient, $code, apply_filters("ws_plugin__s2member_sc_paypal_button_encryption_cache_exp_time", 3600, get_defined_vars())) : null;
                     /* Caching? */
                 }
             }
         }
     }
     /* No WordPress® Filters apply here. */
     /* Instead, use: `ws_plugin__s2member_sc_paypal_button`. */
     return $code;
     /* Button Code. Possibly w/ API encryption now. */
 }
 /**
  * s2Member's PayPal® IPN handler ( inner processing routine ).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */
     /**/
     if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) {
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
             /**/
             $processing = $during = true;
             /* Yes, we ARE processing this. */
             /**/
             $paypal["s2member_log"][] = "This `txn_type` does not require any action on the part of s2Member.";
             $paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
             $paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
         } else {
             $paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
             $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
         }
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", false, get_defined_vars());
     }
 }
 /**
  * s2Member's PayPal® IPN handler ( inner processing routine ).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */
     /**/
     if (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_created\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) {
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
             /**/
             $processing = $during = true;
             /* Yes, we ARE processing this. */
             /**/
             $paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
             $paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
         } else {
             $paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
             $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
         }
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", false, get_defined_vars());
     }
 }
 function s2member_pro_paypal_rbp_for_user($user_id = FALSE)
 {
     $user_id = (int) $user_id;
     $user_id = $user_id ? $user_id : get_current_user_id();
     if (!$user_id) {
         return array();
     }
     $user_subscr_id = get_user_option('s2member_subscr_id', $user_id);
     if (!$user_subscr_id) {
         return array();
     }
     $paypal['METHOD'] = 'GetRecurringPaymentsProfileDetails';
     $paypal['PROFILEID'] = $user_subscr_id;
     if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal['__error'])) {
         return $paypal;
     }
     return array();
 }
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  *
  * @todo Build in routine to void first payment if Recurring Profile creation fails for some reason? Seems logical, even though highly unlikely.
  */
 public static function authnet_checkout()
 {
     if (!empty($_POST["s2member_pro_authnet_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-checkout")) {
         $GLOBALS["ws_plugin__s2member_pro_authnet_checkout_response"] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_authnet_checkout_response"];
         // This is a shorter reference.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_checkout"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"]));
         // And Filter.
         $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_authnet_checkout_post_attr", $post_vars["attr"], get_defined_vars());
         $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"] = 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 (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"];
         }
         if (!c_ws_plugin__s2member_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_authnet_responses::authnet_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__s2member_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cost_calculations = c_ws_plugin__s2member_pro_authnet_utilities::authnet_cost($cp_attr["ta"], $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
                 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_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 ($use_recurring_profile && $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_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     $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_authnet_utilities::authnet_start_time($period1) : c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period3);
                     // Or next billing cycle.
                     $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"] . "~" . $cost_calculations["cur"];
                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                     if (!($_authnet = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                         $_authnet["x_type"] = "AUTH_CAPTURE";
                         $_authnet["x_method"] = "CC";
                         $_authnet["x_email"] = $user->user_email;
                         $_authnet["x_first_name"] = $post_vars["first_name"];
                         $_authnet["x_last_name"] = $post_vars["last_name"];
                         $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                         $_authnet["x_invoice_num"] = "s2-" . uniqid();
                         $_authnet["x_description"] = $cost_calculations["desc"];
                         $_authnet["s2_initial_payment"] = "1";
                         // Initial.
                         $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                         $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
                         if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                             $_authnet["x_tax"] = $cost_calculations["trial_tax"];
                             $_authnet["x_amount"] = $cost_calculations["trial_total"];
                             $_authnet["x_currency_code"] = $cost_calculations["cur"];
                         } else {
                             $_authnet["x_tax"] = $cost_calculations["tax"];
                             $_authnet["x_amount"] = $cost_calculations["total"];
                             $_authnet["x_currency_code"] = $cost_calculations["cur"];
                         }
                         $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                         $_authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                         $_authnet["x_card_code"] = $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"]))
                         #		$_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                         #	else // Otherwise, we assume they provided an issue number instead.
                         #		$_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                         $_authnet["x_address"] = $post_vars["street"];
                         $_authnet["x_city"] = $post_vars["city"];
                         $_authnet["x_state"] = $post_vars["state"];
                         $_authnet["x_country"] = $post_vars["country"];
                         $_authnet["x_zip"] = $post_vars["zip"];
                     }
                     if (!($authnet = array())) {
                         $authnet["x_method"] = "create";
                         $authnet["x_email"] = $user->user_email;
                         $authnet["x_first_name"] = $post_vars["first_name"];
                         $authnet["x_last_name"] = $post_vars["last_name"];
                         $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                         $authnet["x_invoice_num"] = $_authnet ? $_authnet["x_invoice_num"] : "s2-" . uniqid();
                         $authnet["x_description"] = $cost_calculations["desc"];
                         $authnet["x_description"] .= " ((" . $reference . "))";
                         $authnet["x_amount"] = $cost_calculations["total"];
                         $authnet["x_currency_code"] = $cost_calculations["cur"];
                         $authnet["x_start_date"] = date("Y-m-d", $start_time);
                         $authnet["x_unit"] = "days";
                         // Always calculated in days.
                         $authnet["x_length"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
                         $authnet["x_total_occurrences"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "9999" : "1";
                         $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                         $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                         $authnet["x_card_code"] = $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"]))
                         #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                         #	else // Otherwise, we assume they provided an issue number instead.
                         #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                         $authnet["x_address"] = $post_vars["street"];
                         $authnet["x_city"] = $post_vars["city"];
                         $authnet["x_state"] = $post_vars["state"];
                         $authnet["x_country"] = $post_vars["country"];
                         $authnet["x_zip"] = $post_vars["zip"];
                     }
                     if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || !$_authnet || ($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])) {
                         if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")) {
                             // $authnet["response_reason_code"] === "E00018" ... Card expires before start time.
                             if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0) {
                                 $new__txn_id = $new__subscr_id = strtoupper('free-' . uniqid());
                             } else {
                                 $new__txn_id = $_authnet && !empty($_authnet["transaction_id"]) ? $_authnet["transaction_id"] : false;
                                 $new__subscr_id = $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018" ? $new__txn_id : $authnet["subscription_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");
                             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["s2member_paypal_proxy"] = "authnet";
                                 $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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                             }
                             if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                 update_user_option($user_id, "s2member_auto_eot_time", $start_time);
                             }
                             if (($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id)) {
                                 c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
                             }
                             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.<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_authnet_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_authnet_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" => $authnet["__error"], "error" => true);
                         }
                     } else {
                         $global_response = array("response" => $_authnet["__error"], "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_authnet_utilities::authnet_start_time($period1) : c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period3);
                         // Or next billing cycle.
                         $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"] . "~" . $cost_calculations["cur"];
                         if (!($_authnet = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                             $_authnet["x_type"] = "AUTH_CAPTURE";
                             $_authnet["x_method"] = "CC";
                             $_authnet["x_email"] = $post_vars["email"];
                             $_authnet["x_first_name"] = $post_vars["first_name"];
                             $_authnet["x_last_name"] = $post_vars["last_name"];
                             $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                             $_authnet["x_invoice_num"] = "s2-" . uniqid();
                             $_authnet["x_description"] = $cost_calculations["desc"];
                             $_authnet["s2_initial_payment"] = "1";
                             // Initial.
                             $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
                             if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $_authnet["x_tax"] = $cost_calculations["trial_tax"];
                                 $_authnet["x_amount"] = $cost_calculations["trial_total"];
                                 $_authnet["x_currency_code"] = $cost_calculations["cur"];
                             } else {
                                 $_authnet["x_tax"] = $cost_calculations["tax"];
                                 $_authnet["x_amount"] = $cost_calculations["total"];
                                 $_authnet["x_currency_code"] = $cost_calculations["cur"];
                             }
                             $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $_authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                             $_authnet["x_card_code"] = $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"]))
                             #		$_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                             #	else // Otherwise, we assume they provided an issue number instead.
                             #		$_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                             $_authnet["x_address"] = $post_vars["street"];
                             $_authnet["x_city"] = $post_vars["city"];
                             $_authnet["x_state"] = $post_vars["state"];
                             $_authnet["x_country"] = $post_vars["country"];
                             $_authnet["x_zip"] = $post_vars["zip"];
                         }
                         if (!($authnet = array())) {
                             $authnet["x_method"] = "create";
                             $authnet["x_email"] = $post_vars["email"];
                             $authnet["x_first_name"] = $post_vars["first_name"];
                             $authnet["x_last_name"] = $post_vars["last_name"];
                             $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                             $authnet["x_invoice_num"] = $_authnet ? $_authnet["x_invoice_num"] : "s2-" . uniqid();
                             $authnet["x_description"] = $cost_calculations["desc"];
                             $authnet["x_description"] .= " ((" . $reference . "))";
                             $authnet["x_amount"] = $cost_calculations["total"];
                             $authnet["x_currency_code"] = $cost_calculations["cur"];
                             $authnet["x_start_date"] = date("Y-m-d", $start_time);
                             $authnet["x_unit"] = "days";
                             // Always calculated in days.
                             $authnet["x_length"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
                             $authnet["x_total_occurrences"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "9999" : "1";
                             $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                             $authnet["x_card_code"] = $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"]))
                             #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                             #	else // Otherwise, we assume they provided an issue number instead.
                             #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                             $authnet["x_address"] = $post_vars["street"];
                             $authnet["x_city"] = $post_vars["city"];
                             $authnet["x_state"] = $post_vars["state"];
                             $authnet["x_country"] = $post_vars["country"];
                             $authnet["x_zip"] = $post_vars["zip"];
                         }
                         if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || !$_authnet || ($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])) {
                             if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")) {
                                 // $authnet["response_reason_code"] === "E00018" ... Card expires before start time.
                                 if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0) {
                                     $new__txn_id = $new__subscr_id = strtoupper('free-' . uniqid());
                                 } else {
                                     $new__txn_id = $_authnet && !empty($_authnet["transaction_id"]) ? $_authnet["transaction_id"] : false;
                                     $new__subscr_id = $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018" ? $new__txn_id : $authnet["subscription_id"];
                                 }
                                 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["s2member_paypal_proxy"] = "authnet";
                                     $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"];
                                 }
                                 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("authnet");
                                     // 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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                                         if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                             update_user_option($new__user_id, "s2member_auto_eot_time", $start_time);
                                         }
                                         $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_authnet_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_authnet_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, 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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                                         if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                             update_user_option($new__user_id, "s2member_auto_eot_time", $start_time);
                                         }
                                         $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_authnet_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_authnet_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, 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" => $authnet["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => $_authnet["__error"], "error" => true);
                         }
                     } else {
                         if (!$use_recurring_profile && 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 (!($authnet = array())) {
                                 $authnet["x_type"] = "AUTH_CAPTURE";
                                 $authnet["x_method"] = "CC";
                                 $authnet["x_email"] = $user->user_email;
                                 $authnet["x_first_name"] = $post_vars["first_name"];
                                 $authnet["x_last_name"] = $post_vars["last_name"];
                                 $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                                 $authnet["x_invoice_num"] = "s2-" . uniqid();
                                 $authnet["x_description"] = $cost_calculations["desc"];
                                 $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                                 $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                                 $authnet["x_tax"] = $cost_calculations["tax"];
                                 $authnet["x_amount"] = $cost_calculations["total"];
                                 $authnet["x_currency_code"] = $cost_calculations["cur"];
                                 $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                 $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                                 $authnet["x_card_code"] = $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"]))
                                 #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                 #	else // Otherwise, we assume they provided an issue number instead.
                                 #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                                 $authnet["x_address"] = $post_vars["street"];
                                 $authnet["x_city"] = $post_vars["city"];
                                 $authnet["x_state"] = $post_vars["state"];
                                 $authnet["x_country"] = $post_vars["country"];
                                 $authnet["x_zip"] = $post_vars["zip"];
                             }
                             if ($cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                                 $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");
                                 if ($cost_calculations["total"] <= 0) {
                                     $new__subscr_id = $new__txn_id = strtoupper('free-' . uniqid());
                                 } else {
                                     $new__subscr_id = $new__txn_id = $authnet["transaction_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["s2member_paypal_proxy"] = "authnet";
                                     $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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                                 }
                                 if (!$is_independent_ccaps_sale) {
                                     // Independent?
                                     if (($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id)) {
                                         c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
                                     }
                                 }
                                 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.<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_authnet_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_authnet_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" => $authnet["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && !is_user_logged_in()) {
                                 if (!($authnet = array())) {
                                     $authnet["x_type"] = "AUTH_CAPTURE";
                                     $authnet["x_method"] = "CC";
                                     $authnet["x_email"] = $post_vars["email"];
                                     $authnet["x_first_name"] = $post_vars["first_name"];
                                     $authnet["x_last_name"] = $post_vars["last_name"];
                                     $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                                     $authnet["x_invoice_num"] = "s2-" . uniqid();
                                     $authnet["x_description"] = $cost_calculations["desc"];
                                     $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                                     $authnet["x_tax"] = $cost_calculations["tax"];
                                     $authnet["x_amount"] = $cost_calculations["total"];
                                     $authnet["x_currency_code"] = $cost_calculations["cur"];
                                     $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                                     $authnet["x_card_code"] = $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"]))
                                     #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                     #	else // Otherwise, we assume they provided an issue number instead.
                                     #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                                     $authnet["x_address"] = $post_vars["street"];
                                     $authnet["x_city"] = $post_vars["city"];
                                     $authnet["x_state"] = $post_vars["state"];
                                     $authnet["x_country"] = $post_vars["country"];
                                     $authnet["x_zip"] = $post_vars["zip"];
                                 }
                                 if ($cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                                     if ($cost_calculations["total"] <= 0) {
                                         $new__subscr_id = $new__txn_id = strtoupper('free-' . uniqid());
                                     } else {
                                         $new__subscr_id = $new__txn_id = $authnet["transaction_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["s2member_paypal_proxy"] = "authnet";
                                         $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"];
                                     }
                                     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("authnet");
                                         // 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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $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_authnet_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_authnet_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, 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_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $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_authnet_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_authnet_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, 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" => $authnet["__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;
             }
         }
     }
 }
 /**
  * Validates the configuration of the current form.
  *
  * Free Registration Forms do NOT require API Credentials.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @param array $attr An array of Pro-Form Attributes.
  * @return null|array Null if there are no errors, else a response array.
  */
 public static function paypal_form_attr_validation_errors($attr = FALSE)
 {
     if (!($response = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors($attr)) || !empty($attr["register"])) {
         if ($attr["cancel"]) {
             if (!is_user_logged_in()) {
                 $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to cancel your account.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
             } else {
                 if (!is_object($user = wp_get_current_user()) || !($user_id = $user->ID) || !($subscr_id = get_user_option("s2member_subscr_id", $user_id))) {
                     $response = array("response" => _x('Nothing to cancel. You\'re NOT a paid Member.', "s2member-front", "s2member"), "error" => true);
                 } else {
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"]) {
                         if (!($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id))) {
                             $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
                         } else {
                             if (!empty($paypal["STATUS"]) && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                 $response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                             } else {
                                 if (empty($paypal["STATUS"]) || !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                     $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
                                 }
                             }
                         }
                     } else {
                         if (is_array($paypal = array("PROFILEID" => $subscr_id, "METHOD" => "GetRecurringPaymentsProfileDetails"))) {
                             if (!($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) || !empty($paypal["__error"])) {
                                 if ($paypal && !empty($paypal["__error"]) && !empty($paypal["L_ERRORCODE0"]) && $paypal["L_ERRORCODE0"] === "11592") {
                                     $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 {
                                     $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
                                 }
                             } else {
                                 if (!empty($paypal["STATUS"]) && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     if (empty($paypal["STATUS"]) || !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                         $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($attr["update"]) {
                 if (!is_user_logged_in()) {
                     $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to update your billing information.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
                 } else {
                     if (!is_object($user = wp_get_current_user()) || !($user_id = $user->ID) || !($subscr_id = get_user_option("s2member_subscr_id", $user_id))) {
                         $response = array("response" => _x('Nothing to update. You\'re NOT a paid Member.', "s2member-front", "s2member"), "error" => true);
                     } else {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"]) {
                             if (!($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id))) {
                                 $response = array("response" => _x('Nothing to update. 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 {
                                 if (!empty($paypal["TENDER"]) && strtoupper($paypal["TENDER"]) === "P") {
                                     $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                 } else {
                                     if (!empty($paypal["STATUS"]) && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                         $response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                     } else {
                                         if (empty($paypal["STATUS"]) || !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                             $response = array("response" => _x('Nothing to update. 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 {
                             if (is_array($paypal = array("PROFILEID" => $subscr_id, "METHOD" => "GetRecurringPaymentsProfileDetails"))) {
                                 if (!($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) || !empty($paypal["__error"]) || empty($paypal["ACCT"]) || strlen($paypal["ACCT"]) !== 4) {
                                     if ($paypal && empty($paypal["__error"]) && (empty($paypal["ACCT"]) || strlen($paypal["ACCT"]) !== 4)) {
                                         $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                     } else {
                                         if ($paypal && !empty($paypal["__error"]) && !empty($paypal["L_ERRORCODE0"]) && $paypal["L_ERRORCODE0"] === "11592") {
                                             $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                         } else {
                                             $response = array("response" => _x('Nothing to update. 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 {
                                     if (!empty($paypal["STATUS"]) && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                         $response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                     } else {
                                         if (empty($paypal["STATUS"]) || !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                             $response = array("response" => _x('Nothing to update. 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 {
                 if ($attr["register"]) {
                     if (!is_string($attr["level"]) || !is_numeric($attr["level"])) {
                         $response = array("response" => sprintf(_x('Invalid form configuration. Missing "level" attribute. Membership Level. Must be numeric [0-%s].', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
                     } else {
                         if ($attr["level"] < 0 || $attr["level"] > $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) {
                             $response = array("response" => sprintf(_x('Invalid form configuration. Invalid "level" attribute. Membership Level. Must be numeric [0-%s].', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
                         } else {
                             if ($attr["ccaps"] && (!is_string($attr["ccaps"]) || preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) && !preg_match("/^([a-z_0-9,]+)\$/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"]))))) {
                                 $response = array("response" => _x('Invalid form configuration. Invalid "ccaps" attribute. Custom Capabilities. When provided, must be all lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
                             } else {
                                 if ($attr["tp"] && (!is_string($attr["tp"]) || !is_numeric($attr["tp"]))) {
                                     $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                 } else {
                                     if ($attr["tp"] && $attr["tp"] < 1) {
                                         $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                     } else {
                                         if ($attr["tp"] && (!$attr["tt"] || !is_string($attr["tt"]))) {
                                             $response = array("response" => _x('Invalid form configuration. Missing "tt" attribute. The Trial Term. When "tp" is provided, "tt" (Trial Term) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
                                         } else {
                                             if ($attr["tp"] && !preg_match("/[DWMY]/", $attr["tt"])) {
                                                 $response = array("response" => _x('Invalid form configuration. Invalid "tt" attribute. The Trial Term. When "tp" is provided, "tt" (Trial Term) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
                                             } else {
                                                 if ($attr["custom"] && (!is_string($attr["custom"]) || !preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $attr["custom"]))) {
                                                     $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. When provided, must start with your domain name.', "s2member-admin", "s2member-admin"), "error" => true);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     if ($attr["sp"]) {
                         if (!$attr["ids"] || !is_string($attr["ids"])) {
                             $response = array("response" => _x('Invalid form configuration. Missing "ids" attribute. Must contain comma-delimited Post/Page IDs.', "s2member-admin", "s2member"), "error" => true);
                         } else {
                             if (!preg_match("/^([0-9,]+)\$/", $attr["ids"])) {
                                 $response = array("response" => _x('Invalid form configuration. Invalid "ids" attribute. Must contain comma-delimited Post/Page IDs. Must contain [0-9,] only.', "s2member-admin", "s2member"), "error" => true);
                             } else {
                                 if (!$attr["exp"] || !is_string($attr["exp"])) {
                                     $response = array("response" => _x('Invalid form configuration. Missing "exp" attribute. Specific Post/Page Expiration (in hours). Must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                 } else {
                                     if (!is_numeric($attr["exp"])) {
                                         $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration (in hours). Must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                     } else {
                                         if ($attr["exp"] < 1) {
                                             $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration (in hours). Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                         } else {
                                             if ($attr["exp"] > 438291) {
                                                 $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration (in hours). Must be <= 438291.', "s2member-admin", "s2member"), "error" => true);
                                             } else {
                                                 if (!$attr["sp_ids_exp"] || !is_string($attr["sp_ids_exp"])) {
                                                     $response = array("response" => _x('Invalid form configuration. Missing "sp_ids_exp" internal attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
                                                 } else {
                                                     if (!preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $attr["sp_ids_exp"])) {
                                                         $response = array("response" => _x('Invalid form configuration. Invalid "sp_ids_exp" internal attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
                                                     } else {
                                                         if (!$attr["desc"] || !is_string($attr["desc"])) {
                                                             $response = array("response" => _x('Invalid form configuration. Missing "desc" attribute. Please provide a Description for this form.', "s2member-admin", "s2member"), "error" => true);
                                                         } else {
                                                             if (strlen($attr["desc"]) > 100) {
                                                                 $response = array("response" => _x('Invalid form configuration. Your "desc" (Description) attribute must be <= 100 characters long.', "s2member-admin", "s2member"), "error" => true);
                                                             } else {
                                                                 if (!$attr["custom"] || !is_string($attr["custom"])) {
                                                                     $response = array("response" => _x('Invalid form configuration. Missing "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
                                                                 } else {
                                                                     if (!preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $attr["custom"])) {
                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
                                                                     } else {
                                                                         if (!$attr["cc"] || !is_string($attr["cc"])) {
                                                                             $response = array("response" => _x('Invalid form configuration. Missing "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
                                                                         } else {
                                                                             if (strlen($attr["cc"]) !== 3) {
                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
                                                                             } else {
                                                                                 if (!strlen($attr["dg"]) || !is_string($attr["dg"])) {
                                                                                     $response = array("response" => _x('Invalid form configuration. Missing "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
                                                                                 } else {
                                                                                     if ($attr["dg"] < 0 || $attr["dg"] > 1) {
                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
                                                                                     } else {
                                                                                         if (!strlen($attr["ns"]) || !is_string($attr["ns"])) {
                                                                                             $response = array("response" => _x('Invalid form configuration. Missing "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
                                                                                         } else {
                                                                                             if ($attr["ns"] < 0 || $attr["ns"] > 2) {
                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
                                                                                             } else {
                                                                                                 if ($attr["dg"] && $attr["ns"] !== "1") {
                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be 1 with "dg" (digital) items.', "s2member-admin", "s2member"), "error" => true);
                                                                                                 } else {
                                                                                                     if ($attr["lc"] && strlen($attr["lc"]) !== 2) {
                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "lc" attribute. Locale Code. When provided, must be a 2 character country code.', "s2member-admin", "s2member"), "error" => true);
                                                                                                     } else {
                                                                                                         if (!strlen($attr["ra"]) || !is_string($attr["ra"])) {
                                                                                                             $response = array("response" => _x('Invalid form configuration. Missing "ra" attribute. The Regular Amount. Must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                         } else {
                                                                                                             if (!is_numeric($attr["ra"])) {
                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                             } else {
                                                                                                                 if ($attr["ra"] < 0.0) {
                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                 } else {
                                                                                                                     if ($attr["ra"] > 10000.0 && strtoupper($attr["cc"]) === "USD") {
                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($attr["modify"] && !is_user_logged_in()) {
                             $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">login</a> to update your billing plan.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
                         } else {
                             if ($attr["level"] === "*" && !is_user_logged_in()) {
                                 $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">login</a> before making this purchase.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
                             } else {
                                 if ((!$attr["level"] || !is_string($attr["level"]) || !is_numeric($attr["level"])) && $attr["level"] !== "*") {
                                     $response = array("response" => sprintf(_x('Invalid form configuration. Missing "level" attribute. Membership Level. Must be numeric [1-%s], or an asterisk (*).', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
                                 } else {
                                     if (($attr["level"] < 1 || $attr["level"] > $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) && $attr["level"] !== "*") {
                                         $response = array("response" => sprintf(_x('Invalid form configuration. Invalid "level" attribute. Membership Level. Must be numeric [1-%s], or an asterisk (*).', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
                                     } else {
                                         if ($attr["ccaps"] && (!is_string($attr["ccaps"]) || preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) && !preg_match("/^([a-z_0-9,]+)\$/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"]))))) {
                                             $response = array("response" => _x('Invalid form configuration. Invalid "ccaps" attribute. Custom Capabilities. When provided, must be all lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
                                         } else {
                                             if ($attr["level"] === "*" && (!is_string($attr["ccaps"]) || !preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) || !preg_match("/^([a-z_0-9,]+)\$/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $attr["ccaps"]))))) {
                                                 $response = array("response" => _x('Invalid form configuration. Missing or invalid "ccaps" attribute. When "level" is "*" for (Independent Custom Capabilities), "ccaps" is required. All lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
                                             } else {
                                                 if (!$attr["desc"] || !is_string($attr["desc"])) {
                                                     $response = array("response" => _x('Invalid form configuration. Missing "desc" attribute. Please provide a Description for this form.', "s2member-admin", "s2member"), "error" => true);
                                                 } else {
                                                     if (strlen($attr["desc"]) > 100) {
                                                         $response = array("response" => _x('Invalid form configuration. Your "desc" (Description) attribute must be <= 100 characters long.', "s2member-admin", "s2member"), "error" => true);
                                                     } else {
                                                         if (!$attr["custom"] || !is_string($attr["custom"])) {
                                                             $response = array("response" => _x('Invalid form configuration. Missing "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
                                                         } else {
                                                             if (!preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $attr["custom"])) {
                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. Must start with matching domain.', "s2member-admin", "s2member"), "error" => true);
                                                             } else {
                                                                 if (!$attr["cc"] || !is_string($attr["cc"])) {
                                                                     $response = array("response" => _x('Invalid form configuration. Missing "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
                                                                 } else {
                                                                     if (strlen($attr["cc"]) !== 3) {
                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
                                                                     } else {
                                                                         if (!strlen($attr["dg"]) || !is_string($attr["dg"])) {
                                                                             $response = array("response" => _x('Invalid form configuration. Missing "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
                                                                         } else {
                                                                             if ($attr["dg"] < 0 || $attr["dg"] > 1) {
                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
                                                                             } else {
                                                                                 if (!strlen($attr["ns"]) || !is_string($attr["ns"])) {
                                                                                     $response = array("response" => _x('Invalid form configuration. Missing "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
                                                                                 } else {
                                                                                     if ($attr["ns"] < 0 || $attr["ns"] > 2) {
                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
                                                                                     } else {
                                                                                         if ($attr["dg"] && $attr["ns"] !== "1") {
                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be 1 with "dg" (digital) items.', "s2member-admin", "s2member"), "error" => true);
                                                                                         } else {
                                                                                             if ($attr["lc"] && strlen($attr["lc"]) !== 2) {
                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "lc" attribute. Locale Code. When provided, must be a 2 character country code.', "s2member-admin", "s2member"), "error" => true);
                                                                                             } else {
                                                                                                 if ($attr["tp"] && (!is_string($attr["tp"]) || !is_numeric($attr["tp"]))) {
                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                 } else {
                                                                                                     if ($attr["tp"] && $attr["tp"] < 1) {
                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                     } else {
                                                                                                         if ($attr["tp"] && (!$attr["tt"] || !is_string($attr["tt"]))) {
                                                                                                             $response = array("response" => _x('Invalid form configuration. Missing "tt" attribute. The Trial Term. When "tp" is provided, "tt" (Trial Term) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
                                                                                                         } else {
                                                                                                             if ($attr["tp"] && !preg_match("/[DWMY]/", $attr["tt"])) {
                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "tt" attribute. The Trial Term. When "tp" is provided, "tt" (Trial Term) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
                                                                                                             } else {
                                                                                                                 if ($attr["tp"] && $attr["ta"] && !is_numeric($attr["ta"])) {
                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                 } else {
                                                                                                                     if ($attr["tp"] && $attr["ta"] && $attr["ta"] < 0.0) {
                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                     } else {
                                                                                                                         if ($attr["tp"] && $attr["ta"] && $attr["ta"] > 10000.0 && strtoupper($attr["cc"]) === "USD") {
                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                         } else {
                                                                                                                             if (!$attr["rp"] || !is_string($attr["rp"])) {
                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Missing "rp" attribute. The Regular Period. Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                             } else {
                                                                                                                                 if (!is_numeric($attr["rp"])) {
                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "rp" attribute. The Regular Period. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                 } else {
                                                                                                                                     if ($attr["rp"] < 1) {
                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "rp" attribute. The Regular Period. Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                     } else {
                                                                                                                                         if (!$attr["rt"] || !is_string($attr["rt"])) {
                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Missing "rt" attribute. The Regular Term. Must be one of D,W,M,Y,L.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                         } else {
                                                                                                                                             if (!preg_match("/[DWMYL]/", $attr["rt"])) {
                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "rt" attribute. The Regular Term. Must be one of D,W,M,Y,L.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                             } else {
                                                                                                                                                 if ($attr["rt"] === "D" && $attr["rp"] > 365 && $attr["rr"] !== "BN") {
                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" (Regular Term) attribute is "D", "rp" (Regular Period) > 365, and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                 } else {
                                                                                                                                                     if ($attr["rt"] === "W" && $attr["rp"] > 52 && $attr["rr"] !== "BN") {
                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" (Regular Term) attribute is "W", "rp" (Regular Period) > 52, and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                     } else {
                                                                                                                                                         if ($attr["rt"] === "M" && $attr["rp"] > 12 && $attr["rr"] !== "BN") {
                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" (Regular Term) attribute is "M", "rp" (Regular Period) > 12, and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                         } else {
                                                                                                                                                             if ($attr["rr"] !== "BN" && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"] && !in_array($attr["rp"] . "-" . $attr["rt"], array("1-D", "1-W", "2-W", "1-M", "3-M", "6-M", "1-Y"), TRUE)) {
                                                                                                                                                                 // We allow daily here in case Payflow begins to support this in the future.
                                                                                                                                                                 $response = array("response" => _x('Invalid Payflow form configuration. Invalid "rt, rp, rr" attributes. Payflow supports a specific set of recurring intervals. Pro-Forms can be configured to charge: weekly, bi-weekly, monthly, quarterly, semi-yearly or yearly. Any other combination results in this error. This is a Payflow limitation.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                             } else {
                                                                                                                                                                 if ($attr["rt"] === "Y" && $attr["rp"] > 5 && $attr["rr"] !== "BN") {
                                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" (Regular Term) attribute is "Y", "rp" (Regular Period) > 5, and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                 } else {
                                                                                                                                                                     if ($attr["rt"] === "Y" && $attr["rp"] > 1 && $attr["rr"] !== "BN") {
                                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" (Regular Term) attribute is "Y", "rp" (Regular Period) > 1, and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                     } else {
                                                                                                                                                                         if ($attr["rt"] === "L" && $attr["rp"] > 1) {
                                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "rp, rt" attributes. The "rt" (Regular Term) attribute is "L" (Lifetime), and "rp" (Regular Period) > 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                         } else {
                                                                                                                                                                             if ($attr["rt"] === "L" && $attr["rr"] !== "BN") {
                                                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "rt, rr" attributes. The "rt" (Regular Term) attribute is "L" (Lifetime), and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                             } else {
                                                                                                                                                                                 if (!$attr["level_ccaps_eotper"] || !is_string($attr["level_ccaps_eotper"])) {
                                                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Missing "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                 } else {
                                                                                                                                                                                     if ($attr["level"] !== "*" && !preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $attr["level_ccaps_eotper"])) {
                                                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                     } else {
                                                                                                                                                                                         if ($attr["level"] === "*" && !preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $attr["level_ccaps_eotper"])) {
                                                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                         } else {
                                                                                                                                                                                             if (!strlen($attr["ra"]) || !is_string($attr["ra"])) {
                                                                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Missing "ra" attribute. The Regular Amount. Must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                             } else {
                                                                                                                                                                                                 if (!is_numeric($attr["ra"])) {
                                                                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                 } else {
                                                                                                                                                                                                     if ($attr["ra"] < 0.0) {
                                                                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                     } else {
                                                                                                                                                                                                         if ($attr["ra"] > 10000.0 && strtoupper($attr["cc"]) === "USD") {
                                                                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                         } else {
                                                                                                                                                                                                             if ($attr["rr"] && (!is_string($attr["rr"]) || !preg_match("/^([0-1]|BN)\$/", $attr["rr"]))) {
                                                                                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "rr" attribute. Regular Recurring. When provided, must be 0, 1, or BN.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                 if ($attr["rr"] === "BN" && $attr["tp"]) {
                                                                                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "rr, tp" attributes. The "rr" (Regular Recurring) attribute is "BN" (Buy Now), and "tp" (Trial Period) is not "0".', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                     if ($attr["level"] === "*" && $attr["rr"] !== "BN") {
                                                                                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "level, rr" attributes. The "level" (Level) attribute is "*" for (Independent Custom Capabilities), and "rr" is not "BN" (Buy Now).', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                         if ($attr["ra"] && $attr["ta"] === $attr["ra"] && $attr["tp"] === $attr["rp"] && $attr["tt"] === $attr["rt"]) {
                                                                                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "ta, tp, tt" attributes. Trial Period. When provided, these cannot be exactly the same as your "ra, rp, rt" attributes.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                             if ($attr["rrt"] && (!is_string($attr["rrt"]) || !is_numeric($attr["rrt"]))) {
                                                                                                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "rrt" attribute. Recurring Times (fixed). When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                 if ($attr["rrt"] && $attr["rrt"] < 1) {
                                                                                                                                                                                                                                     $response = array("response" => _x('Invalid form configuration. Invalid "rrt" attribute. Recurring Times (fixed). When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                     if ($attr["rrt"] && $attr["rr"] !== "1") {
                                                                                                                                                                                                                                         $response = array("response" => _x('Invalid form configuration. Invalid "rr, rrt" attributes. When "rrt" (Recurring Times) is provided, "rr" (Regular Recurring) must be 1.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                         if (($attr["rr"] === "0" || $attr["rr"] === "1") && (!is_string($attr["rra"]) || !is_numeric($attr["rra"]))) {
                                                                                                                                                                                                                                             $response = array("response" => _x('Invalid form configuration. Invalid "rr, rra" attributes. When "rr" (Regular Recurring) is 0 or 1, "rra" (Recurring Retry Attempts) must be numeric.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                                             if (($attr["rr"] === "0" || $attr["rr"] === "1") && $attr["rra"] < 0) {
                                                                                                                                                                                                                                                 $response = array("response" => _x('Invalid form configuration. Invalid "rr, rra" attributes. When "rr" (Regular Recurring) is 0 or 1, "rra" (Recurring Retry Attempts) must be >= 0.', "s2member-admin", "s2member"), "error" => true);
                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                             }
                                                                                                                                                                                                                         }
                                                                                                                                                                                                                     }
                                                                                                                                                                                                                 }
                                                                                                                                                                                                             }
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                 }
                                                                                                                                                                             }
                                                                                                                                                                         }
                                                                                                                                                                     }
                                                                                                                                                                 }
                                                                                                                                                             }
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                             }
                                                                                                                                         }
                                                                                                                                     }
                                                                                                                                 }
                                                                                                                             }
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return empty($response) ? null : $response;
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Get `period3` from either an array with `PROFILEREFERENCE|rp_invoice_id|period3`, or use an existing string.
  *
  * This will also convert `1 Day`, into `1 D`, and so on.
  * This will also convert `1 SemiMonth`, into `2 W`, and so on.
  * The Regular Period can never be less than 1 day ( `1 D` ).
  *
  * @package s2Member\PayPal
  * @since 3.5
  *
  * @param string|array $array_or_string Either an array of PayPal post vars, or a string.
  * 	If it's a string, we make sure it is a valid `period term` combination.
  * @param string $default Optional. Value if unavailable. Defaults to `1 D`.
  * @return string A `period3` string if possible, or defaults to `1 D`.
  */
 public static function paypal_pro_period3($array_or_string = FALSE, $default = "1 D")
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars());
     unset($__refs, $__v);
     if (is_array($array_or_string) && isset($array_or_string["PROFILENAME"])) {
         $array_or_string["PROFILEREFERENCE"] = $array_or_string["PROFILENAME"];
     }
     if (is_array($array = $array_or_string) && !empty($array["period3"])) {
         $_period3 = trim($array["period3"]);
     } else {
         if (is_array($array = $array_or_string) && (!empty($array["PROFILEREFERENCE"]) || !empty($array["rp_invoice_id"]))) {
             list($_reference, $_domain, $_item_number) = array_map("trim", preg_split("/~/", !empty($array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"], 3));
             list($_start_time, $_period1, $_period3) = array_map("trim", preg_split("/\\:/", $_reference, 3));
         } else {
             if (is_array($array = $array_or_string) && !empty($array["mp_id"]) && ($ipn_signup_var_period3 = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period3", FALSE, $array["mp_id"]))) {
                 $_period3 = trim($ipn_signup_var_period3);
             } else {
                 if (is_string($string = $array_or_string) && !empty($string)) {
                     $_period3 = trim($string);
                 }
             }
         }
     }
     if (!empty($_period3)) {
         list($num, $span) = array_map("trim", preg_split("/ /", $_period3, 2));
         if (strtoupper($span) === "SEMIMONTH" && is_numeric($num) && $num >= 1) {
             $num = "2";
             $span = "W";
         }
         if (strlen($span) !== 1) {
             $span = c_ws_plugin__s2member_paypal_utilities::paypal_std_term($span);
         }
         $span = preg_match("/^[DWMY]\$/i", $span) ? $span : "";
         $num = $span && is_numeric($num) && $num >= 0 ? $num : "";
         $period3 = $num && $span ? $num . " " . strtoupper($span) : $default;
         return apply_filters("ws_plugin__s2member_paypal_pro_period3", $period3, get_defined_vars());
     } else {
         return apply_filters("ws_plugin__s2member_paypal_pro_period3", $default, 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. */
 }
 /**
  * Handles processing of Pro-Forms for Specific Post/Page checkout.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_sp_checkout()
 {
     if (!empty($_POST["s2member_pro_authnet_sp_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-sp-checkout")) {
         $GLOBALS["ws_plugin__s2member_pro_authnet_sp_checkout_response"] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_authnet_sp_checkout_response"];
         // This is a shorter reference.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_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_authnet_sp_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());
         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["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"])) : "";
         if (!c_ws_plugin__s2member_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_authnet_responses::authnet_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__s2member_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cost_calculations = c_ws_plugin__s2member_pro_authnet_utilities::authnet_cost(null, $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
                 if (!($authnet = array())) {
                     $authnet["x_type"] = "AUTH_CAPTURE";
                     $authnet["x_method"] = "CC";
                     $authnet["x_email"] = $post_vars["email"];
                     $authnet["x_first_name"] = $post_vars["first_name"];
                     $authnet["x_last_name"] = $post_vars["last_name"];
                     $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                     $authnet["x_invoice_num"] = "s2-" . uniqid();
                     $authnet["x_description"] = $cost_calculations["desc"];
                     $authnet["s2_invoice"] = $post_vars["attr"]["sp_ids_exp"];
                     $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                     $authnet["x_tax"] = $cost_calculations["tax"];
                     $authnet["x_amount"] = $cost_calculations["total"];
                     $authnet["x_currency_code"] = $cost_calculations["cur"];
                     $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                     $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                     $authnet["x_card_code"] = $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"]))
                     #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                     #	else // Otherwise, we assume they provided an issue number instead.
                     #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                     $authnet["x_address"] = $post_vars["street"];
                     $authnet["x_city"] = $post_vars["city"];
                     $authnet["x_state"] = $post_vars["state"];
                     $authnet["x_country"] = $post_vars["country"];
                     $authnet["x_zip"] = $post_vars["zip"];
                 }
                 if ($cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                     if ($cost_calculations["total"] <= 0) {
                         $new__txn_id = strtoupper('free-' . uniqid());
                     } else {
                         $new__txn_id = $authnet["transaction_id"];
                     }
                     if (!($ipn = array())) {
                         $ipn["txn_type"] = "web_accept";
                         $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"];
                         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"] = "authnet";
                         $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_authnet_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_authnet_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_authnet_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" => $authnet["__error"], "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * s2Member's PayPal IPN handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  *
  * @todo Optimize with ``empty()`` and ``isset()``.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if ((!empty($paypal["txn_type"]) && preg_match("/^new_case\$/i", $paypal["txn_type"]) && !empty($paypal["case_type"]) && preg_match("/^chargeback\$/i", $paypal["case_type"]) || !empty($paypal["payment_status"]) && preg_match("/^(refunded|reversed|reversal)\$/i", $paypal["payment_status"])) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"])) && !empty($paypal["payer_email"]) && !empty($paypal["parent_txn_id"])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             $processing = $during = true;
             // Yes, we ARE processing this.
             /*
             Refunds and chargeback reversals. This is excluded from the processing check.
             In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
             Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
             	If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
             */
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                 foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url) {
                     if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["parent_txn_id"])), $url))) {
                         if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) {
                             if (($url = preg_replace("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_fee"])), $url))) {
                                 if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) {
                                     if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) {
                                         if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) {
                                             if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["ip"])), $url)) {
                                                 if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
             }
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                 $msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Refund/Reversal";
                 $msg .= "\n\n";
                 // Spacing in the message body.
                 $msg .= "parent_txn_id: %%parent_txn_id%%\n";
                 $msg .= "item_number: %%item_number%%\n";
                 $msg .= "item_name: %%item_name%%\n";
                 $msg .= "-amount: %%-amount%%\n";
                 $msg .= "-fee: %%-fee%%\n";
                 $msg .= "first_name: %%first_name%%\n";
                 $msg .= "last_name: %%last_name%%\n";
                 $msg .= "full_name: %%full_name%%\n";
                 $msg .= "payer_email: %%payer_email%%\n";
                 $msg .= "user_ip: %%user_ip%%\n";
                 $msg .= "cv0: %%cv0%%\n";
                 $msg .= "cv1: %%cv1%%\n";
                 $msg .= "cv2: %%cv2%%\n";
                 $msg .= "cv3: %%cv3%%\n";
                 $msg .= "cv4: %%cv4%%\n";
                 $msg .= "cv5: %%cv5%%\n";
                 $msg .= "cv6: %%cv6%%\n";
                 $msg .= "cv7: %%cv7%%\n";
                 $msg .= "cv8: %%cv8%%\n";
                 $msg .= "cv9: %%cv9%%";
                 if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["parent_txn_id"]), $msg))) {
                     if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) {
                         if (($msg = preg_replace("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_fee"]), $msg))) {
                             if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) {
                                 if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) {
                                     if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) {
                                         if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $msg)) {
                                             if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) {
                                                 // Still have a ``$sbj`` and a ``$msg``?
                                                 foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"]) as $recipient) {
                                                     wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_ref_rev_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_ref_rev_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8");
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
             }
             foreach (array_keys(get_defined_vars()) as $__v) {
                 $__refs[$__v] =& ${$__v};
             }
             do_action("ws_plugin__s2member_during_paypal_notify_during_sp_refund_reversal", get_defined_vars());
             unset($__refs, $__v);
         } else {
             $paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
             $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_after_sp_refund_reversal", get_defined_vars());
         unset($__refs, $__v);
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal", false, get_defined_vars());
     }
 }
 /**
  * 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();
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"];
         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_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_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());
         $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());
         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.
         if (!empty($_GET["token"])) {
             delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"]));
         }
         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"]);
                 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_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;
                 if ($use_recurring_profile && $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 (empty($_GET["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal" && ($cost_calculations["trial_total"] > 0 || $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", "s2p-option"), $return_url = $cancel_url);
                     $return_url = add_query_arg("s2p-option", urlencode((string) @$_REQUEST["s2p-option"]), $return_url);
                     $return_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("s2p-option", urlencode((string) @$_REQUEST["s2p-option"]), $cancel_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["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         if ($use_recurring_profile) {
                             $paypal_set_xco["L_BILLINGTYPE0"] = "RecurringPayments";
                             $paypal_set_xco["L_BILLINGAGREEMENTDESCRIPTION0"] = $cost_calculations["desc"];
                             if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["trial_total"];
                             } else {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                             }
                             $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                         } else {
                             $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_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";
                             $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"];
                         $paypal_set_xco = apply_filters('ws_plugin__s2member_pro_paypal_set_xco_vars', $paypal_set_xco, get_defined_vars());
                     }
                     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;
                     } 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);
                             $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())) {
                                 $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;
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 $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 (!empty($_GET["s2member_paypal_xco"]) && $_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["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.
                                             $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["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 $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");
                                 if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0) {
                                     $new__subscr_id = strtoupper('free-' . uniqid());
                                 } else {
                                     $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__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"] = "paypal";
                                     $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_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20)));
                                 }
                                 if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id) && apply_filters("s2member_pro_cancels_old_rp_before_new_rp", TRUE, get_defined_vars())) {
                                     $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                     $paypal["ACTION"] = "Cancel";
                                     c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                 }
                                 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" => _x('<strong>Thank you.</strong> Your account has been updated.', "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 {
                                 $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);
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             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;
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 $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 (!empty($_GET["s2member_paypal_xco"]) && $_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["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.
                                             $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["trial_total"] <= 0 && $cost_calculations["total"] <= 0 || ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 if ($cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0) {
                                     $new__subscr_id = strtoupper('free-' . uniqid());
                                 } else {
                                     $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__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"] = "paypal";
                                     $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"];
                                 }
                                 if (!($create_user = array())) {
                                     $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = @$post_vars["password1"];
                                     $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                     $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                     $_POST["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])) {
                                                 $_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");
                                     $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                     $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                     $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                     $create_user["user_login"] = $post_vars["username"];
                                     $create_user["user_pass"] = c_ws_plugin__s2member_registrations::maybe_custom_pass($post_vars["password1"]);
                                     $create_user["user_email"] = $post_vars["email"];
                                 }
                                 if (!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)) {
                                         if (version_compare(get_bloginfo("version"), "4.3.1", ">=")) {
                                             wp_new_user_notification($new__user_id, null, "admin", $create_user["user_pass"]);
                                         } else {
                                             if (version_compare(get_bloginfo("version"), "4.3", ">=")) {
                                                 wp_new_user_notification($new__user_id, "admin", $create_user["user_pass"]);
                                             } else {
                                                 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(home_url("/?s2member_paypal_notify=1"), $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">log in</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(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 ((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);
                                         if (version_compare(get_bloginfo("version"), "4.3.1", ">=")) {
                                             wp_new_user_notification($new__user_id, null, "both", $create_user["user_pass"]);
                                         } else {
                                             if (version_compare(get_bloginfo("version"), "4.3", ">=")) {
                                                 wp_new_user_notification($new__user_id, "both", $create_user["user_pass"]);
                                             } else {
                                                 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(home_url("/?s2member_paypal_notify=1"), $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(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" => $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 (!empty($_GET["s2member_paypal_xco"]) && $_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";
                                             $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 ($cost_calculations["total"] <= 0 || ($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();
                                         if ($cost_calculations["total"] <= 0) {
                                             $new__subscr_id = $new__txn_id = strtoupper('free-' . uniqid());
                                         } else {
                                             $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["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 (!$is_independent_ccaps_sale) {
                                             if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id) && apply_filters("s2member_pro_cancels_old_rp_before_new_rp", TRUE, get_defined_vars())) {
                                                 $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                                 $paypal["ACTION"] = "Cancel";
                                                 c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                             }
                                         }
                                         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" => _x('<strong>Thank you.</strong> Your account has been updated.', "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 {
                                         $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 (!empty($_GET["s2member_paypal_xco"]) && $_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";
                                             $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
                                                     $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__subscr_id = $new__txn_id = strtoupper('free-' . uniqid());
                                         } else {
                                             $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"] = $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"] = "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"];
                                         }
                                         if (!($create_user = array())) {
                                             $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = @$post_vars["password1"];
                                             $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                             $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                             $_POST["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])) {
                                                         $_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");
                                             $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                             $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                             $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                             $create_user["user_login"] = $post_vars["username"];
                                             $create_user["user_pass"] = c_ws_plugin__s2member_registrations::maybe_custom_pass($post_vars["password1"]);
                                             $create_user["user_email"] = $post_vars["email"];
                                         }
                                         if (!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)) {
                                                 if (version_compare(get_bloginfo("version"), "4.3.1", ">=")) {
                                                     wp_new_user_notification($new__user_id, null, "admin", $create_user["user_pass"]);
                                                 } else {
                                                     if (version_compare(get_bloginfo("version"), "4.3", ">=")) {
                                                         wp_new_user_notification($new__user_id, "admin", $create_user["user_pass"]);
                                                     } else {
                                                         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(home_url("/?s2member_paypal_notify=1"), $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">log in</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(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 ((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);
                                                 if (version_compare(get_bloginfo("version"), "4.3.1", ">=")) {
                                                     wp_new_user_notification($new__user_id, null, "both", $create_user["user_pass"]);
                                                 } else {
                                                     if (version_compare(get_bloginfo("version"), "4.3", ">=")) {
                                                         wp_new_user_notification($new__user_id, "both", $create_user["user_pass"]);
                                                     } else {
                                                         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(home_url("/?s2member_paypal_notify=1"), $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(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" => $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 cancellations.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_cancellation()
 {
     if (!empty($_POST["s2member_pro_authnet_cancellation"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-cancellation")) {
         $GLOBALS["ws_plugin__s2member_pro_authnet_cancellation_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_authnet_cancellation_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_authnet_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $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"];
         /**/
         if (!c_ws_plugin__s2member_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_authnet_responses::authnet_form_submission_validation_errors("cancellation", $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $cur__subscr_id = get_user_option("s2member_subscr_id"))) {
                         if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"]) {
                             if (preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
                                 if (!($ipn = array())) {
                                     /* With Authorize.Net®, we need their IPN signup vars. */
                                     if (is_array($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars())) {
                                         $ipn["txn_type"] = "subscr_cancel";
                                         $ipn["subscr_id"] = $ipn_signup_vars["subscr_id"];
                                         $ipn["custom"] = $ipn_signup_vars["custom"];
                                         /**/
                                         $ipn["period1"] = $ipn_signup_vars["period1"];
                                         $ipn["period3"] = $ipn_signup_vars["period3"];
                                         /**/
                                         $ipn["payer_email"] = $ipn_signup_vars["payer_email"];
                                         $ipn["first_name"] = $ipn_signup_vars["first_name"];
                                         $ipn["last_name"] = $ipn_signup_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = $ipn_signup_vars["option_name1"];
                                         $ipn["option_selection1"] = $ipn_signup_vars["option_selection1"];
                                         /**/
                                         $ipn["option_name2"] = $ipn_signup_vars["option_name2"];
                                         $ipn["option_selection2"] = $ipn_signup_vars["option_selection2"];
                                         /**/
                                         $ipn["item_name"] = $ipn_signup_vars["item_name"];
                                         $ipn["item_number"] = $ipn_signup_vars["item_number"];
                                         /**/
                                         $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));
                                     }
                                 }
                                 /**/
                                 if ($authnet = array("x_method" => "cancel", "x_subscription_id" => $cur__subscr_id)) {
                                     c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
                                     /**/
                                     $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 {
                             $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;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro-Forms for Specific Post/Page checkout.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function stripe_sp_checkout()
 {
     if (!empty($_POST['s2member_pro_stripe_sp_checkout']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_sp_checkout']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-sp-checkout')) {
         $GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_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_stripe_sp_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['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'])) : '';
         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('sp-checkout', $post_vars))) {
                 unset($_POST['s2member_pro_stripe_sp_checkout']['source_token']);
                 // Good one-time only.
                 unset($_POST['s2member_pro_stripe_sp_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(NULL, $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc'], $is_bitcoin);
                 if (!$global_response) {
                     if ($cost_calculations['total'] > 0) {
                         if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(get_current_user_id(), $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))) {
                                 $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'];
                     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'] = '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)));
                     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);
                     if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($post_vars['attr']['ids'], $post_vars['attr']['exp'])) {
                         $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_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 {
                         $global_response = array('response' => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
Beispiel #15
0
 /**
  * Connect to and process DataLink information for ccBill.
  *
  * 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_ccbill_datalink_ipns_per_process");``.
  *
  * @package s2Member\ccBill
  * @since 1.5
  *
  * @attaches-to ``add_action("ws_plugin__s2member_after_auto_eot_system");``
  *
  * @param array $vars Expects an array of defined variables passed in by the Action Hook.
  * @return null
  */
 public static function ccbill_datalink($vars = FALSE)
 {
     global $wpdb;
     global $current_site, $current_blog;
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"]) {
         $mst_time_10m_ago = time() - 6 * 3600 - 600;
         $datalink = "https://datalink.ccbill.com/data/main.cgi";
         if (!($last = get_transient("s2m_" . md5("s2member_pro_ccbill_last_datalink"))) || $last < $mst_time_10m_ago - 86400) {
             $start = $last && $last >= $mst_time_10m_ago - (86400 + 43200) ? $last : $mst_time_10m_ago - 86400;
             $end = $last = $start + 86400 <= $mst_time_10m_ago ? $start + 86400 : $mst_time_10m_ago;
             $dl_types = "REBILL" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_dl_cancellations"] || apply_filters("ws_plugin__s2member_pro_ccbill_datalink_pulls_cancellations", false) ? ",CANCELLATION" : "") . ",EXPIRE,REFUND,CHARGEBACK";
             $qvrs = array("startTime" => date("YmdHis", $start), "endTime" => date("YmdHis", $end), "transactionTypes" => $dl_types, "clientAccnum" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"], "username" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_dl_user"], "password" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_dl_pass"]);
             if (($unprocessed_ipn_lines = trim(c_ws_plugin__s2member_utils_urls::remote($datalink = add_query_arg(urlencode_deep($qvrs), $datalink)))) && !preg_match("/^Error\\:/i", $unprocessed_ipn_lines)) {
                 $ccbill["s2member_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last);
                 set_transient("s2m_" . md5("s2member_pro_ccbill_last_datalink"), $last, 31556926);
                 $ccbill["s2member_log"][] = "Storing new DataLink IPNs into a Transient Queue.";
                 $ccbill["s2member_log"][] = $datalink;
                 $ccbill["s2member_log"][] = $unprocessed_ipn_lines;
                 set_transient("s2m_" . md5("s2member_pro_ccbill_datalink_ipns"), trim(trim(get_transient("s2m_" . md5("s2member_pro_ccbill_datalink_ipns"))) . "\n" . $unprocessed_ipn_lines), 31556926);
             } else {
                 if (!preg_match("/^Error\\:/i", $unprocessed_ipn_lines)) {
                     $ccbill["s2member_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last);
                     set_transient("s2m_" . md5("s2member_pro_ccbill_last_datalink"), $last, 31556926);
                     $ccbill["s2member_log"][] = "No new Datalink IPNs at this time: " . date("D M j, Y g:i:s a T");
                     $ccbill["s2member_log"][] = $datalink;
                     $ccbill["s2member_log"][] = $unprocessed_ipn_lines;
                 } else {
                     $ccbill["s2member_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last);
                     set_transient("s2m_" . md5("s2member_pro_ccbill_last_datalink"), $last, 31556926);
                     $ccbill["s2member_log"][] = "Recording DataLink error at: " . date("D M j, Y g:i:s a T");
                     $ccbill["s2member_log"][] = "Recording server IP address: " . $_SERVER["SERVER_ADDR"];
                     $ccbill["s2member_log"][] = $datalink;
                     $ccbill["s2member_log"][] = $unprocessed_ipn_lines;
                 }
             }
             $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() ? "ccbill-dl-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-dl.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($ccbill, true)) . "\n\n", FILE_APPEND);
                     }
                 }
             }
         } else {
             if ($unprocessed_ipn_lines = trim(get_transient("s2m_" . md5("s2member_pro_ccbill_datalink_ipns")))) {
                 $per_process = apply_filters("ws_plugin__s2member_pro_ccbill_datalink_ipns_per_process", $vars["per_process"], get_defined_vars());
                 foreach ($unprocessed_lines = preg_split("/[\r\n]+/", $unprocessed_ipn_lines) as $line => $unprocessed_line) {
                     unset($ccbill, $processing, $processed, $ipn, $log4, $_log4, $log2, $logs_dir);
                     if (($unprocessed_line = trim($unprocessed_line)) && ($counter = (int) $counter + 1)) {
                         $ccbill["s2member_log"][] = "DataLink IPN processed on: " . date("D M j, Y g:i:s a T");
                         $ccbill["dl_ipn"] = c_ws_plugin__s2member_utils_strings::trim_dq_deep(preg_split("/\",\"/", $unprocessed_line));
                         if (is_array($ccbill["dl_ipn_signup_vars"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(false, $ccbill["dl_ipn"][3]))) {
                             if (preg_match("/^REBILL\$/i", $ccbill["dl_ipn"][0])) {
                                 $ccbill["s2member_log"][] = "ccBill transaction identified as (SUBSCRIPTION PAYMENT).";
                                 $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as txn_type (subscr_payment).";
                                 $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                                 $processing = $processed = true;
                                 $ipn = array();
                                 $ipn["txn_type"] = "subscr_payment";
                                 $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"];
                                 $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"];
                                 $ipn["txn_id"] = $ccbill["dl_ipn"][5];
                                 $ipn["mc_gross"] = number_format($ccbill["dl_ipn"][6], 2, ".", "");
                                 $ipn["mc_currency"] = strtoupper("USD");
                                 $ipn["tax"] = number_format("0.00", 2, ".", "");
                                 $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"];
                                 $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"];
                                 $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"];
                                 $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"];
                                 $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"];
                                 $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"];
                                 $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"];
                                 $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"];
                                 $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"];
                                 $ipn["s2member_paypal_proxy"] = "ccbill";
                                 $ipn["s2member_paypal_proxy_use"] = "standard-emails";
                                 $ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                 c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
                             } else {
                                 if (preg_match("/^CANCELLATION\$/i", $ccbill["dl_ipn"][0])) {
                                     $ccbill["s2member_log"][] = "ccBill transaction identified as (SUBSCRIPTION CANCELLATION).";
                                     $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as txn_type (subscr_cancel).";
                                     $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                                     $processing = $processed = true;
                                     $ipn = array();
                                     $ipn["txn_type"] = "subscr_cancel";
                                     $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"];
                                     $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"];
                                     $ipn["period1"] = $ccbill["dl_ipn_signup_vars"]["period1"];
                                     $ipn["period3"] = $ccbill["dl_ipn_signup_vars"]["period3"];
                                     $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"];
                                     $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"];
                                     $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"];
                                     $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"];
                                     $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"];
                                     $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"];
                                     $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"];
                                     $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"];
                                     $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"];
                                     $ipn["s2member_paypal_proxy"] = "ccbill";
                                     $ipn["s2member_paypal_proxy_use"] = "standard-emails";
                                     $ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                     c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
                                 } else {
                                     if (preg_match("/^EXPIRE\$/i", $ccbill["dl_ipn"][0])) {
                                         $ccbill["s2member_log"][] = "ccBill transaction identified as (SUBSCRIPTION EXPIRATION).";
                                         $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as txn_type (subscr_eot).";
                                         $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                                         $processing = $processed = true;
                                         $ipn = array();
                                         $ipn["txn_type"] = "subscr_eot";
                                         $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"];
                                         $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"];
                                         $ipn["period1"] = $ccbill["dl_ipn_signup_vars"]["period1"];
                                         $ipn["period3"] = $ccbill["dl_ipn_signup_vars"]["period3"];
                                         $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"];
                                         $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"];
                                         $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"];
                                         $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"];
                                         $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"];
                                         $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"];
                                         $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"];
                                         $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"];
                                         $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"];
                                         $ipn["s2member_paypal_proxy"] = "ccbill";
                                         $ipn["s2member_paypal_proxy_use"] = "standard-emails";
                                         $ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
                                     } else {
                                         if (preg_match("/^(REFUND|CHARGEBACK)\$/i", $ccbill["dl_ipn"][0])) {
                                             $ccbill["s2member_log"][] = "ccBill transaction identified as (REFUND|CHARGEBACK).";
                                             $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as payment_status (refunded|reversed).";
                                             $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                                             $processing = $processed = true;
                                             $ipn = array();
                                             $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"];
                                             $ipn["parent_txn_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"];
                                             $ipn["payment_status"] = preg_match("/^CHARGEBACK\$/i", $ccbill["dl_ipn"][0]) ? "reversed" : "refunded";
                                             $ipn["mc_fee"] = "-" . number_format("0.00", 2, ".", "");
                                             $ipn["mc_gross"] = "-" . number_format($ccbill["dl_ipn"][5], 2, ".", "");
                                             $ipn["mc_currency"] = strtoupper("USD");
                                             $ipn["tax"] = "-" . number_format("0.00", 2, ".", "");
                                             $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"];
                                             $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"];
                                             $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"];
                                             $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"];
                                             $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"];
                                             $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"];
                                             $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"];
                                             $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"];
                                             $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"];
                                             $ipn["s2member_paypal_proxy"] = "ccbill";
                                             $ipn["s2member_paypal_proxy_use"] = "standard-emails";
                                             $ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                             c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
                                         } else {
                                             if (!$processed) {
                                                 // Here we add a message to the logs indicating the IPN was ignored; no action taken.
                                                 $ccbill["s2member_log"][] = "Ignoring this DataLink IPN. It does NOT require any action on the part of s2Member.";
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             if (!$processed) {
                                 // Here we add a message to the logs indicating that no IPN vars are available.
                                 $ccbill["s2member_log"][] = "Ignoring this DataLink IPN. No IPN signup vars for Subscr. ID: " . $ccbill["dl_ipn"][3] . ".";
                             }
                         }
                         $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() ? "ccbill-dl-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-dl-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, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($ccbill, true)) . "\n\n", FILE_APPEND);
                                 }
                             }
                         }
                     }
                     unset($unprocessed_lines[$line]);
                     // Remove this line and update the list of unprocessed IPN lines.
                     set_transient("s2m_" . md5("s2member_pro_ccbill_datalink_ipns"), implode("\n", $unprocessed_lines), 31556926);
                     if ($counter >= $per_process) {
                         break;
                     }
                     // Break the loop now.
                 }
             }
         }
     }
     return;
 }
 /**
  * Cancels a Payflow Billing Agreement.
  *
  * @package s2Member\PayPal
  * @since 130510
  *
  * @param string $baid A Billing Agreement ID (aka: BAID).
  * @return boolean True if the agreement was cancelled, else false.
  */
 public static function payflow_cancel_billing_agreement($baid = FALSE)
 {
     $payflow["ACTION"] = "U";
     $payflow["TENDER"] = "P";
     $payflow["BAID"] = $baid;
     $payflow["BA_STATUS"] = "cancel";
     if (($cancellation = c_ws_plugin__s2member_paypal_utilities::paypal_payflow_api_response($payflow)) && empty($cancellation["__error"])) {
         return true;
     }
     return false;
 }
 /**
  * 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"];
         // This is a shorter reference.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"]));
         // And run a Filter.
         $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_paypal_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         $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"];
         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["FIRSTNAME"];
                                     $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"] = $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(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
                                 }
                                 c_ws_plugin__s2member_pro_paypal_utilities::payflow_cancel_profile($paypal["PROFILEID"], $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_business"]))), "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;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
Beispiel #18
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>PayPal 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" autocomplete="off">' . "\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_paypal_ops_page_before_left_sections", get_defined_vars());
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_paypal_account_details", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_paypal_account_details", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="PayPal Account Details">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-paypal-account-details-section">' . "\n";
         echo '<a href="http://www.s2member.com/paypal" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/paypal-logo.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>' . "\n";
         echo '<h3>PayPal Account Details (required, if using PayPal)</h3>' . "\n";
         echo '<p>s2Member integrates with <a href="http://www.s2member.com/paypal" target="_blank" rel="external">PayPal Payments Standard</a>—for businesses. You do not need a PayPal Pro account. You just need to upgrade your Personal PayPal account to a Business status, which is free. A PayPal account can be <a href="http://s2member.com/r/paypal-business-upgrade/" target="_blank" rel="external">upgraded</a> from a Personal account to a Business account by clicking the "Profile" link under your "My Account" tab, selecting "Personal Business Information", and then clicking the "Upgrade Your Account" button. <strong>See also:</strong> This KB article: <a href="http://s2member.com/kb-article/supported-paypal-account-types/" target="_blank" rel="external">PayPal Compatibility (Account Types)</a>.</p>' . "\n";
         echo '<p><em><strong>PayPal API Credentials:</strong> Once you have a PayPal Business account, you\'ll need access to your <a href="http://s2member.com/r/paypal-profile-api-access/" target="_blank" rel="external">PayPal API Credentials</a>. Log into your PayPal account, and navigate to <strong>Profile → API Access (or → Request API Credentials)</strong>. From the available options, please choose "Request API Signature".</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_account_details", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-merchant-id">' . "\n";
         echo 'Your PayPal Merchant 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_paypal_merchant_id" id="ws-plugin--s2member-paypal-merchant-id" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_merchant_id"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → Secure Merchant ID</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-business">' . "\n";
         echo 'Your PayPal EMail Address:' . "\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_paypal_business" id="ws-plugin--s2member-paypal-business" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → Email Accounts</strong>' . "\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">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-api-username">' . "\n";
         echo 'Your PayPal API Username:'******'</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_paypal_api_username" id="ws-plugin--s2member-paypal-api-username" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials)</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-api-password">' . "\n";
         echo 'Your PayPal API Password:'******'</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_paypal_api_password" id="ws-plugin--s2member-paypal-api-password" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials)</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-api-signature">' . "\n";
         echo 'Your PayPal API Signature:' . "\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_paypal_api_signature" id="ws-plugin--s2member-paypal-api-signature" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or  → "Request API Credentials")</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_account_detail_rows", get_defined_vars());
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<table class="form-table" style="margin:0;">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th style="padding-top:0;">' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-sandbox">' . "\n";
         echo 'Developer/Sandbox Testing?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="radio" name="ws_plugin__s2member_paypal_sandbox" id="ws-plugin--s2member-paypal-sandbox-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-paypal-sandbox-0">No</label> &nbsp;&nbsp;&nbsp; <input type="radio" name="ws_plugin__s2member_paypal_sandbox" id="ws-plugin--s2member-paypal-sandbox-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-paypal-sandbox-1">Yes, enable support for Sandbox testing.</label><br />' . "\n";
         echo '<em>Only enable this if you\'ve provided Sandbox credentials above.<br />This puts the API, IPN, PDT and Form/Button Generators all into Sandbox mode.<br />See: <a href="http://s2member.com/r/paypal-developers/" target="_blank" rel="external">PayPal Developers</a></em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-btn-encryption">' . "\n";
         echo 'Enable Button Encryption?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="radio" name="ws_plugin__s2member_paypal_btn_encryption" id="ws-plugin--s2member-paypal-btn-encryption-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_btn_encryption"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-paypal-btn-encryption-0">No</label> &nbsp;&nbsp;&nbsp; <input type="radio" name="ws_plugin__s2member_paypal_btn_encryption" id="ws-plugin--s2member-paypal-btn-encryption-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_btn_encryption"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-paypal-btn-encryption-1">Yes, enable PayPal Button encryption.</label><br />' . "\n";
         echo '<em>If enabled, all of your PayPal Button Shortcodes will produce <em>encrypted</em> PayPal Buttons. This improves security against fraudulent transactions. For extra security, you should update your PayPal account too, under: <strong>My Profile → Website Payment Preferences</strong>. You\'ll want to block all non-encrypted payments. <strong>Note:</strong> this will NOT work until you\'ve supplied s2Member with your PayPal Email Address, and also with your API Username/Password/Signature.</em>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) {
             echo '<tr>' . "\n";
             echo '<th>' . "\n";
             echo '<label for="ws-plugin--s2member-gateway-debug-logs">' . "\n";
             echo 'Enable Logging Routines?' . "\n";
             echo '</label>' . "\n";
             echo '</th>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             echo '<input type="radio" name="ws_plugin__s2member_gateway_debug_logs" id="ws-plugin--s2member-gateway-debug-logs-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-gateway-debug-logs-0">No</label> &nbsp;&nbsp;&nbsp; <input type="radio" name="ws_plugin__s2member_gateway_debug_logs" id="ws-plugin--s2member-gateway-debug-logs-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--s2member-gateway-debug-logs-1">Yes, enable debugging, with API, IPN &amp; Return Page logging.</label><br />' . "\n";
             echo '<em>This enables API, IPN and Return Page logging. The log files are stored here: <code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) . '</code></em><br />' . "\n";
             echo '<em class="ws-menu-page-hilite">If you have any trouble, please review your s2Member log files for problems. See: <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")) . '">Log Viewer</a></em>' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
             echo '<tr>' . "\n";
             echo '<td>' . "\n";
             echo '<div class="info" style="margin-bottom:0;">' . "\n";
             echo '<p style="margin-top:0;"><span>We highly recommend that you enable logging during your initial testing phase. Logs produce lots of useful details that can help in debugging. Logs can help you find issues in your configuration and/or problems during payment processing. See: <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")) . '">Log Files (Debug)</a>.</span></p>' . "\n";
             echo '<p style="margin-bottom:0;"><span class="ws-menu-page-error">However, it is very important to disable logging once you go live. Log files may contain personally identifiable information, credit card numbers, secret API credentials, passwords and/or other sensitive information. We strongly suggest that logging be disabled on a live site (for security reasons).</span></p>' . "\n";
             echo '</div>' . "\n";
             echo '</td>' . "\n";
             echo '</tr>' . "\n";
         }
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<p><em><strong>Sandbox Tip:</strong> If you\'re testing your site through a PayPal Sandbox account, please remember that Email Confirmations from s2Member will not be received after a test purchase. s2Member sends its Confirmation Emails to the PayPal Email Address of the Customer. Since PayPal Sandbox addresses are usually bogus (for testing), you will have to run live transactions before Email Confirmations from s2Member are received. That being said, all other s2Member functionality can be tested through a PayPal Sandbox account. Email Confirmations are the only hang-up.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_account_details_after_sandbox_tip", get_defined_vars());
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_after_paypal_account_details", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_paypal_payflow_account_details", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_paypal_payflow_account_details", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Payflow Account Details">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-paypal-payflow-account-details-section">' . "\n";
         echo '<a href="http://www.s2member.com/paypal" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/paypal-logo.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>' . "\n";
         echo '<h3>Payflow Account Details (required, if using Payflow)</h3>' . "\n";
         echo '<p>Newer PayPal Pro accounts (i.e., PayPal Pro w/ Payflow Edition), come with the Payflow API for Recurring Billing service. If you have a newer PayPal Pro account, and you wish to integrate PayPal\'s Recurring Billing service with s2Member Pro-Forms, you will need to fill in the details here. Providing Payflow API Credentials below, will automatically put s2Member\'s Recurring Billing integration through Pro-Forms into Payflow mode. Just fill in the details below, and you\'re ready to generate Pro-Forms that charge customers on a recurring basis. s2Member will use the Payflow Edition API instead of the older PayPal Pro DPRP service; which is being slowly phased out in favor of Payflow Edition APIs.</p>' . "\n";
         echo '<p><em><strong>Payflow API Credentials:</strong> Once you have a PayPal Pro account, you\'ll need access to your <a href="http://s2member.com/r/paypal-profile-api-access/" target="_blank" rel="external">Payflow API Credentials</a>. Log into your PayPal account, and navigate to <strong>Profile → API Access (or → Request API Credentials)</strong>. From the available options, please choose "Payflow / API Access". You will need the following credentials: Username, Password, Partner, and Vendor.</em></p>' . "\n";
         echo '<p><em><strong>Important Note:</strong> Supplying Payflow API Credentials here does not mean you can bypass other areas of s2Member\'s configuration; i.e., please supply s2Member with all of your PayPal account details. Your PayPal Pro (Payflow Edition) account is configured here, but up above you will need to configure other Account Details also.</em></p>' . "\n";
         echo '<p><strong>See also:</strong> This KB article: <a href="http://s2member.com/kb-article/supported-paypal-account-types/" target="_blank" rel="external">PayPal Account Types</a>.</p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_payflow_account_details", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-payflow-api-username">' . "\n";
         echo 'Your Payflow API Username:'******'</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_paypal_payflow_api_username" id="ws-plugin--s2member-paypal-payflow-api-username" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials) → Payflow API Access</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-payflow-api-password">' . "\n";
         echo 'Your Payflow API Password:'******'</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="password" autocomplete="off" name="ws_plugin__s2member_paypal_payflow_api_password" id="ws-plugin--s2member-paypal-payflow-api-password" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_password"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials) → Payflow API Access</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-payflow-api-partner">' . "\n";
         echo 'Your Payflow API Partner:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" name="ws_plugin__s2member_paypal_payflow_api_partner" id="ws-plugin--s2member-paypal-payflow-api-partner" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_partner"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials) → Payflow API Access</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-payflow-api-vendor">' . "\n";
         echo 'Your Payflow API Vendor:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<input type="text" name="ws_plugin__s2member_paypal_payflow_api_vendor" id="ws-plugin--s2member-paypal-payflow-api-vendor" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_vendor"]) . '" /><br />' . "\n";
         echo 'At PayPal, see: <strong>Profile → API Access (or → Request API Credentials) → Payflow API Access</strong>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_payflow_account_detail_rows", get_defined_vars());
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_after_paypal_payflow_account_details", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_paypal_ipn", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_paypal_ipn", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="PayPal IPN Integration">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-paypal-ipn-section">' . "\n";
         echo '<h3>PayPal IPN / Instant Payment Notifications (required, please enable)</h3>' . "\n";
         echo '<p>Log into your PayPal account and navigate to this section:<br /><strong>Account Profile → Instant Payment Notification Preferences</strong></p>' . "\n";
         echo '<p>Edit your IPN settings &amp; turn IPN Notifications: <strong><code>On</code></strong></p>' . "\n";
         echo '<p>You\'ll need your IPN URL, which is:<br /><code>' . esc_html(home_url("/?s2member_paypal_notify=1")) . '</code></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_ipn", get_defined_vars());
         echo '<h3 style="margin:0;">More Information (<a href="#" onclick="jQuery(\'div#ws-plugin--s2member-paypal-ipn-details\').toggle(); return false;" class="ws-dotted-link">click here</a>)</h3>' . "\n";
         echo '<div id="ws-plugin--s2member-paypal-ipn-details" style="margin-top:10px; display:none;">' . "\n";
         echo '<p><em><strong>Quick Tip:</strong> In addition to the <a href="http://s2member.com/r/paypal-ipn-setup/" target="_blank" rel="external">default IPN settings inside your PayPal account</a>, the IPN URL is also set on a per-transaction basis by the special PayPal Button Code that s2Member provides you with. In other words, if you have multiple sites operating on one PayPal account, that\'s OK. s2Member dynamically sets the IPN URL for each transaction. The result is that the IPN URL configured from within your PayPal account, becomes the default, which is then overwritten on a per-transaction basis. In fact, PayPal recently updated their system to support IPN URL preservation. One PayPal account can handle multiple sites, all using different IPN URLs.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_ipn_after_quick_tip", get_defined_vars());
         echo '<p><em><strong>IPN Communications:</strong> You\'ll be happy to know that s2Member handles cancellations, expirations, failed payments, terminations (e.g., refunds &amp; chargebacks) for you automatically. If you log into your PayPal account and cancel a Member\'s Subscription, or, if the Member logs into their PayPal account and cancels their own Subscription, s2Member will be notified of these important changes and react accordingly through the PayPal IPN service that runs silently behind-the-scene. The PayPal IPN service will notify s2Member whenever a Member\'s payments have been failing, and/or whenever a Member\'s Subscription has expired for any reason. Even refunds &amp; chargeback reversals are supported through the IPN service. If you issue a refund to an unhappy Customer through PayPal, s2Member will be notified, and the account for that Customer will either be demoted to a Free Subscriber, or deleted automatically (based on your configuration). The communication from PayPal → s2Member is seamless.</em></p>' . "\n";
         echo '</div>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h3 style="margin:0;">IPN w/ Proxy Key (<a href="#" onclick="jQuery(\'div#ws-plugin--s2member-paypal-ipn-proxy-details\').toggle(); return false;" class="ws-dotted-link">optional, for 3rd-party integrations</a>)</h3>' . "\n";
         echo '<div id="ws-plugin--s2member-paypal-ipn-proxy-details" style="margin-top:10px; display:none;">' . "\n";
         echo '<p>If you\'re using a 3rd-party application that needs to POST simulated IPN transactions to your s2Member installation, you can use this alternate IPN URL, which includes a Proxy Key. This encrypted Proxy Key verifies incoming data being received by s2Member\'s IPN processor. You can change <em>[proxy-gateway]</em> to whatever you like. The <em>[proxy-gateway]</em> value is required. It will be stored by s2Member as the Customer\'s Paid Subscr. Gateway. Your [proxy-gateway] value will also be reflected in s2Member\'s IPN log.</p>' . "\n";
         echo '<input type="text" autocomplete="off" value="' . format_to_edit(home_url("/?s2member_paypal_notify=1&s2member_paypal_proxy=[proxy-gateway]&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()))) . '" style="width:99%;" />' . "\n";
         echo '<p><em>Any 3rd-party application that is sending IPN transactions to your s2Member installation must include the <code>custom</code> POST variable, and that variable must always start with your installation domain (i.e., custom=<code>' . esc_html($_SERVER["HTTP_HOST"]) . '</code>). In addition, the <code>item_number</code> variable must always match a format that s2Member looks for. Generally speaking, the <code>item_number</code> should be <code>1, 2, 3, or 4</code>, indicating a specific s2Member Level #. However, s2Member also uses some advanced formats in this field. Just to be sure, we suggest creating a PayPal Button with the s2Member Button Generator, and then taking a look at the Full Button Code to see how s2Member expects <code>item_number</code> to be formatted. Other than the aforementioned exceptions, all other POST variables should follow PayPal standards. Please see: <a href="http://www.s2member.com/paypal-ipn-pdt-vars" target="_blank" rel="external">PayPal\'s IPN/PDT reference guide</a> for full documentation.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_ipn_after_proxy", get_defined_vars());
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_after_paypal_ipn", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_paypal_pdt", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_paypal_pdt", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="PayPal PDT/Auto-Return Integration">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-paypal-pdt-section">' . "\n";
         echo '<h3>PayPal PDT Identity Token (required, please enable)</h3>' . "\n";
         echo '<p>Log into your PayPal account and navigate to this section:<br /><strong>Account Profile → Website Payment Preferences</strong></p>' . "\n";
         echo '<p>Turn the Auto-Return feature: <strong><code>On</code></strong></p>' . "\n";
         echo '<p>You\'ll need your <a href="' . esc_attr(home_url("/?s2member_paypal_return=1&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=x-preview")) . '" target="_blank" rel="external">Auto-Return URL</a>, which is:<br /><code>' . esc_html(home_url("/?s2member_paypal_return=1")) . '</code></p>' . "\n";
         echo '<p>You must also enable PDT (Payment Data Transfer): <strong><code>On</code></strong><br /><em>You\'ll be issued an Identity Token that you can enter below.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_pdt", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-paypal-identity-token">' . "\n";
         echo 'PayPal PDT Identity Token:' . "\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_paypal_identity_token" id="ws-plugin--s2member-paypal-identity-token" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]) . '" /><br />' . "\n";
         echo 'Your PDT Identity Token will appear under <strong>Profile → Website Payment Preferences</strong> in your PayPal account.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
         echo '<div class="ws-menu-page-hr"></div>' . "\n";
         echo '<h3 style="margin:0;">More Information (<a href="#" onclick="jQuery(\'div#ws-plugin--s2member-paypal-pdt-details\').toggle(); return false;" class="ws-dotted-link">click here</a>)</h3>' . "\n";
         echo '<div id="ws-plugin--s2member-paypal-pdt-details" style="margin-top:10px; display:none;">' . "\n";
         echo '<p><em><strong>Quick Tip:</strong> In addition to the <a href="http://s2member.com/r/paypal-pdt-setup/" target="_blank" rel="external">default Auto-Return/PDT configuration inside your PayPal account</a>, the Auto-Return URL is also set on a per-transaction basis from within the special PayPal Button Code that s2Member provides you with. In other words, if you have multiple sites operating on one PayPal account, that\'s OK. s2Member sets the Auto-Return URL (dynamically) for each transaction. The result is that the Auto-Return URL configured from within your PayPal account becomes the default, which is then overwritten on a per-transaction basis by the s2Member software.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_pdt_after_quick_tip", get_defined_vars());
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_paypal_pdt_after_more_info", get_defined_vars());
         echo '</div>' . "\n";
         echo '</div>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_after_paypal_pdt", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_signup_confirmation_email", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_signup_confirmation_email", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Signup Confirmation Email (Standard)">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-signup-confirmation-email-section">' . "\n";
         echo '<h3>Signup Confirmation Email (required, but the default works fine)</h3>' . "\n";
         echo '<p>This email is sent to new Customers after they return from a successful signup at PayPal. The <strong>primary</strong> purpose of this email is to provide the Customer with instructions, along with a link to register a Username for their Membership. You may also customize this further by providing details that are specifically geared to your site.</p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_signup_confirmation_email", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-signup-email-recipients">' . "\n";
         echo 'Signup Confirmation Recipients:' . "\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_signup_email_recipients" id="ws-plugin--s2member-signup-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_recipients"]) . '" /><br />' . "\n";
         echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
         echo '<code>"%%full_name%%" &lt;%%payer_email%%&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-signup-email-subject">' . "\n";
         echo 'Signup Confirmation Email Subject:' . "\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_signup_email_subject" id="ws-plugin--s2member-signup-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_subject"]) . '" /><br />' . "\n";
         echo 'Subject Line used in the email sent to a Customer after a successful signup has occurred through PayPal.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-signup-email-message">' . "\n";
         echo 'Signup Confirmation Email Message:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<textarea name="ws_plugin__s2member_signup_email_message" id="ws-plugin--s2member-signup-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_message"]) . '</textarea><br />' . "\n";
         echo 'Message Body used in the email sent to a Customer after a successful signup has occurred through PayPal.<br /><br />' . "\n";
         echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%registration_url%%</code> = The full URL (generated by s2Member) where the Customer can get registered.</li>' . "\n";
         echo '<li><code>%%subscr_id%%</code> = The PayPal Subscription ID, which remains constant throughout any &amp; all future payments. [ <a href="#" onclick="alert(\'There is one exception. If you are selling Lifetime or Fixed-Term (non-recurring) access, using Buy Now functionality; the %%subscr_id%% is actually set to the Transaction ID for the purchase. PayPal does not provide a specific Subscription ID for Buy Now purchases. Since Lifetime &amp; Fixed-Term Subscriptions are NOT recurring (i.e., there is only ONE payment), using the Transaction ID as the Subscription ID is a graceful way to deal with this minor conflict.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%currency%%</code> = Three-character currency code (uppercase); e.g., <code>USD</code></li>' . "\n";
         echo '<li><code>%%currency_symbol%%</code> = Currency code symbol; e.g., <code>$</code></li>' . "\n";
         echo '<li><code>%%initial%%</code> = The Initial Fee charged during signup. If you offered a 100% Free Trial, this will be <code>0</code>. [ <a href="#" onclick="alert(\'This will always represent the amount of money the Customer spent, whenever they initially signed up, no matter what. If a Customer signs up, under the terms of a 100% Free Trial Period, this will be 0.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%regular%%</code> = The Regular Amount of the Subscription. If you offer something 100% free, this will be <code>0</code>. [ <a href="#" onclick="alert(\'This is how much the Subscription costs after an Initial Period expires. If you did NOT offer an Initial Period at a different price, %%initial%% and %%regular%% will be equal to the same thing.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%recurring%%</code> = This is the amount that will be charged on a recurring basis, or <code>0</code> if non-recurring. [ <a href="#" onclick="alert(\'If Recurring Payments have not been required, this will be equal to 0. That being said, %%regular%% &amp; %%recurring%% are usually the same value. This variable can be used in two different ways. You can use it to determine what the Regular Recurring Rate is, or to determine whether the Subscription will recur or not. If it is going to recur, %%recurring%% will be > 0.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%full_name%%</code> = The Full Name (First &amp; Last) of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%user_ip%%</code> = The Customer\'s IP Address, detected during checkout via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n";
         echo '<li><code>%%item_number%%</code> = The Item Number (colon separated <code><em>level:custom_capabilities:fixed term</em></code>) that the Subscription is for.</li>' . "\n";
         echo '<li><code>%%item_name%%</code> = The Item Name (as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number).</li>' . "\n";
         echo '<li><code>%%initial_term%%</code> = This is the term length of the Initial Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%initial_term%% = 1 D (this means 1 Day)\\n%%initial_term%% = 1 W (this means 1 Week)\\n%%initial_term%% = 1 M (this means 1 Month)\\n%%initial_term%% = 1 Y (this means 1 Year)\\n\\nThe Initial Period never recurs, so this only lasts for the term length specified, then it is over.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%initial_cycle%%</code> = This is the <code>%%initial_term%%</code> from above, converted to a cycle representation of: <code><em>X days/weeks/months/years</em></code>.</li>' . "\n";
         echo '<li><code>%%regular_term%%</code> = This is the term length of the Regular Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%regular_term%% = 1 D (this means 1 Day)\\n%%regular_term%% = 1 W (this means 1 Week)\\n%%regular_term%% = 1 M (this means 1 Month)\\n%%regular_term%% = 1 Y (this means 1 Year)\\n%%regular_term%% = 1 L (this means 1 Lifetime)\\n\\nThe Regular Term is usually recurring. So the Regular Term value represents the period (or duration) of each recurring period. If %%recurring%% = 0, then the Regular Term only applies once, because it is not recurring. So if it is not recurring, the value of %%regular_term%% simply represents how long their Membership privileges are going to last after the %%initial_term%% has expired, if there was an Initial Term. The value of this variable ( %%regular_term%% ) will never be empty, it will always be at least: 1 D, meaning 1 day. No exceptions.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%regular_cycle%%</code> = This is the <code>%%regular_term%%</code> from above, converted to a cycle representation of: <code><em>[every] X days/weeks/months/years—OR daily, weekly, bi-weekly, monthly, bi-monthly, quarterly, yearly, or lifetime</em></code>. This is a very useful Replacment Code. Its value is dynamic; depending on term length, recurring status, and period/term lengths configured.</li>' . "\n";
         echo '<li><code>%%recurring/regular_cycle%%</code> = Example (<code>14.95 / Monthly</code>), or ... (<code>0 / non-recurring</code>); depending on the value of <code>%%recurring%%</code>.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n";
         echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n";
         echo '<em>(The campaign (i.e., christmas-promo) could be referenced using <code>%%cv1%%</code>)</em><br />' . "\n";
         echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n";
         echo !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() ? '<div class="ws-menu-page-hr"></div>' . "\n" . '<p style="margin:0;"><strong>PHP Code:</strong> It is also possible to use PHP tags—optional (for developers). If you use PHP tags, please run a test email with <code>&lt;?php print_r(get_defined_vars()); ?&gt;</code>. This will give you a full list of all PHP variables available to you in this email. The <code>$paypal</code> variable is the most important one. It contains all of the <code>$_POST</code> variables received from PayPal\'s IPN service—or from an s2Member Pro-Form integration (e.g., <code>$paypal["item_number"]</code>, <code>$paypal["item_name"]</code>, etc). Please note that all Replacement Codes will be parsed first, and then any PHP tags that you\'ve included. Also, please remember that emails are sent in plain text format.</p>' . "\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_paypal_ops_page_during_left_sections_after_signup_confirmation_email", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_modification_confirmation_email", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_modification_confirmation_email", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Modification Confirmation Email ' . (c_ws_plugin__s2member_utils_conds::pro_is_installed() ? '(Standard/Pro-Form)' : '(Standard)') . '">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-modification-confirmation-email-section">' . "\n";
         echo '<h3>Modification Confirmation Email (required, but the default works fine)</h3>' . "\n";
         echo '<p>This email is sent to existing Users after they complete an upgrade/downgrade (if and when you make this possible). For instance, if a Free Subscriber upgrades to a paid Membership Level, s2Member considers this a Modification (NOT a Signup; a Signup is associated only with someone completely new). The <strong>primary</strong> purpose of this email is to provide the Customer with a confirmation that their account was updated. You may also customize this further by providing details that are specifically geared to your site.</p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_modification_confirmation_email", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-modification-email-recipients">' . "\n";
         echo 'Modification Confirmation Recipients:' . "\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_modification_email_recipients" id="ws-plugin--s2member-modification-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_email_recipients"]) . '" /><br />' . "\n";
         echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
         echo '<code>"%%full_name%%" &lt;%%payer_email%%&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-modification-email-subject">' . "\n";
         echo 'Modification Confirmation Email Subject:' . "\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_modification_email_subject" id="ws-plugin--s2member-modification-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_email_subject"]) . '" /><br />' . "\n";
         echo 'Subject Line used in the email sent to a Customer after a successful modification has occurred through PayPal.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-modification-email-message">' . "\n";
         echo 'Modification Confirmation Email Message:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<textarea name="ws_plugin__s2member_modification_email_message" id="ws-plugin--s2member-modification-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_email_message"]) . '</textarea><br />' . "\n";
         echo 'Message Body used in the email sent to a Customer after a successful modification has occurred through PayPal.<br /><br />' . "\n";
         echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%subscr_id%%</code> = The PayPal Subscription ID, which remains constant throughout any &amp; all future payments. [ <a href="#" onclick="alert(\'There is one exception. If you are selling Lifetime or Fixed-Term (non-recurring) access, using Buy Now functionality; the %%subscr_id%% is actually set to the Transaction ID for the purchase. PayPal does not provide a specific Subscription ID for Buy Now purchases. Since Lifetime &amp; Fixed-Term Subscriptions are NOT recurring (i.e., there is only ONE payment), using the Transaction ID as the Subscription ID is a graceful way to deal with this minor conflict.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%subscr_baid%%</code> = Applicable only with PayPal Pro (Payflow Edition); and only for Express Checkout transactions that require a Billing Agreement. This is the Subscription\'s Billing Agreement ID, which remains constant throughout any &amp; all future payments. [ <a href="#" onclick="alert(\'Applicable only with PayPal Pro (Payflow Edition); and only for Express Checkout transactions that require a Billing Agreement. In all other cases, the %%subscr_baid%% is simply set to the %%subscr_id%% value; i.e., it is a duplicate of %%subscr_id%% in most cases.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%currency%%</code> = Three-character currency code (uppercase); e.g., <code>USD</code></li>' . "\n";
         echo '<li><code>%%currency_symbol%%</code> = Currency code symbol; e.g., <code>$</code></li>' . "\n";
         echo '<li><code>%%initial%%</code> = The Initial Fee. If you offered a 100% Free Trial, this will be <code>0</code>. [ <a href="#" onclick="alert(\'This will always represent the amount of money the Customer spent when they completed checkout, no matter what. Even if that amount is 0. If a Customer upgrades/downgrades under the terms of a 100% Free Trial Period, this will be 0.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%regular%%</code> = The Regular Amount of the Subscription. If you offer something 100% free, this will be <code>0</code>. [ <a href="#" onclick="alert(\'This is how much the Subscription costs after an Initial Period expires. If you did NOT offer an Initial Period at a different price, %%initial%% and %%regular%% will be equal to the same thing.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%recurring%%</code> = This is the amount that will be charged on a recurring basis, or <code>0</code> if non-recurring. [ <a href="#" onclick="alert(\'If Recurring Payments have not been required, this will be equal to 0. That being said, %%regular%% &amp; %%recurring%% are usually the same value. This variable can be used in two different ways. You can use it to determine what the Regular Recurring Rate is, or to determine whether the Subscription will recur or not. If it is going to recur, %%recurring%% will be > 0.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%full_name%%</code> = The Full Name (First &amp; Last) of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased the Membership Subscription.</li>' . "\n";
         echo '<li><code>%%item_number%%</code> = The Item Number (colon separated <code><em>level:custom_capabilities:fixed term</em></code>) that the Subscription is for.</li>' . "\n";
         echo '<li><code>%%item_name%%</code> = The Item Name (as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number).</li>' . "\n";
         echo '<li><code>%%initial_term%%</code> = This is the term length of the Initial Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%initial_term%% = 1 D (this means 1 Day)\\n%%initial_term%% = 1 W (this means 1 Week)\\n%%initial_term%% = 1 M (this means 1 Month)\\n%%initial_term%% = 1 Y (this means 1 Year)\\n\\nThe Initial Period never recurs, so this only lasts for the term length specified, then it is over.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%initial_cycle%%</code> = This is the <code>%%initial_term%%</code> from above, converted to a cycle representation of: <code><em>X days/weeks/months/years</em></code>.</li>' . "\n";
         echo '<li><code>%%regular_term%%</code> = This is the term length of the Regular Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%regular_term%% = 1 D (this means 1 Day)\\n%%regular_term%% = 1 W (this means 1 Week)\\n%%regular_term%% = 1 M (this means 1 Month)\\n%%regular_term%% = 1 Y (this means 1 Year)\\n%%regular_term%% = 1 L (this means 1 Lifetime)\\n\\nThe Regular Term is usually recurring. So the Regular Term value represents the period (or duration) of each recurring period. If %%recurring%% = 0, then the Regular Term only applies once, because it is not recurring. So if it is not recurring, the value of %%regular_term%% simply represents how long their Membership privileges are going to last after the %%initial_term%% has expired, if there was an Initial Term. The value of this variable ( %%regular_term%% ) will never be empty, it will always be at least: 1 D, meaning 1 day. No exceptions.\'); return false;">?</a> ]</li>' . "\n";
         echo '<li><code>%%regular_cycle%%</code> = This is the <code>%%regular_term%%</code> from above, converted to a cycle representation of: <code><em>[every] X days/weeks/months/years—OR daily, weekly, bi-weekly, monthly, bi-monthly, quarterly, yearly, or lifetime</em></code>. This is a very useful Replacment Code. Its value is dynamic; depending on term length, recurring status, and period/term lengths configured.</li>' . "\n";
         echo '<li><code>%%recurring/regular_cycle%%</code> = Example (<code>14.95 / Monthly</code>), or ... (<code>0 / non-recurring</code>); depending on the value of <code>%%recurring%%</code>.</li>' . "\n";
         echo '<li><code>%%user_first_name%%</code> = The First Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_last_name%%</code> = The Last Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_full_name%%</code> = The Full Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_email%%</code> = The Email Address associated with their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_login%%</code> = The Username associated with their account. The Customer created this during registration.</li>' . "\n";
         echo '<li><code>%%user_ip%%</code> = The Customer\'s original IP Address, during checkout/registration via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n";
         echo '<li><code>%%user_id%%</code> = A unique WordPress User ID that references this account in the WordPress database.</li>' . "\n";
         echo '</ul>' . "\n";
         if (c_ws_plugin__s2member_utils_conds::pro_is_installed()) {
             echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro-Forms):</strong>' . "\n";
             echo '<ul class="ws-menu-page-li-margins">' . "\n";
             echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code—if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e., the full Coupon Code).</li>' . "\n";
             echo '<li><code>%%coupon_code%%</code> = A Coupon Code—if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
             echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e., the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
             echo '</ul>' . "\n";
         }
         echo '<strong>Custom Registration/Profile Fields are also supported in this email:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%date_of_birth%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>date_of_birth</code>.</li>' . "\n";
         echo '<li><code>%%street_address%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>street_address</code>.</li>' . "\n";
         echo '<li><code>%%country%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>country</code>.</li>' . "\n";
         echo '<li><em><code>%%etc, etc...%%</code> <strong>see:</strong> s2Member → General Options → Registration/Profile Fields</em>.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n";
         echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n";
         echo '<em>(The campaign (i.e., christmas-promo) could be referenced using <code>%%cv1%%</code>)</em><br />' . "\n";
         echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n";
         echo !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() ? '<div class="ws-menu-page-hr"></div>' . "\n" . '<p style="margin:0;"><strong>PHP Code:</strong> It is also possible to use PHP tags—optional (for developers). If you use PHP tags, please run a test email with <code>&lt;?php print_r(get_defined_vars()); ?&gt;</code>. This will give you a full list of all PHP variables available to you in this email. The <code>$paypal</code> variable is the most important one. It contains all of the <code>$_POST</code> variables received from PayPal\'s IPN service—or from an s2Member Pro-Form integration (e.g., <code>$paypal["item_number"]</code>, <code>$paypal["item_name"]</code>, etc). Please note that all Replacement Codes will be parsed first, and then any PHP tags that you\'ve included. Also, please remember that emails are sent in plain text format.</p>' . "\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_paypal_ops_page_during_left_sections_after_modification_confirmation_email", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_ccap_confirmation_email", c_ws_plugin__s2member_utils_conds::pro_is_installed(), get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_ccap_confirmation_email", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Capability Confirmation Email ' . (c_ws_plugin__s2member_utils_conds::pro_is_installed() ? '(Standard/Pro-Form)' : '(Standard)') . '">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-ccap-confirmation-email-section">' . "\n";
         echo '<h3>Capability Confirmation Email (required, but the default works fine)</h3>' . "\n";
         echo '<p>This email is sent to existing Users after they complete a Buy Now purchase for one or more Custom Capabilities (if and when you make this possible); see: <strong>Dashboard → s2Member → PayPal Buttons/Forms → Capability (Buy Now)</strong>. The <strong>primary</strong> purpose of this email is to provide the Customer with a confirmation that their account was updated. You may also customize this further by providing details that are specifically geared to your site.</p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_ccap_confirmation_email", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-ccap-email-recipients">' . "\n";
         echo 'Capability Confirmation Recipients:' . "\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_ccap_email_recipients" id="ws-plugin--s2member-ccap-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_recipients"]) . '" /><br />' . "\n";
         echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
         echo '<code>"%%full_name%%" &lt;%%payer_email%%&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-ccap-email-subject">' . "\n";
         echo 'Capability Confirmation Email Subject:' . "\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_ccap_email_subject" id="ws-plugin--s2member-ccap-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_subject"]) . '" /><br />' . "\n";
         echo 'Subject Line used in the email sent to a Customer after a purchase is completed through PayPal.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-ccap-email-message">' . "\n";
         echo 'Capability Confirmation Email Message:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<textarea name="ws_plugin__s2member_ccap_email_message" id="ws-plugin--s2member-ccap-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_message"]) . '</textarea><br />' . "\n";
         echo 'Message Body used in the email sent to a Customer after a purchase is completed through PayPal.<br /><br />' . "\n";
         echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%txn_id%%</code> = The PayPal Transaction ID. PayPal assigns a unique identifier for every purchase.</li>' . "\n";
         echo '<li><code>%%currency%%</code> = Three-character currency code (uppercase); e.g., <code>USD</code></li>' . "\n";
         echo '<li><code>%%currency_symbol%%</code> = Currency code symbol; e.g., <code>$</code></li>' . "\n";
         echo '<li><code>%%amount%%</code> = The full Amount that you charged for Custom Capability access.</li>' . "\n";
         echo '<li><code>%%first_name%%</code> = The First Name of the Customer who completed the purchase.</li>' . "\n";
         echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who completed the purchase.</li>' . "\n";
         echo '<li><code>%%full_name%%</code> = The Full Name (First &amp; Last) of the Customer who completed the purchase.</li>' . "\n";
         echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who completed the purchase.</li>' . "\n";
         echo '<li><code>%%item_number%%</code> = The Item Number (colon separated <code><em>*:custom_capabilities</em></code>); where <code>custom_capabilities</code> is a comma-delimited list of the Custom Capabilities they purchased.</li>' . "\n";
         echo '<li><code>%%item_name%%</code> = The Item Name (as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number).</li>' . "\n";
         echo '<li><code>%%user_first_name%%</code> = The First Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_last_name%%</code> = The Last Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_full_name%%</code> = The Full Name listed on their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_email%%</code> = The Email Address associated with their User account. This might be different than what is on file with PayPal.</li>' . "\n";
         echo '<li><code>%%user_login%%</code> = The Username associated with their account. The Customer created this during registration.</li>' . "\n";
         echo '<li><code>%%user_ip%%</code> = The Customer\'s original IP Address, during checkout/registration via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n";
         echo '<li><code>%%user_id%%</code> = A unique WordPress User ID that references this account in the WordPress database.</li>' . "\n";
         echo '</ul>' . "\n";
         if (c_ws_plugin__s2member_utils_conds::pro_is_installed()) {
             echo '<strong>Coupon Replacement Codes (applicable only w/ s2Member Pro-Forms):</strong>' . "\n";
             echo '<ul class="ws-menu-page-li-margins">' . "\n";
             echo '<li><code>%%full_coupon_code%%</code> = A full Coupon Code—if one is accepted by your configuration of s2Member. This may indicate an Affiliate Coupon Code, which will include your Affiliate Suffix Chars too (i.e., the full Coupon Code).</li>' . "\n";
             echo '<li><code>%%coupon_code%%</code> = A Coupon Code—if one is accepted by your configuration of s2Member. This will NOT include any Affiliate Suffix Chars. This indicates the actual Coupon Code accepted by your configuration of s2Member (excluding any Affiliate ID).</li>' . "\n";
             echo '<li><code>%%coupon_affiliate_id%%</code> = This is the end of an Affiliate Coupon Code <em>(i.e., the referring affiliate\'s ID)</em>. This is only applicable if an Affiliate Coupon Code is accepted by your configuration of s2Member.</li>' . "\n";
             echo '</ul>' . "\n";
         }
         echo '<strong>Custom Registration/Profile Fields are also supported in this email:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%date_of_birth%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>date_of_birth</code>.</li>' . "\n";
         echo '<li><code>%%street_address%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>street_address</code>.</li>' . "\n";
         echo '<li><code>%%country%%</code> would be valid; if you have a Custom Registration/Profile Field with the ID <code>country</code>.</li>' . "\n";
         echo '<li><em><code>%%etc, etc...%%</code> <strong>see:</strong> s2Member → General Options → Registration/Profile Fields</em>.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n";
         echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n";
         echo '<em>(The campaign (i.e., christmas-promo) could be referenced using <code>%%cv1%%</code>)</em><br />' . "\n";
         echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n";
         echo !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() ? '<div class="ws-menu-page-hr"></div>' . "\n" . '<p style="margin:0;"><strong>PHP Code:</strong> It is also possible to use PHP tags—optional (for developers). If you use PHP tags, please run a test email with <code>&lt;?php print_r(get_defined_vars()); ?&gt;</code>. This will give you a full list of all PHP variables available to you in this email. The <code>$paypal</code> variable is the most important one. It contains all of the <code>$_POST</code> variables received from PayPal\'s IPN service—or from an s2Member Pro-Form integration (e.g., <code>$paypal["item_number"]</code>, <code>$paypal["item_name"]</code>, etc). Please note that all Replacement Codes will be parsed first, and then any PHP tags that you\'ve included. Also, please remember that emails are sent in plain text format.</p>' . "\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_paypal_ops_page_during_left_sections_after_ccap_confirmation_email", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_sp_confirmation_email", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_sp_confirmation_email", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Specific Post/Page Confirmation Email (Standard)">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-confirmation-email-section">' . "\n";
         echo '<h3>Specific Post/Page Confirmation Email (required, but the default works fine)</h3>' . "\n";
         echo '<p>This email is sent to new Customers after they return from a successful purchase at PayPal, for Specific Post/Page Access. (see: <strong>s2Member → Restriction Options → Specific Post/Page Access</strong>). This is NOT used for Membership sales, only for Specific Post/Page Access. The <strong>primary</strong> purpose of this email is to provide the Customer with instructions, along with a link to access the Specific Post/Page they\'ve purchased access to. If you\'ve created a Specific Post/Page Package (with multiple Posts/Pages bundled together into one transaction), this ONE link (<code>%%sp_access_url%%</code>) will automatically authenticate them for access to ALL of the Posts/Pages included in their transaction. You may customize this email further by providing details that are specifically geared to your site.</p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_sp_confirmation_email", get_defined_vars());
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-sp-email-recipients">' . "\n";
         echo 'Specific Post/Page Confirmation Recipients:' . "\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_sp_email_recipients" id="ws-plugin--s2member-sp-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_email_recipients"]) . '" /><br />' . "\n";
         echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
         echo '<code>"%%full_name%%" &lt;%%payer_email%%&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-sp-email-subject">' . "\n";
         echo 'Specific Post/Page Confirmation Email Subject:' . "\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_sp_email_subject" id="ws-plugin--s2member-sp-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_email_subject"]) . '" /><br />' . "\n";
         echo 'Subject Line used in the email sent to a Customer after a successful purchase has occurred through PayPal, for Specific Post/Page Access.' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-sp-email-message">' . "\n";
         echo 'Specific Post/Page Confirmation Email Message:' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<textarea name="ws_plugin__s2member_sp_email_message" id="ws-plugin--s2member-sp-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_email_message"]) . '</textarea><br />' . "\n";
         echo 'Message Body used in the email sent to a Customer after a successful purchase has occurred through PayPal, for Specific Post/Page Access.<br /><br />' . "\n";
         echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%sp_access_url%%</code> = The full URL (generated by s2Member) where the Customer can gain access.</li>' . "\n";
         echo '<li><code>%%sp_access_exp%%</code> = Human readable expiration for <code>%%sp_access_url%%</code>. Ex: <em>(link expires in <code>%%sp_access_exp%%</code>)</em>.</li>' . "\n";
         echo '<li><code>%%txn_id%%</code> = The PayPal Transaction ID. PayPal assigns a unique identifier for every purchase.</li>' . "\n";
         echo '<li><code>%%currency%%</code> = Three-character currency code (uppercase); e.g., <code>USD</code></li>' . "\n";
         echo '<li><code>%%currency_symbol%%</code> = Currency code symbol; e.g., <code>$</code></li>' . "\n";
         echo '<li><code>%%amount%%</code> = The full Amount that you charged for Specific Post/Page Access.</li>' . "\n";
         echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased Specific Post/Page Access.</li>' . "\n";
         echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased Specific Post/Page Access.</li>' . "\n";
         echo '<li><code>%%full_name%%</code> = The Full Name (First &amp; Last) of the Customer who purchased Specific Post/Page Access.</li>' . "\n";
         echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased Specific Post/Page Access.</li>' . "\n";
         echo '<li><code>%%user_ip%%</code> = The Customer\'s IP Address, detected during checkout via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n";
         echo '<li><code>%%item_number%%</code> = The Item Number. Ex: <code><em>sp:13,24,36:72</em></code> (translates to: <code><em>sp:comma-delimited IDs:expiration hours</em></code>).</li>' . "\n";
         echo '<li><code>%%item_name%%</code> = The Item Name (as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number).</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n";
         echo '<ul class="ws-menu-page-li-margins">' . "\n";
         echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n";
         echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n";
         echo '</ul>' . "\n";
         echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n";
         echo '<em>(The campaign (i.e., christmas-promo) could be referenced using <code>%%cv1%%</code>)</em><br />' . "\n";
         echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n";
         echo !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() ? '<div class="ws-menu-page-hr"></div>' . "\n" . '<p style="margin:0;"><strong>PHP Code:</strong> It is also possible to use PHP tags—optional (for developers). If you use PHP tags, please run a test email with <code>&lt;?php print_r(get_defined_vars()); ?&gt;</code>. This will give you a full list of all PHP variables available to you in this email. The <code>$paypal</code> variable is the most important one. It contains all of the <code>$_POST</code> variables received from PayPal\'s IPN service—or from an s2Member Pro-Form integration (e.g., <code>$paypal["item_number"]</code>, <code>$paypal["item_name"]</code>, etc). Please note that all Replacement Codes will be parsed first, and then any PHP tags that you\'ve included. Also, please remember that emails are sent in plain text format.</p>' . "\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_paypal_ops_page_during_left_sections_after_sp_confirmation_email", get_defined_vars());
     }
     if (apply_filters("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_display_eot_behavior", TRUE, get_defined_vars())) {
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_before_eot_behavior", get_defined_vars());
         echo '<div class="ws-menu-page-group" title="Automatic EOT Behavior">' . "\n";
         echo '<div class="ws-menu-page-section ws-plugin--s2member-eot-behavior-section">' . "\n";
         echo '<h3>PayPal EOT Behavior (required, please choose)</h3>' . "\n";
         echo '<p>EOT = End Of Term. By default, s2Member will demote a paid Member to a Free Subscriber whenever their Subscription term has ended (i.e., expired), been cancelled, refunded, charged back to you, etc. s2Member demotes them to a Free Subscriber, so they will no longer have Member Level Access to your site. However, in some cases, you may prefer to have Customer accounts deleted completely, instead of just being demoted. This is where you choose which method works best for your site. If you don\'t want s2Member to take ANY action at all, you can disable s2Member\'s EOT System temporarily, or even completely. There are also a few other configurable options here, so please read carefully. These options are all very important.</p>' . "\n";
         echo '<p><strong>PayPal IPNs:</strong> The PayPal IPN service will notify s2Member whenever a Member\'s payments have been failing, and/or whenever a Member\'s Subscription has expired for any reason. Even refunds &amp; chargeback reversals are supported through the IPN service. For example, if you issue a refund to an unhappy Customer through PayPal, s2Member will eventually be notified, and the account for that Customer will either be demoted to a Free Subscriber, or deleted automatically (based on your configuration). The communication from PayPal → s2Member is seamless.</p>' . "\n";
         echo '<p><em><strong>Some Hairy Details:</strong> There might be times whenever you notice that a Member\'s Subscription has been cancelled through PayPal... but, s2Member continues allowing the User  access to your site as a paid Member. Please don\'t be confused by this... in 99.9% of these cases, the reason for this is legitimate. s2Member will only remove the User\'s Membership privileges when an EOT (End Of Term) is processed, a refund occurs, a chargeback occurs, or when a cancellation occurs - which would later result in a delayed Auto-EOT by s2Member.</em></p>' . "\n";
         echo '<p><em>s2Member will not process an EOT until the User has completely used up the time they paid for. In other words, if a User signs up for a monthly Subscription on Jan 1st, and then cancels their Subscription on Jan 15th; technically, they should still be allowed to access the site for another 15 days, and then on Feb 1st, the time they paid for has completely elapsed. At that time, s2Member will remove their Membership privileges; by either demoting them to a Free Subscriber, or deleting their account from the system (based on your configuration). s2Member also calculates one extra day (24 hours) into its equation, just to make sure access is not removed sooner than a Customer might expect.</em></p>' . "\n";
         do_action("ws_plugin__s2member_during_paypal_ops_page_during_left_sections_during_eot_behavior", get_defined_vars());
         echo '<p id="ws-plugin--s2member-auto-eot-system-enabled-via-cron"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 2 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) ? '' : ' style="display:none;"') . '>If you\'d like to run s2Member\'s Auto-EOT System through a more traditional Cron Job; instead of through <code>WP-Cron</code>, you will need to configure a Cron Job through your server control panel; provided by your hosting company. Set the Cron Job to run <code>once about every 10 minutes to an hour</code>. You\'ll want to configure an HTTP Cron Job that loads this URL:<br /><code>' . esc_html(home_url("/?s2member_auto_eot_system_via_cron=1")) . '</code></p>' . "\n";
         echo '<table class="form-table">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-auto-eot-system-enabled">' . "\n";
         echo 'Enable s2Member\'s Auto-EOT System?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_auto_eot_system_enabled" id="ws-plugin--s2member-auto-eot-system-enabled">' . "\n";
         // Very advanced conditionals here. If the Auto-EOT System is NOT running, or NOT fully configured, this will indicate that no option is set - as sort of a built-in acknowledgment/warning in the UI panel.
         echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 1 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 2 && (function_exists("wp_cron") && wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] && (function_exists("wp_cron") && wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) ? '<option value=""></option>' . "\n" : '';
         echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 1 && function_exists("wp_cron") && wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule") ? ' selected="selected"' : '') . '>Yes (enable the Auto-EOT System through WP-Cron)</option>' . "\n";
         echo !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() ? '<option value="2"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 2 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) ? ' selected="selected"' : '') . '>Yes (but, I\'ll run it with my own Cron Job)</option>' . "\n" : '';
         echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__s2member_auto_eot_system__schedule")) ? ' selected="selected"' : '') . '>No (disable the Auto-EOT System)</option>' . "\n";
         echo '</select><br />' . "\n";
         echo 'Recommended setting: (<code>Yes / enable via WP-Cron</code>)' . "\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">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-membership-eot-behavior">' . "\n";
         echo 'Membership EOT Behavior (Demote or Delete)?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_membership_eot_behavior" id="ws-plugin--s2member-membership-eot-behavior">' . "\n";
         echo '<option value="demote"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote" ? ' selected="selected"' : '') . '>Demote (convert them to a Free Subscriber)</option>' . "\n";
         echo '<option value="delete"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete" ? ' selected="selected"' : '') . '>Delete (erase their account completely)</option>' . "\n";
         echo '</select>' . "\n";
         echo '</td>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-eots-remove-ccaps">' . "\n";
         echo 'Membership EOTs also Remove all Custom Capabilities?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_eots_remove_ccaps" id="ws-plugin--s2member-eots-remove-ccaps">' . "\n";
         echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eots_remove_ccaps"] ? ' selected="selected"' : '') . '>Yes (an EOT also results in the loss of any Custom Capabilities a User/Member may have)</option>' . "\n";
         echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eots_remove_ccaps"] ? ' selected="selected"' : '') . '>No (an EOT has no impact on any Custom Capabilities a User/Member may have)</option>' . "\n";
         echo '</select><br />' . "\n";
         echo '<em>NOTE: If Refunds/Reversals trigger an Immediate EOT (see setting below); Custom Capabilities will always be removed when/if a Refund or Reversal occurs. In other words, this setting is ignored for Refunds/Reversals (IF they trigger an Immediate EOT—based on your configuration below). If you prefer to review all Refunds/Reversals for yourself, please choose that option below.</em>' . "\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">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-eot-grace-time">' . "\n";
         echo 'EOT Grace Time (in seconds):' . "\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_eot_grace_time" id="ws-plugin--s2member-eot-grace-time" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_grace_time"]) . '" /><br />' . "\n";
         echo '<em>This is represented in seconds. For example, a value of: <code>86400</code> = 1 day. Your EOT Grace Time; is the amount of time you will offer as a grace period (if any). Most site owners will give customers an additional 24 hours of access; just to help avoid any negativity that may result from a customer losing access sooner than they might expect. You can disable EOT Grace Time by setting this to: <code>0</code>. Note: there is NO Grace Time applied when/if a Refund or Reversal occurs. If Refunds/Reversals trigger an Immediate EOT (see setting below); there is never any Grace Time applied in that scenario.</em>' . "\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">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-triggers-immediate-eot">' . "\n";
         echo 'Refunds/Partial Refunds/Reversals (trigger Immediate EOT)?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_triggers_immediate_eot" id="ws-plugin--s2member-triggers-immediate-eot">' . "\n";
         echo '<option value="none"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "none" ? ' selected="selected"' : '') . '>None (I\'ll review these events manually)</option>' . "\n";
         echo '<option value="refunds"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds" ? ' selected="selected"' : '') . '>Full Refunds (full refunds only; ALWAYS trigger an Immediate EOT action)</option>' . "\n";
         echo '<option value="reversals"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals" ? ' selected="selected"' : '') . '>Reversals (chargebacks only; ALWAYS trigger an Immediate EOT action)</option>' . "\n";
         echo '<option value="refunds,reversals"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals" ? ' selected="selected"' : '') . '>Full Refunds, Reversals (these ALWAYS trigger an Immediate EOT action)</option>' . "\n";
         echo '<option value="refunds,partial_refunds,reversals"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,partial_refunds,reversals" ? ' selected="selected"' : '') . '>Full Refunds, Partial Refunds, Reversals (these ALWAYS trigger an Immediate EOT action)</option>' . "\n";
         echo '</select><br />' . "\n";
         echo '<em><strong>Note:</strong> s2Member is not equipped to detect partial refunds against multi-payment Subscriptions reliably. Therefore, all refunds processed against Subscriptions (of any kind) are considered <strong>Partial</strong> Refunds. Full refunds (in the eyes of s2Member) occur only against Buy Now transactions where it is easy for s2Member to see that the refund amount is &gt;= the original Buy Now purchase price (i.e., a Full Refund). <strong>Also Note:</strong> This setting (no matter what you choose) will NOT impact s2Member\'s internal API Notifications for Refund/Reversal events. <a href="#" onclick="alert(\'A Full or Partial Refund; and/or a Reversal Notification will ALWAYS be processed internally by s2Member, even if no action is taken by s2Member in accordance with your configuration here.\\n\\nIn this way, you\\\'ll have the full ability to listen for these events on your own (via API Notifications); if you prefer (optional). For more information, check your Dashboard under: `s2Member → API Notifications → Refunds/Reversals`.\'); return false;">Click here for details</a>.</em>' . "\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">' . "\n";
         echo '<tbody>' . "\n";
         echo '<tr>' . "\n";
         echo '<th>' . "\n";
         echo '<label for="ws-plugin--s2member-eot-time-ext-behavior">' . "\n";
         echo 'Fixed-Term Extensions (Auto-Extend)?' . "\n";
         echo '</label>' . "\n";
         echo '</th>' . "\n";
         echo '</tr>' . "\n";
         echo '<tr>' . "\n";
         echo '<td>' . "\n";
         echo '<select name="ws_plugin__s2member_eot_time_ext_behavior" id="ws-plugin--s2member-eot-time-ext-behavior">' . "\n";
         echo '<option value="extend"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_time_ext_behavior"] === "extend" ? ' selected="selected"' : '') . '>Yes (default, automatically extend any existing EOT Time)</option>' . "\n";
         echo '<option value="reset"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_time_ext_behavior"] === "reset" ? ' selected="selected"' : '') . '>No (do NOT extend; s2Member should reset EOT Time completely)</option>' . "\n";
         echo '</select><br />' . "\n";
         echo '<em>This setting will only affect Buy Now transactions for fixed-term lengths. By default, s2Member will automatically extend any existing EOT Time that a Customer may have. For example, if I buy one year of access, and then I buy another year of access (before my first year is totally used up); I end up with everything I paid you for (now over 1 year of access) if this is set to <code>Yes</code>. If this was set to <code>No</code>, the EOT Time would be reset when I make the second purchase; leaving me with only 1 year of access, starting the date of my second purchase.</em>' . "\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_paypal_ops_page_during_left_sections_after_eot_behavior", get_defined_vars());
     }
     do_action("ws_plugin__s2member_during_paypal_ops_page_after_left_sections", get_defined_vars());
     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";
 }
 /**
  * s2Member's PayPal IPN handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_payment|recurring_payment)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!empty($paypal["subscr_baid"]) || ($paypal["subscr_baid"] = $paypal["subscr_id"])) && (!empty($paypal["subscr_cid"]) || ($paypal["subscr_cid"] = $paypal["subscr_id"])) && !empty($paypal["txn_id"]) && !empty($paypal["mc_gross"])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_payment|recurring_payment` )") . ".";
             if (empty($_REQUEST["s2member_paypal_proxy"])) {
                 $paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
                 sleep(5);
                 // Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
                 $paypal["s2member_log"][] = "Awake. It's " . date("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
             }
             list($paypal["level"], $paypal["ccaps"]) = preg_split("/\\:/", $paypal["item_number"], 3);
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                 $processing = $during = true;
                 // Yes, we ARE processing this.
                 $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                 $pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"];
                 // Preserves existing.
                 $pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]];
                 update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                 // Update now.
                 if (!get_user_option("s2member_first_payment_txn_id", $user_id)) {
                     // 1st payment?
                     update_user_option($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
                 }
                 update_user_option($user_id, "s2member_last_payment_time", time());
                 // Also update last payment time.
                 $paypal["s2member_log"][] = "Updated Payment Times for this Member.";
                 // Flag this action in the log.
                 $fields = get_user_option("s2member_custom_fields", $user_id);
                 // These will be needed in the routines below.
                 $user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
                 // Original IP during Registration.
                 $user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
                 // Now merge conditionally.
                 if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                     foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url) {
                         if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_id"])), $url))) {
                             if (($url = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_baid"])), $url)) && ($url = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_cid"])), $url))) {
                                 if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["txn_id"])), $url))) {
                                     if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_name"])), $url))) {
                                         if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["last_name"])), $url))) {
                                             if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) {
                                                 if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["payer_email"])), $url)) {
                                                     if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
                                                         if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) {
                                                             if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
                                                                 if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
                                                                     if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
                                                                         if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                             if (is_array($fields) && !empty($fields)) {
                                                                                 foreach ($fields as $var => $val) {
                                                                                     if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                         break;
                                                                                     }
                                                                                 }
                                                                             }
                                                                             if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
                                                                                 c_ws_plugin__s2member_utils_urls::remote($url);
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
                 }
                 if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                     $msg = $sbj = "(s2Member / API Notification Email) - Payment";
                     $msg .= "\n\n";
                     // Spacing in the message body.
                     $msg .= "subscr_id: %%subscr_id%%\n";
                     $msg .= "subscr_baid: %%subscr_baid%%\n";
                     $msg .= "subscr_cid: %%subscr_cid%%\n";
                     $msg .= "amount: %%amount%%\n";
                     $msg .= "txn_id: %%txn_id%%\n";
                     $msg .= "item_number: %%item_number%%\n";
                     $msg .= "item_name: %%item_name%%\n";
                     $msg .= "first_name: %%first_name%%\n";
                     $msg .= "last_name: %%last_name%%\n";
                     $msg .= "full_name: %%full_name%%\n";
                     $msg .= "payer_email: %%payer_email%%\n";
                     $msg .= "user_first_name: %%user_first_name%%\n";
                     $msg .= "user_last_name: %%user_last_name%%\n";
                     $msg .= "user_full_name: %%user_full_name%%\n";
                     $msg .= "user_email: %%user_email%%\n";
                     $msg .= "user_login: %%user_login%%\n";
                     $msg .= "user_ip: %%user_ip%%\n";
                     $msg .= "user_id: %%user_id%%\n";
                     if (is_array($fields) && !empty($fields)) {
                         foreach ($fields as $var => $val) {
                             $msg .= $var . ": %%" . $var . "%%\n";
                         }
                     }
                     $msg .= "cv0: %%cv0%%\n";
                     $msg .= "cv1: %%cv1%%\n";
                     $msg .= "cv2: %%cv2%%\n";
                     $msg .= "cv3: %%cv3%%\n";
                     $msg .= "cv4: %%cv4%%\n";
                     $msg .= "cv5: %%cv5%%\n";
                     $msg .= "cv6: %%cv6%%\n";
                     $msg .= "cv7: %%cv7%%\n";
                     $msg .= "cv8: %%cv8%%\n";
                     $msg .= "cv9: %%cv9%%";
                     if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_id"]), $msg))) {
                         if (($msg = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_baid"]), $msg)) && ($msg = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_cid"]), $msg))) {
                             if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["txn_id"]), $msg))) {
                                 if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["item_name"]), $msg))) {
                                     if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["last_name"]), $msg))) {
                                         if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) {
                                             if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["payer_email"]), $msg)) {
                                                 if (($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) && ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $msg))) {
                                                     if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . " " . $user->last_name)), $msg)) {
                                                         if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $msg)) {
                                                             if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $msg)) {
                                                                 if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $msg)) {
                                                                     if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) {
                                                                         if (is_array($fields) && !empty($fields)) {
                                                                             foreach ($fields as $var => $val) {
                                                                                 if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) {
                                                                                     break;
                                                                                 }
                                                                             }
                                                                         }
                                                                         if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) {
                                                                             // Still have a ``$sbj`` and a ``$msg``?
                                                                             foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient) {
                                                                                 wp_mail($recipient, apply_filters("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8");
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
                 }
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars());
                 unset($__refs, $__v);
             } else {
                 $paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
                 $ipn = array("txn_type" => "subscr_payment");
                 // Create a simulated IPN response for txn_type=subscr_payment.
                 foreach ($paypal as $var => $val) {
                     if (in_array($var, array("subscr_gateway", "subscr_id", "subscr_baid", "subscr_cid", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2"))) {
                         $ipn[$var] = $val;
                     }
                 }
                 $paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
                 set_transient("s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
             }
         } else {
             $paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_payment|recurring_payment` ).";
             $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars());
         unset($__refs, $__v);
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", false, get_defined_vars());
     }
 }
 /**
  * Handles ccBill IPN URL processing.
  *
  * @package s2Member\ccBill
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after handling the Notification.
  */
 public static function ccbill_notify()
 {
     global $current_site, $current_blog;
     if (isset($_GET["s2member_pro_ccbill_notify"]) && strlen($_GET["s2member_pro_ccbill_notify"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"]) {
         @ignore_user_abort(true);
         // Continue processing even if/when connection is broken by the sender.
         if (is_array($ccbill = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_postvars()) && ($_ccbill = $ccbill)) {
             $ccbill["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T");
             $ccbill["s2member_log"][] = "s2Member POST vars verified with ccBill.";
             if (!$ccbill["denialId"] && $ccbill["subscription_id"] && !$ccbill["recurringPeriod"]) {
                 $ccbill["s2member_log"][] = "ccBill transaction identified as ( `NON-RECURRING/BUY-NOW` ).";
                 $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as `txn_type` ( `web_accept` ).";
                 $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                 $processing = $processed = true;
                 $ipn = array();
                 // Reset.
                 $ipn["txn_type"] = "web_accept";
                 $ipn["txn_id"] = $ccbill["subscription_id"];
                 $ipn["custom"] = $ccbill["s2_custom"];
                 $ipn["mc_gross"] = number_format($ccbill["initialPrice"], 2, ".", "");
                 $ipn["mc_currency"] = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_code($ccbill["currencyCode"]);
                 $ipn["tax"] = number_format("0.00", 2, ".", "");
                 $ipn["payer_email"] = $ccbill["email"];
                 $ipn["first_name"] = $ccbill["customer_fname"];
                 $ipn["last_name"] = $ccbill["customer_lname"];
                 $ipn["option_name1"] = $ccbill["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                 $ipn["option_selection1"] = $ccbill["s2_referencing"] ? $ccbill["s2_referencing"] : $_SERVER["HTTP_HOST"];
                 $ipn["option_name2"] = "Customer IP Address";
                 $ipn["option_selection2"] = $ccbill["s2_customer_ip"];
                 $ipn["item_number"] = $ccbill["s2_invoice"];
                 $ipn["item_name"] = $ccbill["s2_desc"];
                 $ipn["s2member_paypal_proxy"] = "ccbill";
                 $ipn["s2member_paypal_proxy_use"] = "standard-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));
             } else {
                 if (!$ccbill["denialId"] && $ccbill["subscription_id"] && $ccbill["recurringPeriod"]) {
                     $ccbill["s2member_log"][] = "ccBill transaction identified as ( `RECURRING/SUBSCRIPTION` ).";
                     $ccbill["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as `txn_type` ( `subscr_signup` ).";
                     $ccbill["s2member_log"][] = "Please check PayPal IPN logs for further processing details.";
                     $processing = $processed = true;
                     $ipn = array();
                     // Reset.
                     $ipn["txn_type"] = "subscr_signup";
                     $ipn["subscr_id"] = $ccbill["subscription_id"];
                     $ipn["recurring"] = "1";
                     // Yes, recurring.
                     $ipn["txn_id"] = $ccbill["subscription_id"];
                     $ipn["custom"] = $ccbill["s2_custom"];
                     $ipn["period1"] = $ccbill["s2_p1"];
                     $ipn["period3"] = $ccbill["s2_p3"];
                     $ipn["mc_amount1"] = number_format($ccbill["initialPrice"], 2, ".", "");
                     $ipn["mc_amount3"] = number_format($ccbill["recurringPrice"], 2, ".", "");
                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                     $ipn["mc_currency"] = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_code($ccbill["currencyCode"]);
                     $ipn["tax"] = number_format("0.00", 2, ".", "");
                     $ipn["payer_email"] = $ccbill["email"];
                     $ipn["first_name"] = $ccbill["customer_fname"];
                     $ipn["last_name"] = $ccbill["customer_lname"];
                     $ipn["option_name1"] = $ccbill["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                     $ipn["option_selection1"] = $ccbill["s2_referencing"] ? $ccbill["s2_referencing"] : $_SERVER["HTTP_HOST"];
                     $ipn["option_name2"] = "Customer IP Address";
                     $ipn["option_selection2"] = $ccbill["s2_customer_ip"];
                     $ipn["item_number"] = $ccbill["s2_invoice"];
                     $ipn["item_name"] = $ccbill["s2_desc"];
                     $ipn["s2member_paypal_proxy"] = "ccbill";
                     $ipn["s2member_paypal_proxy_use"] = "standard-emails";
                     $ipn["s2member_paypal_proxy_use"] .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                     $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));
                 } else {
                     if (!$processed) {
                         // If nothing was processed, here we add a message to the logs indicating the IPN was ignored.
                         $ccbill["s2member_log"][] = "Ignoring this IPN request. The transaction does NOT require any action on the part of s2Member.";
                     }
                 }
             }
         } else {
             $ccbill["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid ccBill configuration. Please check: s2Member → ccBill Options.";
             $ccbill["s2member_log"][] = "If you're absolutely SURE that your ccBill configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to ccBill over an HTTPS connection.";
             $ccbill["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server.";
             $ccbill["s2member_log"][] = var_export($_REQUEST, true);
             // Recording _POST + _GET vars for analysis and debugging.
         }
         /*
         If debugging/logging is enabled; we need to append $ccbill to the log file.
         	Logging now supports Multisite Networking as well.
         */
         $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() ? "ccbill-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-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, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($ccbill, true)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         status_header(200);
         // Send a 200 OK status header.
         header("Content-Type: text/plain; charset=UTF-8");
         // Content-Type text/plain with UTF-8.
         while (@ob_end_clean()) {
         }
         // Clean any existing output buffers.
         exit;
         // Exit now.
     }
 }
 /**
  * Handles Google® IPN URL processing.
  *
  * @package s2Member\Google
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after handling the Notification.
  */
 public static function google_notify()
 {
     global $current_site, $current_blog;
     /* For Multisite support. */
     /**/
     if (!empty($_GET["s2member_pro_google_notify"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]) {
         @ignore_user_abort(true);
         /* Continue processing even if/when connection is broken by the sender. */
         /**/
         if (is_array($google = c_ws_plugin__s2member_pro_google_utilities::google_postvars()) && ($_google = $google)) {
             $google["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T");
             $google["s2member_log"][] = "s2Member POST vars verified with Google®.";
             /**/
             if (preg_match("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && !$s2vars_item1["s2_subscr_id"]) {
                 $google["s2member_log"][] = "Google® transaction identified as ( `SALE/BUY-NOW` ).";
                 $google["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `web_accept` ).";
                 $google["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                 /**/
                 $processing = $processed = true;
                 $ipn = array();
                 /* Reset. */
                 /**/
                 $ipn["txn_type"] = "web_accept";
                 /**/
                 $ipn["txn_id"] = $s2vars_item1["s2_txn_id"] ? $s2vars_item1["s2_txn_id"] : $google["order-summary_google-order-number"];
                 /**/
                 $ipn["custom"] = $s2vars_item1["s2_custom"];
                 /**/
                 $ipn["mc_gross"] = number_format($google["order-summary_order-total"], 2, ".", "");
                 $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]);
                 $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", "");
                 /**/
                 $ipn["payer_email"] = $google["buyer-billing-address_email"];
                 $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"];
                 $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"];
                 /**/
                 $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                 $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"];
                 /**/
                 $ipn["option_name2"] = "Customer IP Address";
                 /* IP Address. */
                 $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"];
                 /**/
                 $ipn["item_number"] = $s2vars_item1["s2_item_number"];
                 $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"];
                 /**/
                 $ipn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-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("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"] && !$s2vars_item1["s2_subscr_payment"]) {
                     $google["s2member_log"][] = "Google® transaction identified as ( `SALE/SUBSCRIPTION` ).";
                     $google["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_signup` ).";
                     $google["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                     /**/
                     $processing = $processed = true;
                     $ipn = array();
                     /* Reset. */
                     /**/
                     $ipn["txn_type"] = "subscr_signup";
                     $ipn["subscr_id"] = $s2vars_item1["s2_subscr_id"];
                     /**/
                     $ipn["recurring"] = !($times = $google["order-summary_shopping-cart_items_item-2_subscription_payments_subscription-payment-1_times"]) || $times > 1 ? "1" : "0";
                     /**/
                     $ipn["txn_id"] = $google["order-summary_google-order-number"];
                     /**/
                     $ipn["custom"] = $s2vars_item1["s2_custom"];
                     /**/
                     $ipn["period1"] = $s2vars_item1["s2_period1"];
                     /* Just use s2Member's period calculations to make this easier. */
                     $ipn["period3"] = $s2vars_item1["s2_period3"];
                     /* Just use s2Member's period calculations to make this easier. */
                     /**/
                     $ipn["mc_amount1"] = number_format($google["order-summary_shopping-cart_items_item-1_unit-price"], 2, ".", "");
                     $ipn["mc_amount3"] = number_format($google["order-summary_shopping-cart_items_item-2_subscription_recurrent-item_unit-price"], 2, ".", "");
                     /**/
                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                     /**/
                     $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]);
                     $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", "");
                     /**/
                     $ipn["payer_email"] = $google["buyer-billing-address_email"];
                     $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"];
                     $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"];
                     /**/
                     $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                     $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"];
                     /**/
                     $ipn["option_name2"] = "Customer IP Address";
                     /* IP Address. */
                     $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"];
                     /**/
                     $ipn["item_number"] = $s2vars_item1["s2_item_number"];
                     $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"];
                     /**/
                     $ipn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-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());
                     /**/
                     c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                 } else {
                     if (preg_match("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"] && $s2vars_item1["s2_subscr_payment"]) {
                         $google["s2member_log"][] = "Google® transaction identified as ( `SUBSCRIPTION PAYMENT` ).";
                         $google["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_payment` ).";
                         $google["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                         /**/
                         $processing = $processed = true;
                         $ipn = array();
                         /* Reset. */
                         /**/
                         $ipn["txn_type"] = "subscr_payment";
                         $ipn["subscr_id"] = $s2vars_item1["s2_subscr_id"];
                         /**/
                         $ipn["txn_id"] = $google["order-summary_google-order-number"];
                         /**/
                         $ipn["custom"] = $s2vars_item1["s2_custom"];
                         /**/
                         $ipn["mc_gross"] = number_format($google["order-summary_order-total"], 2, ".", "");
                         $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]);
                         $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", "");
                         /**/
                         $ipn["payer_email"] = $google["buyer-billing-address_email"];
                         $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"];
                         $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"];
                         /**/
                         $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                         $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"];
                         /**/
                         $ipn["option_name2"] = "Customer IP Address";
                         /* IP Address. */
                         $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"];
                         /**/
                         $ipn["item_number"] = $s2vars_item1["s2_item_number"];
                         $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"];
                         /**/
                         $ipn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-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("/^cancelled-subscription-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"]) {
                             $google["s2member_log"][] = "Google® transaction identified as ( `SUBSCRIPTION CANCELLATION` ).";
                             $google["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_cancel` ).";
                             $google["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"] = $s2vars_item1["s2_subscr_id"];
                             /**/
                             $ipn["custom"] = $s2vars_item1["s2_custom"];
                             /**/
                             $ipn["period1"] = $s2vars_item1["s2_period1"];
                             $ipn["period3"] = $s2vars_item1["s2_period3"];
                             /**/
                             $ipn["payer_email"] = $google["order-summary_risk-information_billing-address_email"];
                             $ipn["first_name"] = preg_replace("/( )(.+)/", "", $google["order-summary_risk-information_billing-address_contact-name"]);
                             $ipn["last_name"] = preg_replace("/(.+?)( )/", "", $google["order-summary_risk-information_billing-address_contact-name"]);
                             /**/
                             $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                             $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"];
                             /**/
                             $ipn["option_name2"] = "Customer IP Address";
                             /* IP Address. */
                             $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"];
                             /**/
                             $ipn["item_number"] = $s2vars_item1["s2_item_number"];
                             $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"];
                             /**/
                             $ipn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-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("/^(refund|chargeback)-amount-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && (preg_match("/^refund/", $google["_type"]) && $google["latest-fee-refund-amount"] >= $google["order-summary_total-charge-amount"] || preg_match("/^chargeback/", $google["_type"]) && $google["latest-chargeback-amount"] >= $google["order-summary_total-charge-amount"])) {
                                 $google["s2member_log"][] = "Google® transaction identified as ( `REFUND|CHARGEBACK` ).";
                                 $google["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `payment_status` ( `refunded|reversed` ).";
                                 $google["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                                 /**/
                                 $processing = $processed = true;
                                 $ipn = array();
                                 /* Reset. */
                                 /**/
                                 $ipn["custom"] = $s2vars_item1["s2_custom"];
                                 /**/
                                 if ($s2vars_item1["s2_subscr_id"] && !$s2vars_item1["s2_txn_id"]) {
                                     $ipn["parent_txn_id"] = $s2vars_item1["s2_subscr_id"];
                                 } else {
                                     if ($s2vars_item1["s2_txn_id"] && !$s2vars_item1["s2_subscr_id"]) {
                                         $ipn["parent_txn_id"] = $s2vars_item1["s2_txn_id"];
                                     } else {
                                         /* Default to Google's Order #. */
                                         $ipn["parent_txn_id"] = $google["order-summary_google-order-number"];
                                     }
                                 }
                                 /**/
                                 if (preg_match("/^refund/", $google["_type"])) {
                                     $ipn["payment_status"] = "refunded";
                                     /* Refunding. */
                                     $ipn["mc_fee"] = "-" . number_format($google["latest-fee-refund-amount"], 2, ".", "");
                                     $ipn["mc_gross"] = "-" . number_format($google["latest-refund-amount"], 2, ".", "");
                                     $ipn["mc_currency"] = strtoupper($google["latest-refund-amount_currency"]);
                                     $ipn["tax"] = "-" . number_format("0.00", 2, ".", "");
                                 } else {
                                     if (preg_match("/^chargeback/", $google["_type"])) {
                                         $ipn["payment_status"] = "reversed";
                                         /* Reversed/chargeback. */
                                         $ipn["mc_fee"] = "-" . number_format($google["latest-chargeback-fee-amount"], 2, ".", "");
                                         $ipn["mc_gross"] = "-" . number_format($google["latest-chargeback-amount"], 2, ".", "");
                                         $ipn["mc_currency"] = strtoupper($google["latest-chargeback-amount_currency"]);
                                         $ipn["tax"] = "-" . number_format("0.00", 2, ".", "");
                                     }
                                 }
                                 /**/
                                 $ipn["payer_email"] = $google["order-summary_risk-information_billing-address_email"];
                                 $ipn["first_name"] = preg_replace("/( )(.+)/", "", $google["order-summary_risk-information_billing-address_contact-name"]);
                                 $ipn["last_name"] = preg_replace("/(.+?)( )/", "", $google["order-summary_risk-information_billing-address_contact-name"]);
                                 /**/
                                 $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain";
                                 $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"];
                                 /**/
                                 $ipn["option_name2"] = "Customer IP Address";
                                 /* IP Address. */
                                 $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"];
                                 /**/
                                 $ipn["item_number"] = $s2vars_item1["s2_item_number"];
                                 $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"];
                                 /**/
                                 $ipn_q = "&s2member_paypal_proxy=google&s2member_paypal_proxy_use=standard-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 IPN was ignored. */
                                     $google["s2member_log"][] = "Ignoring this IPN request. The transaction does NOT require any action on the part of s2Member.";
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $google["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid Google® configuration. Please check: s2Member -> Google® Options.";
             $google["s2member_log"][] = "If you're absolutely SURE that your Google® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to Google® over an HTTPS connection.";
             $google["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
             $google["s2member_log"][] = var_export($_REQUEST, true);
             /* Recording _POST + _GET vars for analysis and debugging. */
         }
         /*
         We need to log this final event before it occurs, so that is makes it into the log entry.
         */
         $google["s2member_log"][] = "Sending Google® an XML Notification Acknowlegment w/ original serial number.";
         /*
         If debugging/logging is enabled; we need to append $google to the log file.
         	Logging now supports Multisite Networking as well.
         */
         $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-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "google-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($google, true) . "\n\n", FILE_APPEND);
                 }
             }
         }
         /**/
         $confirmation = '<?xml version="1.0" encoding="UTF-8"?>';
         $confirmation .= '<notification-acknowledgment xmlns="http://checkout.google.com/schema/2"';
         $confirmation .= ' serial-number="' . esc_attr(trim(stripslashes($_REQUEST["serial-number"]))) . '" />';
         /**/
         status_header(200);
         /* Send a 200 OK status header. */
         header("Content-Type: application/xml");
         /* Google® expects application/xml here. */
         eval('while (@ob_end_clean ());');
         /* End/clean all output buffers that may or may not exist. */
         /**/
         exit($confirmation);
         /* Exit w/ serial number confirmation. */
     }
 }
 /**
  * Handles ClickBank IPN URL processing.
  *
  * @package s2Member\ClickBank
  * @since 1.5
  *
  * @attaches-to ``add_action('init');``
  */
 public static function clickbank_notify()
 {
     global $current_site, $current_blog;
     // For Multisite support.
     if (!empty($_GET['s2member_pro_clickbank_notify']) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_clickbank_username']) {
         @ignore_user_abort(TRUE);
         // Continue processing even if/when connection is broken by the sender.
         if (is_array($clickbank = c_ws_plugin__s2member_pro_clickbank_utilities::clickbank_postvars_v2_1()) && ($_clickbank = $clickbank)) {
             $clickbank['s2member_log'][] = 'IPN received on: ' . date('D M j, Y g:i:s a T');
             $clickbank['s2member_log'][] = 's2Member POST vars verified with ClickBank.';
             $s2vars = c_ws_plugin__s2member_pro_clickbank_utilities::clickbank_parse_s2vars_v2_1($clickbank['cvendthru'], $clickbank['ctransaction']);
             if (isset($s2vars['s2_p1'], $s2vars['s2_p3']) && $s2vars['s2_p1'] === '0 D') {
                 // No Trial defaults to Regular Period.
                 $s2vars['s2_p1'] = $s2vars['s2_p3'];
             }
             // Initial Period. No Trial defaults to Regular Period.
             $clickbank['s2vars'] = $s2vars;
             // So they appear in the log entry for this Notification.
             if (strcasecmp($clickbank['ccustfirstname'] . ' ' . $clickbank['ccustlastname'], $clickbank['ccustfullname']) !== 0 && preg_match('/(?:[^ ]+)(?: +)(?:[^ ]+)/', $clickbank['ccustfullname'])) {
                 list($clickbank['ccustfirstname'], $clickbank['ccustlastname']) = preg_split('/ +/', $clickbank['ccustfullname'], 2);
             }
             if (preg_match('/^(?:TEST_)?SALE$/i', $clickbank['ctransaction']) && preg_match('/^STANDARD$/i', $clickbank['cprodtype'])) {
                 $clickbank['s2member_log'][] = 'ClickBank transaction identified as ( `SALE/STANDARD` ).';
                 $clickbank['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `web_accept` ).';
                 $clickbank['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                 $processing = $processed = TRUE;
                 $ipn = array();
                 // Reset.
                 $ipn['txn_type'] = 'web_accept';
                 $ipn['txn_id'] = $clickbank['ctransreceipt'];
                 $ipn['custom'] = $s2vars['s2_custom'];
                 $ipn['mc_gross'] = number_format($clickbank['corderamount'] / 100, 2, '.', '');
                 $ipn['mc_currency'] = strtoupper($clickbank['ccurrency']);
                 $ipn['tax'] = number_format('0.00', 2, '.', '');
                 $ipn['payer_email'] = $clickbank['ccustemail'];
                 $ipn['first_name'] = ucwords(strtolower($clickbank['ccustfirstname']));
                 $ipn['last_name'] = ucwords(strtolower($clickbank['ccustlastname']));
                 $ipn['option_name1'] = $s2vars['s2_referencing'] ? 'Referencing Customer ID' : 'Originating Domain';
                 $ipn['option_selection1'] = $s2vars['s2_referencing'] ? $s2vars['s2_referencing'] : $_SERVER['HTTP_HOST'];
                 $ipn['option_name2'] = 'Customer IP Address';
                 $ipn['option_selection2'] = $s2vars['s2_customer_ip'];
                 $ipn['item_number'] = $s2vars['s2_invoice'];
                 $ipn['item_name'] = $s2vars['s2_desc'];
                 $ipn['s2member_paypal_proxy'] = 'clickbank';
                 $ipn['s2member_paypal_proxy_use'] = 'standard-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));
             } else {
                 if (preg_match('/^(?:TEST_)?SALE$/i', $clickbank['ctransaction']) && preg_match('/^RECURRING$/i', $clickbank['cprodtype'])) {
                     $clickbank['s2member_log'][] = 'ClickBank transaction identified as ( `SALE/RECURRING` ).';
                     $clickbank['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `subscr_signup` ).';
                     $clickbank['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                     $processing = $processed = TRUE;
                     $ipn = array();
                     // Reset.
                     $ipn['txn_type'] = 'subscr_signup';
                     $ipn['subscr_id'] = $s2vars['s2_subscr_id'];
                     $ipn['recurring'] = $clickbank['cfuturepayments'] > 1 ? '1' : '0';
                     $ipn['txn_id'] = $clickbank['ctransreceipt'];
                     $ipn['custom'] = $s2vars['s2_custom'];
                     $ipn['period1'] = $s2vars['s2_p1'];
                     $ipn['period3'] = $s2vars['s2_p3'];
                     $ipn['mc_amount1'] = number_format($clickbank['corderamount'] / 100, 2, '.', '');
                     $ipn['mc_amount3'] = number_format($clickbank['crebillamnt'] / 100, 2, '.', '');
                     $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                     $ipn['mc_currency'] = strtoupper($clickbank['ccurrency']);
                     $ipn['tax'] = number_format('0.00', 2, '.', '');
                     $ipn['payer_email'] = $clickbank['ccustemail'];
                     $ipn['first_name'] = ucwords(strtolower($clickbank['ccustfirstname']));
                     $ipn['last_name'] = ucwords(strtolower($clickbank['ccustlastname']));
                     $ipn['option_name1'] = $s2vars['s2_referencing'] ? 'Referencing Customer ID' : 'Originating Domain';
                     $ipn['option_selection1'] = $s2vars['s2_referencing'] ? $s2vars['s2_referencing'] : $_SERVER['HTTP_HOST'];
                     $ipn['option_name2'] = 'Customer IP Address';
                     $ipn['option_selection2'] = $s2vars['s2_customer_ip'];
                     $ipn['item_number'] = $s2vars['s2_invoice'];
                     $ipn['item_name'] = $s2vars['s2_desc'];
                     $ipn['s2member_paypal_proxy'] = 'clickbank';
                     $ipn['s2member_paypal_proxy_use'] = 'standard-emails';
                     $ipn['s2member_paypal_proxy_use'] .= $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                     $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));
                 } else {
                     if (preg_match('/^(?:TEST_)?BILL$/i', $clickbank['ctransaction']) && preg_match('/^RECURRING$/i', $clickbank['cprodtype'])) {
                         $clickbank['s2member_log'][] = 'ClickBank transaction identified as ( `BILL/RECURRING` ).';
                         $clickbank['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `subscr_payment` ).';
                         $clickbank['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                         $processing = $processed = TRUE;
                         $ipn = array();
                         // Reset.
                         $ipn['txn_type'] = 'subscr_payment';
                         $ipn['subscr_id'] = $s2vars['s2_subscr_id'];
                         $ipn['txn_id'] = $clickbank['ctransreceipt'];
                         $ipn['custom'] = $s2vars['s2_custom'];
                         $ipn['mc_gross'] = number_format($clickbank['corderamount'] / 100, 2, '.', '');
                         $ipn['mc_currency'] = strtoupper($clickbank['ccurrency']);
                         $ipn['tax'] = number_format('0.00', 2, '.', '');
                         $ipn['payer_email'] = $clickbank['ccustemail'];
                         $ipn['first_name'] = ucwords(strtolower($clickbank['ccustfirstname']));
                         $ipn['last_name'] = ucwords(strtolower($clickbank['ccustlastname']));
                         $ipn['option_name1'] = $s2vars['s2_referencing'] ? 'Referencing Customer ID' : 'Originating Domain';
                         $ipn['option_selection1'] = $s2vars['s2_referencing'] ? $s2vars['s2_referencing'] : $_SERVER['HTTP_HOST'];
                         $ipn['option_name2'] = 'Customer IP Address';
                         $ipn['option_selection2'] = $s2vars['s2_customer_ip'];
                         $ipn['item_number'] = $s2vars['s2_invoice'];
                         $ipn['item_name'] = $s2vars['s2_desc'];
                         $ipn['s2member_paypal_proxy'] = 'clickbank';
                         $ipn['s2member_paypal_proxy_use'] = 'standard-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));
                     } else {
                         if (preg_match('/^(?:TEST_)?(?:RFND|CGBK|INSF)$/i', $clickbank['ctransaction'])) {
                             $clickbank['s2member_log'][] = 'ClickBank transaction identified as ( `RFND|CGBK|INSF` ).';
                             $clickbank['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `payment_status` ( `refunded|reversed` ).';
                             $clickbank['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                             $processing = $processed = TRUE;
                             $ipn = array();
                             // Reset.
                             $ipn['payment_status'] = preg_match('/^(?:TEST_)?RFND$/', $clickbank['ctransaction']) ? 'refunded' : 'reversed';
                             $ipn['parent_txn_id'] = preg_match('/^RECURRING$/i', $clickbank['cprodtype']) && $s2vars['s2_subscr_id'] ? $s2vars['s2_subscr_id'] : $clickbank['ctransreceipt'];
                             $ipn['custom'] = $s2vars['s2_custom'];
                             $ipn['mc_fee'] = '-' . number_format('0.00', 2, '.', '');
                             $ipn['mc_gross'] = '-' . number_format(abs($clickbank['corderamount']) / 100, 2, '.', '');
                             $ipn['mc_currency'] = strtoupper($clickbank['ccurrency']);
                             $ipn['tax'] = '-' . number_format('0.00', 2, '.', '');
                             $ipn['payer_email'] = $clickbank['ccustemail'];
                             $ipn['first_name'] = ucwords(strtolower($clickbank['ccustfirstname']));
                             $ipn['last_name'] = ucwords(strtolower($clickbank['ccustlastname']));
                             $ipn['option_name1'] = $s2vars['s2_referencing'] ? 'Referencing Customer ID' : 'Originating Domain';
                             $ipn['option_selection1'] = $s2vars['s2_referencing'] ? $s2vars['s2_referencing'] : $_SERVER['HTTP_HOST'];
                             $ipn['option_name2'] = 'Customer IP Address';
                             $ipn['option_selection2'] = $s2vars['s2_customer_ip'];
                             $ipn['item_number'] = $s2vars['s2_invoice'];
                             $ipn['item_name'] = $s2vars['s2_desc'];
                             $ipn['s2member_paypal_proxy'] = 'clickbank';
                             $ipn['s2member_paypal_proxy_use'] = 'standard-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));
                         }
                     }
                 }
             }
             if (preg_match('/^(?:TEST_)?(?:SALE|BILL)$/i', $clickbank['ctransaction']) && preg_match('/^RECURRING$/i', $clickbank['cprodtype']) && (preg_match('/^COMPLETED$/i', $clickbank['crebillstatus']) || $clickbank['cfuturepayments'] <= 0) && apply_filters('c_ws_plugin__s2member_pro_clickbank_notify_handles_completions', TRUE, get_defined_vars()) || preg_match('/^(?:TEST_)?CANCEL-REBILL$/i', $clickbank['ctransaction']) && preg_match('/^RECURRING$/i', $clickbank['cprodtype'])) {
                 $clickbank['s2member_log'][] = 'ClickBank transaction identified as ( `RECURRING/COMPLETED` or `CANCEL-REBILL` ).';
                 $clickbank['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `subscr_cancel` ).';
                 $clickbank['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'] = $s2vars['s2_subscr_id'];
                 $ipn['custom'] = $s2vars['s2_custom'];
                 $ipn['period1'] = $s2vars['s2_p1'];
                 $ipn['period3'] = $s2vars['s2_p3'];
                 $ipn['payer_email'] = $clickbank['ccustemail'];
                 $ipn['first_name'] = ucwords(strtolower($clickbank['ccustfirstname']));
                 $ipn['last_name'] = ucwords(strtolower($clickbank['ccustlastname']));
                 $ipn['option_name1'] = $s2vars['s2_referencing'] ? 'Referencing Customer ID' : 'Originating Domain';
                 $ipn['option_selection1'] = $s2vars['s2_referencing'] ? $s2vars['s2_referencing'] : $_SERVER['HTTP_HOST'];
                 $ipn['option_name2'] = 'Customer IP Address';
                 $ipn['option_selection2'] = $s2vars['s2_customer_ip'];
                 $ipn['item_number'] = $s2vars['s2_invoice'];
                 $ipn['item_name'] = $s2vars['s2_desc'];
                 $ipn['s2member_paypal_proxy'] = 'clickbank';
                 $ipn['s2member_paypal_proxy_use'] = 'standard-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));
             }
             if (empty($processed)) {
                 // If nothing was processed, here we add a message to the logs indicating the IPN was ignored.
                 $clickbank['s2member_log'][] = 'Ignoring this IPN request. The transaction does NOT require any action on the part of s2Member.';
             }
         } else {
             $clickbank['s2member_log'][] = 'Unable to verify POST vars. This is most likely related to an invalid ClickBank configuration. Please check: s2Member → ClickBank Options.';
             $clickbank['s2member_log'][] = 'If you\'re absolutely SURE that your ClickBank configuration is valid, you may want to run some tests on your server, just to be sure $_POST variables are populated, and that your server is able to connect to ClickBank over an HTTPS connection.';
             $clickbank['s2member_log'][] = 's2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server.';
             $clickbank['s2member_log'][] = var_export($_REQUEST, TRUE);
             // Recording _POST + _GET vars for analysis and debugging.
         }
         /*
         If debugging/logging is enabled; we need to append $clickbank to the log file.
         	Logging now supports Multisite Networking as well.
         */
         $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() ? 'clickbank-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'clickbank-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, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($clickbank, TRUE)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         status_header(200);
         // Send a 200 OK status header.
         header('Content-Type: text/plain; charset=UTF-8');
         // Content-Type text/plain with UTF-8.
         while (@ob_end_clean()) {
         }
         // Clean any existing output buffers.
         exit;
         // Exit now.
     }
 }
 /**
  * Handles PayPal Return URLs.
  *
  * @package s2Member\PayPal
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection.
  */
 public static function paypal_return()
 {
     global $current_site, $current_blog;
     do_action("ws_plugin__s2member_before_paypal_return", get_defined_vars());
     if (!empty($_GET["s2member_paypal_return"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty($_GET["s2member_paypal_proxy"]))) {
         $custom_success_redirection = !empty($_GET["s2member_paypal_return_success"]) ? esc_html(trim(stripslashes($_GET["s2member_paypal_return_success"]))) : false;
         $custom_success_redirection = $custom_success_redirection ? str_ireplace(array("&#038;", "&amp;"), "&", $custom_success_redirection) : $custom_success_redirection;
         if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars()) && ($_paypal = $paypal) && ($_paypal_s = serialize($_paypal))) {
             $paypal["s2member_log"][] = "Return-Data received on: " . date("D M j, Y g:i:s a T");
             $paypal["s2member_log"][] = "s2Member POST vars verified " . (!empty($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal.");
             $paypal["subscr_gateway"] = !empty($_GET["s2member_paypal_proxy"]) ? esc_html(trim(stripslashes($_GET["s2member_paypal_proxy"]))) : "paypal";
             if (empty($_GET["s2member_paypal_proxy"]) || empty($_GET["s2member_paypal_proxy_use"]) || !preg_match("/ty-email/", $_GET["s2member_paypal_proxy_use"])) {
                 $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)\$/i";
                 if (!empty($paypal["custom"]) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"])) {
                     $paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
                     foreach (array_keys(get_defined_vars()) as $__v) {
                         $__refs[$__v] =& ${$__v};
                     }
                     if (!apply_filters("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars())) {
                         unset($__refs, $__v);
                         if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_web_accept_sp::cp(get_defined_vars())) {
                             $paypal = $_paypal_cp;
                         } else {
                             if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level::cp(get_defined_vars())) {
                                 $paypal = $_paypal_cp;
                             } else {
                                 if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level::cp(get_defined_vars())) {
                                     $paypal = $_paypal_cp;
                                 } else {
                                     if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level::cp(get_defined_vars())) {
                                         $paypal = $_paypal_cp;
                                     } else {
                                         $paypal["s2member_log"][] = "Unexpected `txn_type/status`. The `txn_type/status` did not match a required action.";
                                         $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                                         echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unexpected <code>txn_type/status</code>.<br />The <code>txn_type/status</code> did not meet requirements.<br />Please contact Support for assistance.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                                     }
                                 }
                             }
                         }
                     } else {
                         // Else a custom conditional has been applied by filters.
                         unset($__refs, $__v);
                     }
                 } else {
                     if ($paypal["custom"] && ($paypal["custom"] === "www." . $_SERVER["HTTP_HOST"] || "www." . $paypal["custom"] === $_SERVER["HTTP_HOST"])) {
                         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice("<strong>s2Member:</strong> Post-processing failed on at least one transaction. It appears that you have a PayPal Button configured with a <code>custom=\"\"</code> Shortcode Attribute that does NOT match up with your installation domain name. If your site uses the <code>www.</code> prefix, please include that. If it does not, please exclude the <code>www.</code> prefix. You should have <code>custom=\"" . preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]) . "\"</code>", "*:*", true);
                     }
                     $paypal["s2member_log"][] = 'Unable to verify `$_SERVER["HTTP_HOST"]`. Please check the `custom` value in your Button Code. It MUST start with your domain name.';
                     $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                     echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unable to verify <code>$_SERVER["HTTP_HOST"]</code>.<br />Please contact Support for assistance.<br /><br />If you are the site owner, please check the <code>custom</code> value in your Button Code. It MUST start with your domain name.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                 }
             } else {
                 // In this case ... a Proxy has explicitly requested `ty-email` processing.
                 $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_proxy_ty_email::cp(get_defined_vars());
             }
         } else {
             if (!empty($_GET["s2member_paypal_proxy"]) && !empty($_GET["s2member_paypal_proxy_use"]) && preg_match("/x-preview/", $_GET["s2member_paypal_proxy_use"]) && ($paypal["subscr_gateway"] = esc_html(trim(stripslashes($_GET["s2member_paypal_proxy"]))))) {
                 $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_proxy_x_preview::cp(get_defined_vars());
             } else {
                 if (empty($_GET["tx"]) && empty($_GET["s2member_paypal_proxy"]) && ($paypal["subscr_gateway"] = "paypal")) {
                     $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_no_tx_data::cp(get_defined_vars());
                 } else {
                     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]) {
                         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice("<strong>s2Member:</strong> You have no PayPal PDT Identity Token configured. PayPal Auto-Return handling failed. Please update your PayPal PDT Identity Key. See: <code>s2Member -› PayPal Options -› PayPal PDT/Auto-Return Integration</code>. Thank you!", "*:*", true);
                     }
                     $paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.";
                     $paypal["s2member_log"][] = "Please make sure that you configure a PayPal PDT Identity Token for your installation of s2Member. See: `s2Member -› PayPal Options -› PayPal PDT/Auto-Return Integration`.";
                     $paypal["s2member_log"][] = "See also, this KB article: `http://www.s2member.com/kb/server-scanner/`. We suggest that you run the s2Member Server Scanner.";
                     $paypal["s2member_log"][] = var_export($_REQUEST, true);
                     $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                     echo c_ws_plugin__s2member_return_templates::return_template("default", _x('<strong>ERROR:</strong> Unable to verify <code>$_POST</code> vars.<br />Please contact Support for assistance.<br /><br />This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility. If you are the site owner, and you\'re absolutely SURE that your configuration is valid, you may want to run some tests on your server, just to be sure <code>$_POST</code> variables are populated, and that your server is able to connect/communicate with your Payment Gateway over an HTTPS connection.<br /><br />s2Member uses the <code>WP_Http</code> class for remote connections; which will try to use <code>cURL</code> first, and then fall back on the <code>FOPEN</code> method when <code>cURL</code> is not available. On a Windows server, you may have to disable your <code>cURL</code> extension; and instead, set <code>allow_url_fopen = yes</code> in your php.ini file. The <code>cURL</code> extension (usually) does NOT support SSL connections on a Windows server.<br /><br />Please see <a href="http://www.s2member.com/forums/topic/ideal-server-configuration-for-s2member/" target="_blank">this thread</a> for details regarding the ideal server configuration for s2Member.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                 }
             }
         }
         /*
         Add RTN proxy (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy"])) {
             $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
         }
         /*
         Add IPN proxy use vars (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy_use"])) {
             $paypal["s2member_paypal_proxy_use"] = $_GET["s2member_paypal_proxy_use"];
         }
         /*
         Also add RTN proxy self-verification (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy_verification"])) {
             $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
         }
         /*
         Also add RTN success redirection URL (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_return_success"])) {
             $paypal["s2member_paypal_return_success"] = $_GET["s2member_paypal_return_success"];
         }
         /*
         Also add RTN t and r Attributes (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_return_tra"])) {
             $paypal["s2member_paypal_return_tra"] = $_GET["s2member_paypal_return_tra"];
         }
         /*
         If debugging/logging is enabled; we need to append $paypal to the log file.
         	Logging now supports Multisite Networking as well.
         */
         $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-rtn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-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($paypal, true)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_return", get_defined_vars());
         unset($__refs, $__v);
         exit;
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_after_paypal_return", get_defined_vars());
     unset($__refs, $__v);
 }
 /**
  * Configures all new Users.
  *
  * The Hook `user_register` is also fired by calling:
  * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
  *
  * This function also receives hand-offs from s2Member's handlers for these two Hooks:
  * `wpmu_activate_user` and `wpmu_activate_blog`.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action('user_register');``
  *
  * @param int|string $user_id A numeric WordPress User ID.
  * @param string     $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
  * @param array      $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
  *
  * @TODO Impossible to delete cookies when fired inside: `/wp-activate.php`?
  */
 public static function configure_user_registration($user_id = '', $password = '', $meta = array())
 {
     global $wpdb;
     // Global database object reference.
     global $pagenow;
     // We need this to detect the current administration page.
     global $current_site, $current_blog;
     // Adds support for Multisite Networking.
     static $email_config, $processed;
     // Static vars prevent duplicate processing.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_configure_user_registration', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
     if (!isset($email_config) && ($email_config = TRUE)) {
         // Anytime this routine is fired; we configure email.
         c_ws_plugin__s2member_email_configs::email_config();
     }
     // Configures `From:` email header.
     $_p = isset($_POST) ? $_POST : NULL;
     // Grab global ``$_POST`` array here, if it's possible to do so.
     $rvs = isset($GLOBALS['ws_plugin__s2member_registration_vars']) ? $GLOBALS['ws_plugin__s2member_registration_vars'] : NULL;
     if (!$processed) {
         if (is_array($_p) || is_array($meta) || is_array($rvs)) {
             if (!(is_multisite() && is_blog_admin() && $pagenow === 'user-new.php' && isset($_p['noconfirmation']) && is_super_admin() && !is_array($meta))) {
                 if (!(preg_match('/\\/wp-activate\\.php/', $_SERVER['REQUEST_URI']) && !is_array($meta))) {
                     if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) {
                         if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user') && !is_array($rvs))) {
                             if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = TRUE)) {
                                 settype($_p, 'array') . settype($meta, 'array') . settype($rvs, 'array');
                                 // Force arrays here.
                                 $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p));
                                 $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta));
                                 $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs);
                                 foreach ($_p as $_key => $_value) {
                                     // Scan ``$_p`` vars; adding `custom_reg_field` keys.
                                     if (preg_match('/^ws_plugin__s2member_user_new_/', $_key)) {
                                         // Look for keys.
                                         if ($_key = str_replace('_user_new_', '_custom_reg_field_', $_key)) {
                                             $_p[$_key] = $_value;
                                         }
                                     }
                                 }
                                 // Add each of these key conversions.
                                 unset($_key, $_value);
                                 if (!is_admin() && (isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_custom']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_ccaps']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_notes']))) {
                                     exit(_x('s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!', 's2member-front', 's2member'));
                                 }
                                 $_pmr = array_merge($_p, $meta, $rvs);
                                 // Merge all of these arrays together now, in this specific order.
                                 unset($_p, $meta, $rvs);
                                 // These variables can all be unset now; we have them all in the ``$_pmr`` array.
                                 $custom_reg_display_name = $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_display_name'];
                                 // Can be configured by the site owner.
                                 if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                                     /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                     			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                     			If processed through `/wp-activate.php`, it could've originated inside the admin—via `/user-new.php`. */
                                     /**
                                      * @var $subscr_gateway string Reference for IDEs.
                                      * @var $subscr_id string Reference for IDEs.
                                      * @var $custom string Reference for IDEs.
                                      * @var $item_number string Reference for IDEs.
                                      */
                                     $processed = 'yes';
                                     // Mark this as yes.
                                     $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                     @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $item_number, 3));
                                     $role = 's2member_level' . $level;
                                     // Membership Level.
                                     $email = $user->user_email;
                                     $login = $user->user_login;
                                     $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                     $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip;
                                     // Else use environment variable.
                                     $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                     $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                     $cv = preg_split('/\\|/', $custom);
                                     if (!($auto_eot_time = '') && $eotper) {
                                         // If a specific EOT Period is included.
                                         $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper);
                                     }
                                     $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                     $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE;
                                     $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in;
                                     if (!($fname = $user->first_name)) {
                                         if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                             $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                         }
                                     }
                                     if (!$fname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr['field_1'])) {
                                             // BuddyPress?
                                             $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1']));
                                         }
                                     }
                                     if (!($lname = $user->last_name)) {
                                         if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                             $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                         }
                                     }
                                     if (!$lname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) {
                                             $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1']));
                                         }
                                     }
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                         $fname = trim($login);
                                         $lname = '';
                                         // Username and empty Last Name.
                                     }
                                     $name = trim($fname . ' ' . $lname);
                                     // Both names.
                                     if (!($pass = $password)) {
                                         // Try s2Member's generator.
                                         if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                             $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                         }
                                     }
                                     if (!$pass) {
                                         // Also try BuddyPress Password.
                                         if (!empty($_pmr['signup_password'])) {
                                             // BuddyPress?
                                             $pass = (string) $_pmr['signup_password'];
                                         }
                                     }
                                     if ($pass) {
                                         !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                         update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                     }
                                     update_user_option($user_id, 's2member_registration_ip', $ip);
                                     update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                     update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                     update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                     update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                     update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                     update_user_option($user_id, 's2member_custom', $custom);
                                     update_user_option($user_id, 's2member_notes', $notes);
                                     if (!$user->first_name && $fname) {
                                         update_user_meta($user_id, 'first_name', $fname);
                                     }
                                     if (!$user->last_name && $lname) {
                                         update_user_meta($user_id, 'last_name', $lname);
                                     }
                                     if (!$user->display_name || $user->display_name === $user->user_login) {
                                         if ($custom_reg_display_name === 'full' && $name) {
                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                         } else {
                                             if ($custom_reg_display_name === 'first' && $fname) {
                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                             } else {
                                                 if ($custom_reg_display_name === 'last' && $lname) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'login' && $login) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if (is_multisite()) {
                                         if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                             remove_user_from_blog($user_id, $current_site->blog_id);
                                         }
                                         // No Main Site Role.
                                         if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                             // Recorded yet?
                                             update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                         }
                                     }
                                     if ($current_role !== $role) {
                                         // Only if NOT the current Role.
                                         $user->set_role($role);
                                     }
                                     // s2Member.
                                     if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                         foreach ($user->allcaps as $cap => $cap_enabled) {
                                             if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                 $user->remove_cap($ccap = $cap);
                                             }
                                         }
                                     }
                                     if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                         foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                 $user->add_cap('access_s2member_ccap_' . $ccap);
                                             }
                                         }
                                     }
                                     if (!($fields = array()) && $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($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                 $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                             }
                                         }
                                     }
                                     unset($field, $field_var, $field_id_class);
                                     // Housekeeping.
                                     if (!empty($fields)) {
                                         // Only if NOT empty.
                                         update_user_option($user_id, 's2member_custom_fields', $fields);
                                     }
                                     if ($level > 0) {
                                         $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                         $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                         $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                         update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                         // Update now.
                                     }
                                     if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) {
                                         update_user_option($user_id, 's2member_bp_activation_role', $role);
                                         update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_signup_vars_' . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) {
                                         update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars);
                                         // For future reference.
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_payment_' . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment['subscr_gateway'])) {
                                         $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_payment['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_payment), $proxy), array('timeout' => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_eot_' . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot['subscr_gateway'])) {
                                         $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_eot['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_eot), $proxy), array('timeout' => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (!headers_sent()) {
                                         // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
                                         @setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                     }
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action('ws_plugin__s2member_during_configure_user_registration_front_side_paid', get_defined_vars());
                                     do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
                                     unset($__refs, $__v);
                                 } else {
                                     if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user'))) {
                                         /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                         			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                         			If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
                                         $processed = 'yes';
                                         // Mark this as yes.
                                         $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                         $role = '';
                                         // Initialize ``$role`` to an empty string here, before processing.
                                         $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role;
                                         $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role;
                                         $role = !$role && $current_role ? $current_role : $role;
                                         // Use existing Role?
                                         $role = !$role ? get_option('default_role') : $role;
                                         // Otherwise default.
                                         $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
                                         $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
                                         $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level;
                                         $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level;
                                         $level = !$level ? '0' : $level;
                                         $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
                                         $email = $user->user_email;
                                         $login = $user->user_login;
                                         $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                         $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip;
                                         // Else use environment variable.
                                         $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
                                         $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
                                         $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                         $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                         $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
                                         $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
                                         $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
                                         $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                         $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE;
                                         $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in;
                                         if (!($fname = $user->first_name)) {
                                             if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                                 $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                             }
                                         }
                                         if (!$fname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr['field_1'])) {
                                                 // BuddyPress?
                                                 $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1']));
                                             }
                                         }
                                         if (!($lname = $user->last_name)) {
                                             if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                                 $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                             }
                                         }
                                         if (!$lname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) {
                                                 $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1']));
                                             }
                                         }
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                             $fname = trim($login);
                                             $lname = '';
                                             // Username and empty Last Name.
                                         }
                                         $name = trim($fname . ' ' . $lname);
                                         // Both names.
                                         if (!($pass = $password)) {
                                             // Try s2Member's generator.
                                             if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                                 $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                             }
                                         }
                                         if (!$pass) {
                                             // Also try BuddyPress Password.
                                             if (!empty($_pmr['signup_password'])) {
                                                 // BuddyPress?
                                                 $pass = (string) $_pmr['signup_password'];
                                             }
                                         }
                                         if ($pass) {
                                             !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                             update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                         }
                                         update_user_option($user_id, 's2member_registration_ip', $ip);
                                         update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                         update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                         update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                         update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                         update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                         update_user_option($user_id, 's2member_custom', $custom);
                                         update_user_option($user_id, 's2member_notes', $notes);
                                         if (!$user->first_name && $fname) {
                                             update_user_meta($user_id, 'first_name', $fname);
                                         }
                                         if (!$user->last_name && $lname) {
                                             update_user_meta($user_id, 'last_name', $lname);
                                         }
                                         if (!$user->display_name || $user->display_name === $user->user_login) {
                                             if ($custom_reg_display_name === 'full' && $name) {
                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                             } else {
                                                 if ($custom_reg_display_name === 'first' && $fname) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'last' && $lname) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                     } else {
                                                         if ($custom_reg_display_name === 'login' && $login) {
                                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if (is_multisite()) {
                                             if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                                 remove_user_from_blog($user_id, $current_site->blog_id);
                                             }
                                             // No Main Site Role.
                                             if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                                 // Recorded yet?
                                                 update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                             }
                                         }
                                         if ($current_role !== $role) {
                                             // Only if NOT the current Role.
                                             $user->set_role($role);
                                         }
                                         // s2Member.
                                         if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                 if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                     $user->remove_cap($ccap = $cap);
                                                 }
                                             }
                                         }
                                         if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                             foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                                 if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                     $user->add_cap('access_s2member_ccap_' . $ccap);
                                                 }
                                             }
                                         }
                                         if (!($fields = array()) && $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($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                     $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                                 }
                                             }
                                         }
                                         unset($field, $field_var, $field_id_class);
                                         // Housekeeping.
                                         if (!empty($fields)) {
                                             // Only if NOT empty.
                                             update_user_option($user_id, 's2member_custom_fields', $fields);
                                         }
                                         if ($level > 0) {
                                             $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                             $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                             $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                             update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                             // Update now.
                                         }
                                         if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) {
                                             update_user_option($user_id, 's2member_bp_activation_role', $role);
                                             update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
                                         }
                                         foreach (array_keys(get_defined_vars()) as $__v) {
                                             $__refs[$__v] =& ${$__v};
                                         }
                                         do_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', get_defined_vars());
                                         do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
                                         unset($__refs, $__v);
                                     } else {
                                         if (is_blog_admin() && $pagenow === 'user-new.php' || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) {
                                             // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
                                             $processed = 'yes';
                                             // Mark this as yes, to indicate that a routine was processed.
                                             $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                             $role = '';
                                             // Initialize $role to an empty string here, before processing.
                                             $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role;
                                             $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role;
                                             $role = !$role && $current_role ? $current_role : $role;
                                             // Use existing Role?
                                             $role = !$role ? get_option('default_role') : $role;
                                             // Otherwise default.
                                             $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
                                             $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
                                             $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level;
                                             $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level;
                                             $level = !$level ? '0' : $level;
                                             $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
                                             $email = $user->user_email;
                                             $login = $user->user_login;
                                             $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                             $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
                                             $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
                                             $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                             $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                             $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
                                             $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
                                             $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
                                             $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                             $opt_in = !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : FALSE;
                                             if (!($fname = $user->first_name)) {
                                                 // `Users → Add New`.
                                                 if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                                     $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                                 }
                                             }
                                             if (!($lname = $user->last_name)) {
                                                 // `Users → Add New`.
                                                 if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                                     $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                                 }
                                             }
                                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                                 $fname = trim($login);
                                                 $lname = '';
                                                 // Username and empty Last Name.
                                             }
                                             $name = trim($fname . ' ' . $lname);
                                             // Both names.
                                             if (!($pass = $password)) {
                                                 // Try s2Member's generator.
                                                 if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                                     $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                                 }
                                             }
                                             if (!$pass) {
                                                 // Also try the `Users → Add New` form.
                                                 if (!empty($_pmr['pass1'])) {
                                                     // Field in `/user-new.php`.
                                                     $pass = (string) $_pmr['pass1'];
                                                 }
                                             }
                                             if ($pass) {
                                                 !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                                 update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                             }
                                             update_user_option($user_id, 's2member_registration_ip', $ip);
                                             update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                             update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                             update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                             update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                             update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                             update_user_option($user_id, 's2member_custom', $custom);
                                             update_user_option($user_id, 's2member_notes', $notes);
                                             if (!$user->first_name && $fname) {
                                                 update_user_meta($user_id, 'first_name', $fname);
                                             }
                                             if (!$user->last_name && $lname) {
                                                 update_user_meta($user_id, 'last_name', $lname);
                                             }
                                             if (!$user->display_name || $user->display_name === $user->user_login) {
                                                 if ($custom_reg_display_name === 'full' && $name) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'first' && $fname) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                                     } else {
                                                         if ($custom_reg_display_name === 'last' && $lname) {
                                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                         } else {
                                                             if ($custom_reg_display_name === 'login' && $login) {
                                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if (is_multisite()) {
                                                 if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                                     remove_user_from_blog($user_id, $current_site->blog_id);
                                                 }
                                                 // No Main Site Role.
                                                 if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                                     // Recorded yet?
                                                     update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                                 }
                                             }
                                             if ($current_role !== $role) {
                                                 // Only if NOT the current Role.
                                                 $user->set_role($role);
                                             }
                                             // s2Member.
                                             if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                     if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                         $user->remove_cap($ccap = $cap);
                                                     }
                                                 }
                                             }
                                             if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                                 foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                                     if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                         $user->add_cap('access_s2member_ccap_' . $ccap);
                                                     }
                                                 }
                                             }
                                             if (!($fields = array()) && $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($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                         $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                                     }
                                                 }
                                             }
                                             unset($field, $field_var, $field_id_class);
                                             // Housekeeping.
                                             if (!empty($fields)) {
                                                 // Only if NOT empty.
                                                 update_user_option($user_id, 's2member_custom_fields', $fields);
                                             }
                                             if ($level > 0) {
                                                 $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                                 $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                                 $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                                 update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                                 // Update now.
                                             }
                                             foreach (array_keys(get_defined_vars()) as $__v) {
                                                 $__refs[$__v] =& ${$__v};
                                             }
                                             do_action('ws_plugin__s2member_during_configure_user_registration_admin_side', get_defined_vars());
                                             unset($__refs, $__v);
                                         }
                                     }
                                 }
                                 if ($processed === 'yes') {
                                     /**
                                      * If processed, all of these will have been defined by now.
                                      *
                                      * @var $role string Reference for IDEs.
                                      * @var $level string Reference for IDEs.
                                      * @var $ccaps string Reference for IDEs.
                                      * @var $auto_eot_time string|integer Reference for IDEs.
                                      * @var $fname string Reference for IDEs.
                                      * @var $lname string Reference for IDEs.
                                      * @var $name string Reference for IDEs.
                                      * @var $email string Reference for IDEs.
                                      * @var $login string Reference for IDEs.
                                      * @var $pass string Reference for IDEs.
                                      * @var $ip string Reference for IDEs.
                                      * @var $opt_in boolean Reference for IDEs.
                                      * @var $fields array Reference for IDEs.
                                      */
                                     if ($urls = $GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_urls']) {
                                         foreach (preg_split('/[' . "\r\n\t" . ']+/', $urls) as $url) {
                                             // Notify each of the URLs.
                                             if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) {
                                                 if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) {
                                                     if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) {
                                                         if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) {
                                                             if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) {
                                                                 if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) {
                                                                     if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) {
                                                                         if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) {
                                                                             if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) {
                                                                                 if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) {
                                                                                     if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) {
                                                                                         if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) {
                                                                                             if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                                                 foreach ($fields as $var => $val) {
                                                                                                     // Custom Fields.
                                                                                                     if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                                         break;
                                                                                                     }
                                                                                                 }
                                                                                                 if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) {
                                                                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($urls, $url, $var, $val);
                                     // Housekeeping.
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) {
                                         $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
                                         c_ws_plugin__s2member_email_configs::email_config_release();
                                         $msg = $sbj = '(s2Member / API Notification Email) - Registration';
                                         $msg .= "\n\n";
                                         // Spacing in the message body.
                                         $msg .= 'role: %%role%%' . "\n";
                                         $msg .= 'level: %%level%%' . "\n";
                                         $msg .= 'ccaps: %%ccaps%%' . "\n";
                                         $msg .= 'auto_eot_time: %%auto_eot_time%%' . "\n";
                                         $msg .= 'user_first_name: %%user_first_name%%' . "\n";
                                         $msg .= 'user_last_name: %%user_last_name%%' . "\n";
                                         $msg .= 'user_full_name: %%user_full_name%%' . "\n";
                                         $msg .= 'user_email: %%user_email%%' . "\n";
                                         $msg .= 'user_login: %%user_login%%' . "\n";
                                         $msg .= 'user_pass: %%user_pass%%' . "\n";
                                         $msg .= 'user_ip: %%user_ip%%' . "\n";
                                         $msg .= 'user_id: %%user_id%%' . "\n";
                                         foreach ($fields as $var => $val) {
                                             $msg .= $var . ': %%' . $var . '%%' . "\n";
                                         }
                                         $msg .= 'cv0: %%cv0%%' . "\n";
                                         $msg .= 'cv1: %%cv1%%' . "\n";
                                         $msg .= 'cv2: %%cv2%%' . "\n";
                                         $msg .= 'cv3: %%cv3%%' . "\n";
                                         $msg .= 'cv4: %%cv4%%' . "\n";
                                         $msg .= 'cv5: %%cv5%%' . "\n";
                                         $msg .= 'cv6: %%cv6%%' . "\n";
                                         $msg .= 'cv7: %%cv7%%' . "\n";
                                         $msg .= 'cv8: %%cv8%%' . "\n";
                                         $msg .= 'cv9: %%cv9%%';
                                         if ($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)) {
                                             if ($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) {
                                                 if ($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) {
                                                     if ($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) {
                                                         if ($msg = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($auto_eot_time), $msg)) {
                                                             if ($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($fname), $msg)) {
                                                                 if ($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($lname), $msg)) {
                                                                     if ($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($name), $msg)) {
                                                                         if ($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($email), $msg)) {
                                                                             if ($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($login), $msg)) {
                                                                                 if ($msg = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($pass), $msg)) {
                                                                                     if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ip), $msg)) {
                                                                                         if ($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) {
                                                                                                 // Still have a ``$sbj`` and a ``$msg``?
                                                                                                 foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) as $recipient) {
                                                                                                     wp_mail($recipient, apply_filters('ws_plugin__s2member_registration_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_registration_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8');
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if ($email_configs_were_on) {
                                             // Back on?
                                             c_ws_plugin__s2member_email_configs::email_config();
                                         }
                                         unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on);
                                         // Housekeeping.
                                     }
                                     if (!empty($GLOBALS['ws_plugin__s2member_registration_return_url']) && ($url = $GLOBALS['ws_plugin__s2member_registration_return_url'])) {
                                         if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) {
                                             if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) {
                                                 if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) {
                                                     if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) {
                                                         if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) {
                                                             if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) {
                                                                 if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) {
                                                                     if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) {
                                                                         if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) {
                                                                             if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) {
                                                                                 if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) {
                                                                                     if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) {
                                                                                         if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($url = trim($url)) {
                                                                                                 // Preserve remaining Replacements; because the parent routine may perform replacements too.
                                                                                                 $GLOBALS['ws_plugin__s2member_registration_return_url'] = $url;
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($url, $var, $val);
                                     // Housekeeping.
                                     c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, TRUE, $user_id);
                                     /*
                                     Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
                                     	@TODO It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
                                     */
                                     if (!headers_sent()) {
                                         @setcookie('s2member_subscr_gateway', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_gateway', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_subscr_id', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_id', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_custom', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_custom', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_item_number', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_item_number', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                     }
                                     /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
                                     			Logging now supports Multisite Networking as well. */
                                     $reg_vars = get_defined_vars();
                                     // All defined vars.
                                     $reg_vars['_COOKIE'] = $_COOKIE;
                                     // Record cookies also.
                                     // No need to include these in the logs. Unset before log entry.
                                     unset($reg_vars['wpdb'], $reg_vars['current_site'], $reg_vars['current_blog']);
                                     c_ws_plugin__s2member_utils_logs::log_entry('reg-handler', $reg_vars);
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action('ws_plugin__s2member_during_configure_user_registration', get_defined_vars());
                                     unset($__refs, $__v);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_after_configure_user_registration', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Configures all new Users.
  *
  * The Hook `user_register` is also fired by calling:
  * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
  *
  * This function also receives hand-offs from s2Member's handlers for these two Hooks:
  * `wpmu_activate_user` and `wpmu_activate_blog`.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action("user_register");``
  *
  * @param int|str $user_id A numeric WordPress User ID.
  * @param str $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
  * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
  * @return null No return value. Returns `null` in possible every scenario.
  *
  * @todo Impossible to delete cookies when fired inside: `/wp-activate.php`?
  */
 public static function configure_user_registration($user_id = FALSE, $password = FALSE, $meta = FALSE)
 {
     global $wpdb;
     global $pagenow;
     // We need this to detect the current administration page.
     global $current_site, $current_blog;
     // Adds support for Multisite Networking.
     static $email_config, $processed;
     // Static vars prevent duplicate processing.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_configure_user_registration", get_defined_vars());
     unset($__refs, $__v);
     // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
     if (!isset($email_config) && ($email_config = true)) {
         // Anytime this routine is fired; we configure email.
         c_ws_plugin__s2member_email_configs::email_config();
     }
     // Configures `From:` email header.
     $_p = isset($_POST) ? $_POST : null;
     $rvs = isset($GLOBALS["ws_plugin__s2member_registration_vars"]) ? $GLOBALS["ws_plugin__s2member_registration_vars"] : null;
     if (!$processed) {
         if (is_array($_p) || is_array($meta) || is_array($rvs)) {
             if (!(is_multisite() && is_blog_admin() && $pagenow === "user-new.php" && isset($_p["noconfirmation"]) && is_super_admin() && !is_array($meta))) {
                 if (!(preg_match("/\\/wp-activate\\.php/", $_SERVER["REQUEST_URI"]) && !is_array($meta))) {
                     if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) {
                         if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user") && !is_array($rvs))) {
                             if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = true)) {
                                 settype($_p, "array") . settype($meta, "array") . settype($rvs, "array");
                                 $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p));
                                 $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta));
                                 $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs);
                                 foreach ($_p as $_key => $_value) {
                                     // Scan ``$_p`` vars; adding `custom_reg_field` keys.
                                     if (preg_match("/^ws_plugin__s2member_user_new_/", $_key)) {
                                         // Look for keys.
                                         if ($_key = str_replace("_user_new_", "_custom_reg_field_", $_key)) {
                                             $_p[$_key] = $_value;
                                         }
                                     }
                                 }
                                 // Add each of these key conversions.
                                 unset($_key, $_value);
                                 if (!is_admin() && (isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_custom"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_notes"]))) {
                                     exit(_x("s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!", "s2member-front", "s2member"));
                                 }
                                 $_pmr = array_merge($_p, $meta, $rvs);
                                 // Merge all of these arrays together now, in this specific order.
                                 unset($_p, $meta, $rvs);
                                 // These variables can all be unset now; we have them all in the ``$_pmr`` array.
                                 $custom_reg_display_name = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_display_name"];
                                 // Can be configured by the site owner.
                                 if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                                     /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                     			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                     			If processed through `/wp-activate.php`, it could've originated inside the admin — via `/user-new.php`. */
                                     $processed = "yes";
                                     // Mark this as yes.
                                     $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                     @(list($level, $ccaps, $eotper) = preg_split("/\\:/", $item_number, 3));
                                     $role = "s2member_level" . $level;
                                     // Membership Level.
                                     $email = $user->user_email;
                                     $login = $user->user_login;
                                     $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                     $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip;
                                     // Else use environment variable.
                                     $cv = preg_split("/\\|/", $custom);
                                     if (!($auto_eot_time = "") && $eotper) {
                                         // If a specific EOT Period is included.
                                         $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $eotper);
                                     }
                                     $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                     $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false;
                                     $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
                                     if (!($fname = $user->first_name)) {
                                         if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                             $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                         }
                                     }
                                     if (!$fname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr["field_1"])) {
                                             // BuddyPress?
                                             $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"]));
                                         }
                                     }
                                     if (!($lname = $user->last_name)) {
                                         if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                             $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                         }
                                     }
                                     if (!$lname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) {
                                             $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"]));
                                         }
                                     }
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                         $fname = trim($login);
                                         $lname = "";
                                     }
                                     // Username and empty Last Name.
                                     $name = trim($fname . " " . $lname);
                                     // Both names.
                                     if (!($pass = $password)) {
                                         // Try s2Member's generator.
                                         if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                             $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                         }
                                     }
                                     if (!$pass) {
                                         // Also try BuddyPress Password.
                                         if (!empty($_pmr["signup_password"])) {
                                             // BuddyPress?
                                             $pass = (string) $_pmr["signup_password"];
                                         }
                                     }
                                     if ($pass) {
                                         !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                         update_user_option($user_id, "default_password_nag", false, true);
                                     }
                                     update_user_option($user_id, "s2member_registration_ip", $ip);
                                     update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                     update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                     update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                     update_user_option($user_id, "s2member_custom", $custom);
                                     update_user_option($user_id, "s2member_notes", $notes);
                                     if (!$user->first_name && $fname) {
                                         update_user_meta($user_id, "first_name", $fname);
                                     }
                                     if (!$user->last_name && $lname) {
                                         update_user_meta($user_id, "last_name", $lname);
                                     }
                                     if (!$user->display_name || $user->display_name === $user->user_login) {
                                         if ($custom_reg_display_name === "full" && $name) {
                                             wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                         } else {
                                             if ($custom_reg_display_name === "first" && $fname) {
                                                 wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                             } else {
                                                 if ($custom_reg_display_name === "last" && $lname) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                 } else {
                                                     if ($custom_reg_display_name === "login" && $login) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if (is_multisite()) {
                                         if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                             remove_user_from_blog($user_id, $current_site->blog_id);
                                         }
                                         // No Main Site Role.
                                         if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                             // Recorded yet?
                                             update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                         }
                                     }
                                     if ($current_role !== $role) {
                                         // Only if NOT the current Role.
                                         $user->set_role($role);
                                     }
                                     // s2Member.
                                     if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                         foreach ($user->allcaps as $cap => $cap_enabled) {
                                             if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                 $user->remove_cap($ccap = $cap);
                                             }
                                         }
                                     }
                                     if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                         foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                 $user->add_cap("access_s2member_ccap_" . $ccap);
                                             }
                                         }
                                     }
                                     if (!($fields = array()) && $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($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                 $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                             }
                                         }
                                     }
                                     unset($field, $field_var, $field_id_class);
                                     // Housekeeping.
                                     if (!empty($fields)) {
                                         // Only if NOT empty.
                                         update_user_option($user_id, "s2member_custom_fields", $fields);
                                     }
                                     if ($level > 0) {
                                         $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                         $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                         $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                         update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                         // Update now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_signup_vars_" . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) {
                                         update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
                                         // For future reference.
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment["subscr_gateway"])) {
                                         $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_payment["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_payment), $proxy), array("timeout" => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_eot_" . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot["subscr_gateway"])) {
                                         $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_eot["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_eot), $proxy), array("timeout" => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (!headers_sent()) {
                                         // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
                                         @setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
                                     }
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars());
                                     do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars());
                                     unset($__refs, $__v);
                                 } else {
                                     if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user"))) {
                                         /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                         			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                         			If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
                                         $processed = "yes";
                                         // Mark this as yes.
                                         $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                         $role = "";
                                         // Initialize ``$role`` to an empty string here, before processing.
                                         $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role;
                                         $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role;
                                         $role = !$role && $current_role ? $current_role : $role;
                                         // Use existing Role?
                                         $role = !$role ? get_option("default_role") : $role;
                                         // Otherwise default.
                                         $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
                                         $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
                                         $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level;
                                         $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level;
                                         $level = !$level ? "0" : $level;
                                         $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
                                         $email = $user->user_email;
                                         $login = $user->user_login;
                                         $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                         $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip;
                                         // Else use environment variable.
                                         $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
                                         $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
                                         $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
                                         $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
                                         $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : "";
                                         $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                         $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false;
                                         $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
                                         if (!($fname = $user->first_name)) {
                                             if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                                 $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                             }
                                         }
                                         if (!$fname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr["field_1"])) {
                                                 // BuddyPress?
                                                 $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"]));
                                             }
                                         }
                                         if (!($lname = $user->last_name)) {
                                             if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                                 $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                             }
                                         }
                                         if (!$lname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) {
                                                 $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"]));
                                             }
                                         }
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                             $fname = trim($login);
                                             $lname = "";
                                         }
                                         // Username and empty Last Name.
                                         $name = trim($fname . " " . $lname);
                                         // Both names.
                                         if (!($pass = $password)) {
                                             // Try s2Member's generator.
                                             if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                                 $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                             }
                                         }
                                         if (!$pass) {
                                             // Also try BuddyPress Password.
                                             if (!empty($_pmr["signup_password"])) {
                                                 // BuddyPress?
                                                 $pass = (string) $_pmr["signup_password"];
                                             }
                                         }
                                         if ($pass) {
                                             !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                             update_user_option($user_id, "default_password_nag", false, true);
                                         }
                                         update_user_option($user_id, "s2member_registration_ip", $ip);
                                         update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                         update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                         update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                         update_user_option($user_id, "s2member_custom", $custom);
                                         update_user_option($user_id, "s2member_notes", $notes);
                                         if (!$user->first_name && $fname) {
                                             update_user_meta($user_id, "first_name", $fname);
                                         }
                                         if (!$user->last_name && $lname) {
                                             update_user_meta($user_id, "last_name", $lname);
                                         }
                                         if (!$user->display_name || $user->display_name === $user->user_login) {
                                             if ($custom_reg_display_name === "full" && $name) {
                                                 wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                             } else {
                                                 if ($custom_reg_display_name === "first" && $fname) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                                 } else {
                                                     if ($custom_reg_display_name === "last" && $lname) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                     } else {
                                                         if ($custom_reg_display_name === "login" && $login) {
                                                             wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if (is_multisite()) {
                                             if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                                 remove_user_from_blog($user_id, $current_site->blog_id);
                                             }
                                             if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                                 update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                             }
                                         }
                                         if ($current_role !== $role) {
                                             // Only if NOT the current Role.
                                             $user->set_role($role);
                                         }
                                         // s2Member.
                                         if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                 if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                     $user->remove_cap($ccap = $cap);
                                                 }
                                             }
                                         }
                                         if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                             foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                                 if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                     $user->add_cap("access_s2member_ccap_" . $ccap);
                                                 }
                                             }
                                         }
                                         if (!($fields = array()) && $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($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                     $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                                 }
                                             }
                                         }
                                         unset($field, $field_var, $field_id_class);
                                         // Housekeeping.
                                         if (!empty($fields)) {
                                             // Only if NOT empty.
                                             update_user_option($user_id, "s2member_custom_fields", $fields);
                                         }
                                         if ($level > 0) {
                                             $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                             $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                             $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                             update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                             // Update now.
                                         }
                                         foreach (array_keys(get_defined_vars()) as $__v) {
                                             $__refs[$__v] =& ${$__v};
                                         }
                                         do_action("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars());
                                         do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars());
                                         unset($__refs, $__v);
                                     } else {
                                         if (is_blog_admin() && $pagenow === "user-new.php" || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) {
                                             // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
                                             $processed = "yes";
                                             // Mark this as yes, to indicate that a routine was processed.
                                             $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                             $role = "";
                                             // Initialize $role to an empty string here, before processing.
                                             $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role;
                                             $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role;
                                             $role = !$role && $current_role ? $current_role : $role;
                                             // Use existing Role?
                                             $role = !$role ? get_option("default_role") : $role;
                                             // Otherwise default.
                                             $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
                                             $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
                                             $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level;
                                             $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level;
                                             $level = !$level ? "0" : $level;
                                             $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
                                             $email = $user->user_email;
                                             $login = $user->user_login;
                                             $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                             $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
                                             $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
                                             $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
                                             $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
                                             $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : "";
                                             $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                             $opt_in = !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
                                             if (!($fname = $user->first_name)) {
                                                 // `Users -› Add New`.
                                                 if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                                     $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                                 }
                                             }
                                             if (!($lname = $user->last_name)) {
                                                 // `Users -› Add New`.
                                                 if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                                     $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                                 }
                                             }
                                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                                 $fname = trim($login);
                                                 $lname = "";
                                             }
                                             // Username and empty Last Name.
                                             $name = trim($fname . " " . $lname);
                                             // Both names.
                                             if (!($pass = $password)) {
                                                 // Try s2Member's generator.
                                                 if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                                     $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                                 }
                                             }
                                             if (!$pass) {
                                                 // Also try the `Users -› Add New` form.
                                                 if (!empty($_pmr["pass1"])) {
                                                     // Field in `/user-new.php`.
                                                     $pass = (string) $_pmr["pass1"];
                                                 }
                                             }
                                             if ($pass) {
                                                 !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                                 update_user_option($user_id, "default_password_nag", false, true);
                                             }
                                             update_user_option($user_id, "s2member_registration_ip", $ip);
                                             update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                             update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                             update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                             update_user_option($user_id, "s2member_custom", $custom);
                                             update_user_option($user_id, "s2member_notes", $notes);
                                             if (!$user->first_name && $fname) {
                                                 update_user_meta($user_id, "first_name", $fname);
                                             }
                                             if (!$user->last_name && $lname) {
                                                 update_user_meta($user_id, "last_name", $lname);
                                             }
                                             if (!$user->display_name || $user->display_name === $user->user_login) {
                                                 if ($custom_reg_display_name === "full" && $name) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                                 } else {
                                                     if ($custom_reg_display_name === "first" && $fname) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                                     } else {
                                                         if ($custom_reg_display_name === "last" && $lname) {
                                                             wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                         } else {
                                                             if ($custom_reg_display_name === "login" && $login) {
                                                                 wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if (is_multisite()) {
                                                 if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                                     remove_user_from_blog($user_id, $current_site->blog_id);
                                                 }
                                                 // No Main Site Role.
                                                 if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                                     // Recorded yet?
                                                     update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                                 }
                                             }
                                             if ($current_role !== $role) {
                                                 // Only if NOT the current Role.
                                                 $user->set_role($role);
                                             }
                                             // s2Member.
                                             if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                     if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                         $user->remove_cap($ccap = $cap);
                                                     }
                                                 }
                                             }
                                             if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                                 foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                                     if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                         $user->add_cap("access_s2member_ccap_" . $ccap);
                                                     }
                                                 }
                                             }
                                             if (!($fields = array()) && $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($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                         $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                                     }
                                                 }
                                             }
                                             unset($field, $field_var, $field_id_class);
                                             // Housekeeping.
                                             if (!empty($fields)) {
                                                 // Only if NOT empty.
                                                 update_user_option($user_id, "s2member_custom_fields", $fields);
                                             }
                                             if ($level > 0) {
                                                 $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                                 $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                                 $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                                 update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                                 // Update now.
                                             }
                                             foreach (array_keys(get_defined_vars()) as $__v) {
                                                 $__refs[$__v] =& ${$__v};
                                             }
                                             do_action("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars());
                                             unset($__refs, $__v);
                                         }
                                     }
                                 }
                                 if ($processed === "yes") {
                                     if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) {
                                         foreach (preg_split("/[\r\n\t]+/", $urls) as $url) {
                                             // Notify each of the URLs.
                                             if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) {
                                                 if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) {
                                                     if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) {
                                                         if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) {
                                                             if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) {
                                                                 if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) {
                                                                     if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) {
                                                                         if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) {
                                                                             if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) {
                                                                                 if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) {
                                                                                     if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) {
                                                                                         if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) {
                                                                                             if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) {
                                                                                                 foreach ($fields as $var => $val) {
                                                                                                     // Custom Fields.
                                                                                                     if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) {
                                                                                                         break;
                                                                                                     }
                                                                                                 }
                                                                                                 if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
                                                                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($urls, $url, $var, $val);
                                     // Housekeeping.
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) {
                                         $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
                                         c_ws_plugin__s2member_email_configs::email_config_release();
                                         $msg = $sbj = "(s2Member / API Notification Email) - Registration";
                                         $msg .= "\n\n";
                                         // Spacing in the message body.
                                         $msg .= "role: %%role%%\n";
                                         $msg .= "level: %%level%%\n";
                                         $msg .= "ccaps: %%ccaps%%\n";
                                         $msg .= "auto_eot_time: %%auto_eot_time%%\n";
                                         $msg .= "user_first_name: %%user_first_name%%\n";
                                         $msg .= "user_last_name: %%user_last_name%%\n";
                                         $msg .= "user_full_name: %%user_full_name%%\n";
                                         $msg .= "user_email: %%user_email%%\n";
                                         $msg .= "user_login: %%user_login%%\n";
                                         $msg .= "user_pass: %%user_pass%%\n";
                                         $msg .= "user_ip: %%user_ip%%\n";
                                         $msg .= "user_id: %%user_id%%\n";
                                         foreach ($fields as $var => $val) {
                                             $msg .= $var . ": %%" . $var . "%%\n";
                                         }
                                         $msg .= "cv0: %%cv0%%\n";
                                         $msg .= "cv1: %%cv1%%\n";
                                         $msg .= "cv2: %%cv2%%\n";
                                         $msg .= "cv3: %%cv3%%\n";
                                         $msg .= "cv4: %%cv4%%\n";
                                         $msg .= "cv5: %%cv5%%\n";
                                         $msg .= "cv6: %%cv6%%\n";
                                         $msg .= "cv7: %%cv7%%\n";
                                         $msg .= "cv8: %%cv8%%\n";
                                         $msg .= "cv9: %%cv9%%";
                                         if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) {
                                             if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($role), $msg)) {
                                                 if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($level), $msg)) {
                                                     if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ccaps), $msg)) {
                                                         if ($msg = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($auto_eot_time), $msg)) {
                                                             if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($fname), $msg)) {
                                                                 if ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($lname), $msg)) {
                                                                     if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($name), $msg)) {
                                                                         if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($email), $msg)) {
                                                                             if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($login), $msg)) {
                                                                                 if ($msg = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($pass), $msg)) {
                                                                                     if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ip), $msg)) {
                                                                                         if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) {
                                                                                                 // Still have a ``$sbj`` and a ``$msg``?
                                                                                                 foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) as $recipient) {
                                                                                                     wp_mail($recipient, apply_filters("ws_plugin__s2member_registration_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_registration_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8");
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if ($email_configs_were_on) {
                                             // Back on?
                                             c_ws_plugin__s2member_email_configs::email_config();
                                         }
                                         unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on);
                                         // Housekeeping.
                                     }
                                     if ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"]) {
                                         if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) {
                                             if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) {
                                                 if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) {
                                                     if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) {
                                                         if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) {
                                                             if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) {
                                                                 if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) {
                                                                     if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) {
                                                                         if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) {
                                                                             if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) {
                                                                                 if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) {
                                                                                     if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) {
                                                                                         if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($url = trim($url)) {
                                                                                                 // Preserve remaining Replacements; because the parent routine may perform replacements too.
                                                                                                 $GLOBALS["ws_plugin__s2member_registration_return_url"] = $url;
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($url, $var, $val);
                                     // Housekeeping.
                                     c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, true, $user_id);
                                     /*
                                     Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
                                     	@todo It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
                                     */
                                     if (!headers_sent()) {
                                         @setcookie("s2member_subscr_gateway", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_gateway", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_subscr_id", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_id", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_custom", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_custom", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_item_number", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_item_number", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                     }
                                     /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
                                     			Logging now supports Multisite Networking as well. */
                                     $reg_vars = get_defined_vars();
                                     // All defined vars.
                                     // No need to include these in the logs. Unset before log entry.
                                     unset($reg_vars["wpdb"], $reg_vars["current_site"], $reg_vars["current_blog"]);
                                     $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() ? "reg-handler-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "reg-handler.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($reg_vars, true)) . "\n\n", FILE_APPEND);
                                             }
                                         }
                                     }
                                     unset($logt, $logv, $logm, $log4, $_log4, $log2, $logs_dir, $reg_vars);
                                     // Housekeeping.
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action("ws_plugin__s2member_during_configure_user_registration", get_defined_vars());
                                     unset($__refs, $__v);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_after_configure_user_registration", get_defined_vars());
     unset($__refs, $__v);
     return;
 }
 /**
  * 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 billing updates.
  *
  * @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_update()
 {
     if (!empty($_POST["s2member_pro_paypal_update"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_update"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-update")) {
         $GLOBALS["ws_plugin__s2member_pro_paypal_update_response"] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_update_response"];
         // This is a shorter reference.
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_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_paypal_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 (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"];
         }
         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("update", $post_vars))) {
                 if ($post_vars["card_type"] === "PayPal") {
                     $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                 } else {
                     if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (($paypal = array("METHOD" => "GetRecurringPaymentsProfileDetails")) && ($paypal["PROFILEID"] = $cur__subscr_id = get_user_option("s2member_subscr_id"))) {
                             if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                 $paypal = array();
                                 // Reset the PayPal array.
                                 $paypal["METHOD"] = "UpdateRecurringPaymentsProfile";
                                 $paypal["PROFILEID"] = $cur__subscr_id;
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $user->first_name;
                                 $paypal["LASTNAME"] = $user->last_name;
                                 $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"])) {
                                     $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" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                         $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 {
                                         if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) !== 4) {
                                             $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                         } else {
                                             if ($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") {
                                                 $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                             } else {
                                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> No 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 {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Cancels a Payflow Billing Agreement.
  *
  * @package s2Member\PayPal
  * @since 130510
  *
  * @param string $baid A Billing Agreement ID (aka: BAID).
  *
  * @return boolean True if the agreement was cancelled, else false.
  */
 public static function payflow_cancel_billing_agreement($baid = '')
 {
     $payflow['ACTION'] = 'U';
     $payflow['TENDER'] = 'P';
     $payflow['BAID'] = $baid;
     $payflow['BA_STATUS'] = 'cancel';
     if (($cancellation = c_ws_plugin__s2member_paypal_utilities::paypal_payflow_api_response($payflow)) && empty($cancellation['__error'])) {
         return TRUE;
     }
     return FALSE;
 }