/**
  * Handles Stripe Webhook/IPN event processing.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_notify()
 {
     global $current_site, $current_blog;
     if (!empty($_GET['s2member_pro_stripe_notify']) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_stripe_api_secret_key']) {
         $stripe = array();
         // Initialize array of Webhook/IPN event data and s2Member log details.
         @ignore_user_abort(TRUE);
         // Continue processing even if/when connection is broken.
         require_once dirname(__FILE__) . '/stripe-sdk/lib/Stripe.php';
         Stripe::setApiKey($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_stripe_api_secret_key']);
         if (is_object($event = c_ws_plugin__s2member_pro_stripe_utilities::get_event()) && ($stripe['event'] = $event)) {
             switch ($event->type) {
                 case 'invoice.payment_succeeded':
                     // Subscription payments.
                     if (!empty($event->data->object) && ($stripe_invoice = $event->data->object) instanceof Stripe_Invoice && !empty($stripe_invoice->customer) && !empty($stripe_invoice->subscription) && ($stripe_invoice_total = number_format(c_ws_plugin__s2member_pro_stripe_utilities::cents_to_dollar_amount($stripe_invoice->total, $stripe_invoice->currency), 2, '.', '')) > 0 && is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($stripe_invoice->customer, $stripe_invoice->subscription)) && ($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) {
                         $processing = TRUE;
                         $ipn['txn_type'] = 'subscr_payment';
                         $ipn['txn_id'] = $stripe_invoice->id;
                         $ipn['txn_cid'] = $ipn_signup_vars['subscr_cid'];
                         $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
                         $ipn['subscr_id'] = $ipn_signup_vars['subscr_id'];
                         $ipn['custom'] = $ipn_signup_vars['custom'];
                         $ipn['mc_gross'] = $stripe_invoice_total;
                         $ipn['mc_currency'] = strtoupper($stripe_invoice->currency);
                         $ipn['tax'] = number_format(0, 2, '.', '');
                         $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['s2member_paypal_proxy'] = 'stripe';
                         $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));
                         $stripe['s2member_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T');
                         if ($maybe_end_subscription = self::_maybe_end_subscription_after_payment($stripe_invoice->customer, $stripe_subscription)) {
                             $stripe['s2member_log'][] = $maybe_end_subscription;
                         }
                         $stripe['s2member_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through s2Member\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).';
                         $stripe['s2member_log'][] = 'Please check core IPN logs for further processing details.';
                     }
                     break;
                     // Break switch handler.
                 // Break switch handler.
                 case 'invoice.payment_failed':
                     // Subscription payment failures.
                     if (!empty($event->data->object) && ($stripe_invoice = $event->data->object) instanceof Stripe_Invoice && !empty($stripe_invoice->customer) && !empty($stripe_invoice->subscription) && ($stripe_invoice_total = number_format(c_ws_plugin__s2member_pro_stripe_utilities::cents_to_dollar_amount($stripe_invoice->total, $stripe_invoice->currency), 2, '.', '')) > 0 && is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($stripe_invoice->customer, $stripe_invoice->subscription)) && ($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) {
                         $processing = TRUE;
                         $stripe['s2member_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T');
                         if ($maybe_end_subscription = self::_maybe_end_subscription_after_payment($stripe_invoice->customer, $stripe_subscription)) {
                             $stripe['s2member_log'][] = $maybe_end_subscription;
                         }
                         $stripe['s2member_log'][] = 'Ignoring `' . $event->type . '`. s2Member does NOT respond to individual payment failures; only to subscription cancellations.';
                         $stripe['s2member_log'][] = 'You may control the behavior(s) associated w/ subscription payment failures from your Stripe Dashboard please.';
                     }
                     break;
                     // Break switch handler.
                 // Break switch handler.
                 case 'customer.deleted':
                     // Customer deletions.
                     if (!empty($event->data->object) && ($stripe_customer = $event->data->object) instanceof Stripe_Customer && ($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(0, $stripe_customer->id))) {
                         $processing = TRUE;
                         $ipn['txn_type'] = 'subscr_eot';
                         $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
                         $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['s2member_paypal_proxy'] = 'stripe';
                         $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));
                         $stripe['s2member_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T');
                         $stripe['s2member_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through s2Member\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).';
                         $stripe['s2member_log'][] = 'Please check core IPN logs for further processing details.';
                     }
                     break;
                     // Break switch handler.
                 // Break switch handler.
                 case 'customer.subscription.deleted':
                     // Customer subscription deletion.
                     if (!empty($event->data->object) && ($stripe_subscription = $event->data->object) instanceof Stripe_Subscription && ($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) {
                         $processing = TRUE;
                         $ipn['txn_type'] = 'subscr_eot';
                         $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
                         $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['s2member_paypal_proxy'] = 'stripe';
                         $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));
                         $stripe['s2member_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T');
                         $stripe['s2member_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through s2Member\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).';
                         $stripe['s2member_log'][] = 'Please check core IPN logs for further processing details.';
                     }
                     break;
                     // Break switch handler.
             }
             if (empty($processing)) {
                 $stripe['s2member_log'][] = 'Ignoring this Webhook/IPN. The event does NOT require any action on the part of s2Member.';
             }
         } else {
             $stripe['s2member_log'][] = 'Unable to verify Webhook/IPN event ID. This is most likely related to an invalid Stripe configuration. Please check: s2Member → Stripe Options.';
             $stripe['s2member_log'][] = 'If you\'re absolutely SURE that your Stripe configuration is valid, you may want to run some tests on your server, just to be sure \\$_POST variables (and php://input) are populated; and that your server is able to connect to Stripe over an HTTPS connection.';
             $stripe['s2member_log'][] = 's2Member uses the Stripe SDK for remote connections; which relies upon the cURL extension for PHP. Please make sure that your installation of PHP has the cURL extension; and that it\'s configured together with OpenSSL for HTTPS communication.';
             $stripe['s2member_log'][] = var_export($_REQUEST, TRUE) . "\n" . var_export(json_decode(@file_get_contents('php://input')), TRUE);
         }
         $logt = c_ws_plugin__s2member_utilities::time_details();
         $logv = c_ws_plugin__s2member_utilities::ver_details();
         $logm = c_ws_plugin__s2member_utilities::mem_details();
         $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'];
         $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
         $log2 = is_multisite() && !is_main_site() ? 'stripe-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'stripe-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($stripe, 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.
     }
 }
Esempio n. 2
0
 /**
  * Handles processing of Pro-Form checkouts.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_checkout()
 {
     if (!empty($_POST['s2member_pro_stripe_checkout']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_checkout']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-checkout')) {
         $GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_checkout']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__s2member_pro_stripe_checkout_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email(@$post_vars['email']), get_defined_vars());
         $post_vars['username'] = is_multisite() ? strtolower(@$post_vars['username']) : @$post_vars['username'];
         // Force lowercase.
         $post_vars['username'] = sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite());
         $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
         // Collect reCAPTCHA™ post vars.
         if (!c_ws_plugin__s2member_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__s2member_pro_stripe_responses::stripe_form_submission_validation_errors('checkout', $post_vars))) {
                 unset($_POST['s2member_pro_stripe_checkout']['source_token']);
                 // Good one-time only.
                 unset($_POST['s2member_pro_stripe_checkout']['source_token_summary']);
                 // Good one-time only.
                 $is_bitcoin = !empty($post_vars['source_token']) && stripos($post_vars['source_token'], 'btcrcv_') === 0;
                 $cp_attr = c_ws_plugin__s2member_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post'));
                 $cost_calculations = c_ws_plugin__s2member_pro_stripe_utilities::cost($cp_attr['ta'], $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc'], $is_bitcoin);
                 if ($cost_calculations['total'] <= 0 && $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0) {
                     $post_vars['attr']['tp'] = '0';
                     // Ditch the trial period completely.
                     $cost_calculations['sub_total'] = $cost_calculations['trial_sub_total'];
                     // Use as regular sub-total (ditch trial sub-total).
                     $cost_calculations['tax'] = $cost_calculations['trial_tax'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['tax_per'] = $cost_calculations['trial_tax_per'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['total'] = $cost_calculations['trial_total'];
                     // Use as regular total (ditch trial).
                     $cost_calculations['trial_sub_total'] = '0.00';
                     // Ditch the initial total (using as grand total).
                     $cost_calculations['trial_tax'] = '0.00';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_tax_per'] = '';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_total'] = '0.00';
                     // Ditch this calculation now also.
                 }
                 $use_subscription = $post_vars['attr']['rr'] === 'BN' || !$post_vars['attr']['tp'] && !$post_vars['attr']['rr'] ? FALSE : TRUE;
                 $is_independent_ccaps_sale = $post_vars['attr']['level'] === '*' ? TRUE : FALSE;
                 // Selling Independent Custom Capabilities?
                 if ($use_subscription && $cost_calculations['trial_total'] <= 0 && $cost_calculations['total'] <= 0) {
                     if (!$post_vars['attr']['rr'] && $post_vars['attr']['rt'] !== 'L') {
                         if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                             $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                         } else {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                             }
                         }
                     } else {
                         if ($post_vars['attr']['rr'] && $post_vars['attr']['rrt'] && $post_vars['attr']['rt'] !== 'L') {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                             } else {
                                 if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                     $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                                 }
                             }
                         }
                     }
                 }
                 if ($use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     $plan_attr = $cp_attr;
                     // For the subscription plan.
                     $plan_attr['ta'] = $cost_calculations['trial_total'];
                     $plan_attr['ra'] = $cost_calculations['total'];
                     $plan_attr['desc'] = $cost_calculations['desc'];
                     update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                     update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                     $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                     $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                     $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__s2member_pro_stripe_utilities::start_time($period1) : c_ws_plugin__s2member_pro_stripe_utilities::start_time($period3);
                     // Or next billing cycle.
                     if (!$global_response) {
                         if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                             if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                             } else {
                                 if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                         $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                     } else {
                                         $new__txn_cid = $stripe_customer->id;
                                         $new__txn_id = $stripe_charge->id;
                                     }
                                 }
                             }
                         }
                     }
                     if (!$global_response) {
                         if ($cost_calculations['total'] > 0) {
                             if (!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr))) {
                                 $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                             } else {
                                 if ((empty($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if ((empty($stripe_customer_with_source) || !is_object($stripe_customer_with_source)) && !is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id, array(), $post_vars, $cost_calculations))) {
                                             $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                         } else {
                                             $new__subscr_cid = $stripe_customer->id;
                                             $new__subscr_id = $stripe_subscription->id;
                                         }
                                     }
                                 }
                             }
                             if ($global_response && !empty($new__txn_id)) {
                                 $global_response = array();
                                 $stripe_subscription_failed_charge_succeeded = TRUE;
                             }
                         }
                     }
                     if (!$global_response) {
                         $old__subscr_cid = get_user_option('s2member_subscr_cid');
                         $old__subscr_id = get_user_option('s2member_subscr_id');
                         $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                         if (empty($new__subscr_cid)) {
                             $new__subscr_cid = strtoupper('free-' . uniqid());
                         }
                         if (empty($new__subscr_id)) {
                             $new__subscr_id = strtoupper('free-' . uniqid());
                         }
                         $ipn['txn_type'] = 'subscr_signup';
                         $ipn['subscr_cid'] = $new__subscr_cid;
                         $ipn['subscr_id'] = $new__subscr_id;
                         $ipn['custom'] = $post_vars['attr']['custom'];
                         $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                         $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                         $ipn['period1'] = $period1;
                         $ipn['period3'] = $period3;
                         $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                         $ipn['mc_amount3'] = $cost_calculations['total'];
                         $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                         $ipn['mc_currency'] = $cost_calculations['cur'];
                         $ipn['tax'] = $cost_calculations['tax'];
                         $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                         $ipn['payer_email'] = $user->user_email;
                         $ipn['first_name'] = $post_vars['first_name'];
                         $ipn['last_name'] = $post_vars['last_name'];
                         $ipn['option_name1'] = 'Referencing Customer ID';
                         $ipn['option_selection1'] = $old__subscr_or_wp_id;
                         $ipn['option_name2'] = 'Customer IP Address';
                         $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                         $ipn['item_name'] = $cost_calculations['desc'];
                         $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                         $ipn['s2member_paypal_proxy'] = 'stripe';
                         $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                         $ipn['s2member_paypal_proxy_use'] .= $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                         $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                         $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                         $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                         $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                         if (!empty($stripe_subscription_failed_charge_succeeded)) {
                             update_user_option($user_id, 's2member_auto_eot_time', $start_time);
                         }
                         if ($old__subscr_cid && $old__subscr_id && apply_filters('s2member_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                             c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                         }
                         c_ws_plugin__s2member_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                         setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                         if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     }
                 } else {
                     if ($use_subscription && !is_user_logged_in()) {
                         $plan_attr = $cp_attr;
                         // For the subscription plan.
                         $plan_attr['ta'] = $cost_calculations['trial_total'];
                         $plan_attr['ra'] = $cost_calculations['total'];
                         $plan_attr['desc'] = $cost_calculations['desc'];
                         $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                         $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                         $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__s2member_pro_stripe_utilities::start_time($period1) : c_ws_plugin__s2member_pro_stripe_utilities::start_time($period3);
                         // Or next billing cycle.
                         if (!$global_response) {
                             if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                             $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                         } else {
                                             $new__txn_cid = $stripe_customer->id;
                                             $new__txn_id = $stripe_charge->id;
                                         }
                                     }
                                 }
                             }
                         }
                         if (!$global_response) {
                             if ($cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr))) {
                                     $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                                 } else {
                                     if ((empty($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if ((empty($stripe_customer_with_source) || !is_object($stripe_customer_with_source)) && !is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id, array(), $post_vars, $cost_calculations))) {
                                                 $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                             } else {
                                                 $new__subscr_cid = $stripe_customer->id;
                                                 $new__subscr_id = $stripe_subscription->id;
                                             }
                                         }
                                     }
                                 }
                                 if ($global_response && !empty($new__txn_id)) {
                                     $global_response = array();
                                     $stripe_subscription_failed_charge_succeeded = TRUE;
                                 }
                             }
                         }
                         if (!$global_response) {
                             if (empty($new__subscr_cid)) {
                                 $new__subscr_cid = strtoupper('free-' . uniqid());
                             }
                             if (empty($new__subscr_id)) {
                                 $new__subscr_id = strtoupper('free-' . uniqid());
                             }
                             $ipn['txn_type'] = 'subscr_signup';
                             $ipn['subscr_cid'] = $new__subscr_cid;
                             $ipn['subscr_id'] = $new__subscr_id;
                             $ipn['custom'] = $post_vars['attr']['custom'];
                             $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                             $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                             $ipn['period1'] = $period1;
                             $ipn['period3'] = $period3;
                             $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                             $ipn['mc_amount3'] = $cost_calculations['total'];
                             $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                             $ipn['mc_currency'] = $cost_calculations['cur'];
                             $ipn['tax'] = $cost_calculations['tax'];
                             $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                             $ipn['payer_email'] = $post_vars['email'];
                             $ipn['first_name'] = $post_vars['first_name'];
                             $ipn['last_name'] = $post_vars['last_name'];
                             $ipn['option_name1'] = 'Originating Domain';
                             $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                             $ipn['option_name2'] = 'Customer IP Address';
                             $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                             $ipn['item_name'] = $cost_calculations['desc'];
                             $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                             $ipn['s2member_paypal_proxy'] = 'stripe';
                             $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                             $ipn['s2member_paypal_proxy_use'] .= $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                             $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                             $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                             $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'] = @$post_vars['password1'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_first_name'] = $post_vars['first_name'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_last_name'] = $post_vars['last_name'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                 foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                     $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                     $field_id_class = preg_replace('/_/', '-', $field_var);
                                     if (isset($post_vars['custom_fields'][$field_var])) {
                                         $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                     }
                                 }
                             }
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'] = 'stripe';
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'] = $new__subscr_cid;
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'] = $new__subscr_id;
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_level'] = $post_vars['attr']['level'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_ccaps'] = $post_vars['attr']['ccaps'];
                             $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_custom'] = $post_vars['attr']['custom'];
                             @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                             if (!empty($eotper)) {
                                 $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper));
                             }
                             $create_user['user_email'] = $post_vars['email'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_login'] = $post_vars['username'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_pass'] = wp_generate_password();
                             // Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
                             $has_custom_password = !empty($post_vars['password1']) && $post_vars['password1'] === $create_user['user_pass'];
                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                 update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                 wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                 if (!empty($stripe_subscription_failed_charge_succeeded)) {
                                     update_user_option($new__user_id, 's2member_auto_eot_time', $start_time);
                                 }
                                 $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                 if ($has_custom_password) {
                                     $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">log in</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 } else {
                                     $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                 }
                                 if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                 $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     } else {
                         if (!$use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                             update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                             update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                             if (!$global_response) {
                                 if ($cost_calculations['total'] > 0) {
                                     if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                                 $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                             } else {
                                                 $new__txn_cid = $stripe_customer->id;
                                                 $new__txn_id = $stripe_charge->id;
                                             }
                                         }
                                     }
                                 }
                             }
                             if (!$global_response) {
                                 $old__subscr_cid = get_user_option('s2member_subscr_cid');
                                 $old__subscr_id = get_user_option('s2member_subscr_id');
                                 $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                 if (empty($new__txn_cid)) {
                                     $new__txn_cid = strtoupper('free-' . uniqid());
                                 }
                                 if (empty($new__txn_id)) {
                                     $new__txn_id = strtoupper('free-' . uniqid());
                                 }
                                 $ipn['txn_type'] = 'web_accept';
                                 $ipn['txn_cid'] = $new__txn_cid;
                                 $ipn['txn_id'] = $new__txn_id;
                                 $ipn['custom'] = $post_vars['attr']['custom'];
                                 $ipn['mc_gross'] = $cost_calculations['total'];
                                 $ipn['mc_currency'] = $cost_calculations['cur'];
                                 $ipn['tax'] = $cost_calculations['tax'];
                                 $ipn['payer_email'] = $user->user_email;
                                 $ipn['first_name'] = $post_vars['first_name'];
                                 $ipn['last_name'] = $post_vars['last_name'];
                                 $ipn['option_name1'] = 'Referencing Customer ID';
                                 $ipn['option_selection1'] = $old__subscr_or_wp_id;
                                 $ipn['option_name2'] = 'Customer IP Address';
                                 $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                 $ipn['item_name'] = $cost_calculations['desc'];
                                 $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                 $ipn['s2member_paypal_proxy'] = 'stripe';
                                 $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                 $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                 $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                 $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                 $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 if (!$is_independent_ccaps_sale) {
                                     // Independent?
                                     if ($old__subscr_cid && $old__subscr_id && apply_filters('s2member_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                                         c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                                     }
                                 }
                                 c_ws_plugin__s2member_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                                 setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                 $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         } else {
                             if (!$use_subscription && !is_user_logged_in()) {
                                 if (!$global_response) {
                                     if ($cost_calculations['total'] > 0) {
                                         if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
                                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                             } else {
                                                 if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) {
                                                     $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                                 } else {
                                                     $new__txn_cid = $stripe_customer->id;
                                                     $new__txn_id = $stripe_charge->id;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if (!$global_response) {
                                     if (empty($new__txn_cid)) {
                                         $new__txn_cid = strtoupper('free-' . uniqid());
                                     }
                                     if (empty($new__txn_id)) {
                                         $new__txn_id = strtoupper('free-' . uniqid());
                                     }
                                     $ipn['txn_type'] = 'web_accept';
                                     $ipn['txn_cid'] = $new__txn_cid;
                                     $ipn['txn_id'] = $new__txn_id;
                                     $ipn['custom'] = $post_vars['attr']['custom'];
                                     $ipn['mc_gross'] = $cost_calculations['total'];
                                     $ipn['mc_currency'] = $cost_calculations['cur'];
                                     $ipn['tax'] = $cost_calculations['tax'];
                                     $ipn['payer_email'] = $post_vars['email'];
                                     $ipn['first_name'] = $post_vars['first_name'];
                                     $ipn['last_name'] = $post_vars['last_name'];
                                     $ipn['option_name1'] = 'Originating Domain';
                                     $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                                     $ipn['option_name2'] = 'Customer IP Address';
                                     $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                     $ipn['item_name'] = $cost_calculations['desc'];
                                     $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                     $ipn['s2member_paypal_proxy'] = 'stripe';
                                     $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                     $ipn['s2member_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                     $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                     $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'] = @$post_vars['password1'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_first_name'] = $post_vars['first_name'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_last_name'] = $post_vars['last_name'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                         foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                             $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                             $field_id_class = preg_replace('/_/', '-', $field_var);
                                             if (isset($post_vars['custom_fields'][$field_var])) {
                                                 $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                             }
                                         }
                                     }
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'] = 'stripe';
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'] = $new__txn_cid;
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'] = $new__txn_id;
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_level'] = $post_vars['attr']['level'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_ccaps'] = $post_vars['attr']['ccaps'];
                                     $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_custom'] = $post_vars['attr']['custom'];
                                     @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                                     if (!empty($eotper)) {
                                         $GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper));
                                     }
                                     $create_user['user_email'] = $post_vars['email'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_login'] = $post_vars['username'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_pass'] = wp_generate_password();
                                     // Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
                                     $has_custom_password = !empty($post_vars['password1']) && $post_vars['password1'] === $create_user['user_pass'];
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                         wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                         $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                         setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                         if ($has_custom_password) {
                                             $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">log in</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                         } else {
                                             $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                         }
                                         if ($post_vars['attr']['success'] && substr($ipn['s2member_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                         $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                                     }
                                 }
                             } else {
                                 $global_response = array('response' => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
 /**
  * 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-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;
             }
         }
     }
 }
 /**
  * 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 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.
     }
 }
 /**
  * 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-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'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_authnet_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_authnet_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_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 (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['s2member_paypal_proxy'] = 'authnet';
                                     $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));
                                 }
                                 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;
                         }
                     }
                     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;
             }
         }
     }
 }
 /**
  * Connect to and process cancellations/refunds/chargebacks/etc via Payflow.
  *
  * 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_payflow_ipns_per_process");``.
  *
  * @package s2Member\PayPal
  * @since 120514
  *
  * @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 payflow_service($vars = FALSE)
 {
     global $wpdb;
     // Need global DB obj.
     global $current_site, $current_blog;
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"]) {
         $scan_time = apply_filters("ws_plugin__s2member_pro_payflow_status_scan_time", strtotime("-1 day"), get_defined_vars());
         $per_process = apply_filters("ws_plugin__s2member_pro_payflow_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` = 'paypal' 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($paypal, $subscr_id, $ipn_sv, $processing, $processed, $ipn, $log4, $_log4, $log2, $logs_dir);
                     if (($subscr_id = get_user_option("s2member_subscr_id", $user_id)) && !get_user_option("s2member_auto_eot_time", $user_id)) {
                         if (is_array($ipn_sv = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(false, $subscr_id)) && ($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id)) && is_array($paypal["ipn_signup_vars"] = $ipn_sv)) {
                             if (preg_match("/expired/i", $paypal["STATUS"])) {
                                 $paypal["s2member_log"][] = "Payflow IPN via polling, processed on: " . date("D M j, Y g:i:s a T");
                                 $paypal["s2member_log"][] = "Payflow transaction identified as ( `SUBSCRIPTION EXPIRATION` ).";
                                 $paypal["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as `txn_type` ( `subscr_eot` ).";
                                 $paypal["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"] = $paypal["ipn_signup_vars"]["subscr_id"];
                                 $ipn["custom"] = $paypal["ipn_signup_vars"]["custom"];
                                 $ipn["period1"] = $paypal["ipn_signup_vars"]["period1"];
                                 $ipn["period3"] = $paypal["ipn_signup_vars"]["period3"];
                                 $ipn["payer_email"] = $paypal["ipn_signup_vars"]["payer_email"];
                                 $ipn["first_name"] = $paypal["ipn_signup_vars"]["first_name"];
                                 $ipn["last_name"] = $paypal["ipn_signup_vars"]["last_name"];
                                 $ipn["option_name1"] = $paypal["ipn_signup_vars"]["option_name1"];
                                 $ipn["option_selection1"] = $paypal["ipn_signup_vars"]["option_selection1"];
                                 $ipn["option_name2"] = $paypal["ipn_signup_vars"]["option_name2"];
                                 $ipn["option_selection2"] = $paypal["ipn_signup_vars"]["option_selection2"];
                                 $ipn["item_number"] = $paypal["ipn_signup_vars"]["item_number"];
                                 $ipn["item_name"] = $paypal["ipn_signup_vars"]["item_name"];
                                 $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));
                             } else {
                                 if (preg_match("/(suspended|canceled|terminated|deactivated)/i", $paypal["STATUS"])) {
                                     $paypal["s2member_log"][] = "Payflow IPN via polling, processed on: " . date("D M j, Y g:i:s a T");
                                     $paypal["s2member_log"][] = "Payflow transaction identified as ( `SUBSCRIPTION " . strtoupper($paypal["STATUS"]) . "` ).";
                                     $paypal["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal processor as `txn_type` ( `subscr_cancel` ).";
                                     $paypal["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"] = $paypal["ipn_signup_vars"]["subscr_id"];
                                     $ipn["custom"] = $paypal["ipn_signup_vars"]["custom"];
                                     $ipn["period1"] = $paypal["ipn_signup_vars"]["period1"];
                                     $ipn["period3"] = $paypal["ipn_signup_vars"]["period3"];
                                     $ipn["payer_email"] = $paypal["ipn_signup_vars"]["payer_email"];
                                     $ipn["first_name"] = $paypal["ipn_signup_vars"]["first_name"];
                                     $ipn["last_name"] = $paypal["ipn_signup_vars"]["last_name"];
                                     $ipn["option_name1"] = $paypal["ipn_signup_vars"]["option_name1"];
                                     $ipn["option_selection1"] = $paypal["ipn_signup_vars"]["option_selection1"];
                                     $ipn["option_name2"] = $paypal["ipn_signup_vars"]["option_name2"];
                                     $ipn["option_selection2"] = $paypal["ipn_signup_vars"]["option_selection2"];
                                     $ipn["item_number"] = $paypal["ipn_signup_vars"]["item_number"];
                                     $ipn["item_name"] = $paypal["ipn_signup_vars"]["item_name"];
                                     $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));
                                 } else {
                                     if (!$processed) {
                                         // If nothing was processed, here we add a message to the logs indicating the status; which is being ignored.
                                         $paypal["s2member_log"][] = "Ignoring this status ( `" . $paypal["STATUS"] . "` ). It does NOT require any action on the part of s2Member.";
                                     }
                                 }
                             }
                             $logt = c_ws_plugin__s2member_utilities::time_details();
                             $logv = c_ws_plugin__s2member_utilities::ver_details();
                             $logm = c_ws_plugin__s2member_utilities::mem_details();
                             $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
                             $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                             $log2 = is_multisite() && !is_main_site() ? "paypal-payflow-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-payflow-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($paypal, 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;
 }
 /**
  * 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;
     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 (!empty($google["typ"]) && preg_match('/^google\\/payments\\/inapp\\/item\\/v[0-9]+\\/postback\\/buy$/i', $google["typ"]) && is_array($s2vars = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google)) && !empty($google["response"]["orderId"])) {
                 $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"] = $google["response"]["orderId"];
                 $ipn["custom"] = $s2vars["cs"];
                 $ipn["mc_gross"] = number_format($google["request"]["price"], 2, ".", "");
                 $ipn["mc_currency"] = strtoupper($google["request"]["currencyCode"]);
                 $ipn["tax"] = number_format((double) @$google["request"]["tax"], 2, ".", "");
                 $ipn["payer_email"] = $s2vars["em"];
                 $ipn["first_name"] = $s2vars["fn"];
                 $ipn["last_name"] = $s2vars["ln"];
                 $ipn["option_name1"] = $s2vars["rf"] ? "Referencing Customer ID" : "Originating Domain";
                 $ipn["option_selection1"] = $s2vars["rf"] ? $s2vars["rf"] : $_SERVER["HTTP_HOST"];
                 $ipn["option_name2"] = "Customer IP Address";
                 // IP Address.
                 $ipn["option_selection2"] = $s2vars["ip"];
                 $ipn["item_number"] = $s2vars["in"];
                 $ipn["item_name"] = $google["request"]["description"];
                 $ipn["s2member_paypal_proxy"] = "google";
                 $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 (!empty($google["typ"]) && preg_match('/^google\\/payments\\/inapp\\/subscription\\/v[0-9]+\\/postback\\/buy$/i', $google["typ"]) && is_array($s2vars = c_ws_plugin__s2member_pro_google_utilities::google_parse_s2vars($google)) && !empty($google["response"]["orderId"])) {
                     $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"] = $google["response"]["orderId"];
                     $ipn["txn_id"] = $google["response"]["orderId"];
                     $ipn["recurring"] = $s2vars["rr"];
                     $ipn["custom"] = $s2vars["cs"];
                     $ipn["period1"] = $s2vars["p1"];
                     $ipn["period3"] = $s2vars["p3"];
                     $ipn["mc_amount1"] = $ipn["mc_gross"] = number_format($google["request"]["initialPayment"]["price"], 2, ".", "");
                     $ipn["mc_currency"] = strtoupper($google["request"]["initialPayment"]["currencyCode"]);
                     $ipn["tax"] = number_format((double) @$google["request"]["initialPayment"]["tax"], 2, ".", "");
                     $ipn["mc_amount3"] = number_format($google["request"]["recurrence"]["price"], 2, ".", "");
                     $ipn["payer_email"] = $s2vars["em"];
                     $ipn["first_name"] = $s2vars["fn"];
                     $ipn["last_name"] = $s2vars["ln"];
                     $ipn["option_name1"] = $s2vars["rf"] ? "Referencing Customer ID" : "Originating Domain";
                     $ipn["option_selection1"] = $s2vars["rf"] ? $s2vars["rf"] : $_SERVER["HTTP_HOST"];
                     $ipn["option_name2"] = "Customer IP Address";
                     // IP Address.
                     $ipn["option_selection2"] = $s2vars["ip"];
                     $ipn["item_number"] = $s2vars["in"];
                     $ipn["item_name"] = $google["request"]["description"];
                     $ipn["s2member_paypal_proxy"] = "google";
                     $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 (!empty($google["typ"]) && preg_match('/^google\\/payments\\/inapp\\/subscription\\/v[0-9]+\\/canceled$/i', $google["typ"]) && !empty($google["response"]["statusCode"]) && preg_match("/^SUBSCRIPTION_CANCELED\$/i", $google["response"]["statusCode"]) && !empty($google["response"]["orderId"]) && ($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(false, $google["response"]["orderId"]))) {
                         $google["s2member_log"][] = "Google transaction identified as ( `SUBSCRIPTION_CANCELED` ).";
                         $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"] = $google["response"]["orderId"];
                         $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_number"] = $ipn_signup_vars["item_number"];
                         $ipn["item_name"] = $ipn_signup_vars["item_name"];
                         $ipn["s2member_paypal_proxy"] = "google";
                         $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 (!$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.
         */
         $google["s2member_log"][] = "Sending Google an acknowlegment w/ order ID.";
         /*
         If debugging/logging is enabled; we need to append $google 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() ? "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, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($google, true)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         status_header(200);
         // Send a 200 OK status header.
         header("Content-Type: text/plain");
         // Google expects text/plain here.
         while (@ob_end_clean()) {
         }
         // Clean any existing output buffers.
         exit(!empty($google["response"]["orderId"]) ? $google["response"]["orderId"] : "");
     }
 }
 /**
  * Handles Authorize.Net IPN URL processing.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action('init');``
  */
 public static function authnet_notify()
 {
     global $current_site, $current_blog;
     // For Multisite support.
     if (!empty($_GET['s2member_pro_authnet_notify']) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_api_login_id']) {
         @ignore_user_abort(TRUE);
         // Continue processing even if/when connection is broken by the sender.
         if (is_array($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_postvars()) && ($_authnet = $authnet)) {
             $processing = $processed = FALSE;
             // Initialize these flags.
             $authnet['s2member_log'][] = 'IPN received on: ' . date('D M j, Y g:i:s a T');
             $authnet['s2member_log'][] = 's2Member POST vars verified with Authorize.Net.';
             if ($authnet['x_subscription_id'] && $authnet['x_subscription_paynum'] && $authnet['x_response_code'] === '1') {
                 if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                     $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / PAYMENT #' . $authnet['x_subscription_paynum'] . '`).';
                     if ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($authnet['x_subscription_id'])) {
                         delete_user_option($user_id, 's2member_authnet_payment_failures');
                         $authnet['s2member_log'][] = 'Successful payment. Resetting payment failures to `0` for this subscription.';
                     }
                     $authnet['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` (`subscr_payment`).';
                     $authnet['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'] = $authnet['x_subscription_id'];
                     $ipn['txn_id'] = $authnet['x_trans_id'];
                     $ipn['custom'] = $authnet['s2_custom'];
                     $ipn['mc_gross'] = number_format($authnet['x_amount'], 2, '.', '');
                     $ipn['mc_currency'] = strtoupper(!empty($authnet['s2_currency']) ? $authnet['s2_currency'] : 'USD');
                     $ipn['tax'] = number_format($authnet['x_tax'], 2, '.', '');
                     $ipn['payer_email'] = $authnet['x_email'];
                     $ipn['first_name'] = $authnet['x_first_name'];
                     $ipn['last_name'] = $authnet['x_last_name'];
                     $ipn['option_name1'] = 'Referencing Customer ID';
                     $ipn['option_selection1'] = $authnet['x_subscription_id'];
                     $ipn['option_name2'] = 'Customer IP Address';
                     $ipn['option_selection2'] = NULL;
                     $ipn['item_number'] = $authnet['s2_invoice'];
                     $ipn['item_name'] = $authnet['x_description'];
                     $ipn['s2member_paypal_proxy'] = 'authnet';
                     $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));
                 } else {
                     $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / PAYMENT #' . $authnet['x_subscription_paynum'] . '`).';
                     $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.';
                 }
             } else {
                 if ($authnet['x_subscription_id'] && $authnet['x_subscription_paynum'] && preg_match('/^(2|3)$/', $authnet['x_response_code'])) {
                     if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                         if ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($authnet['x_subscription_id'])) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures'] && ($current_payment_failures = get_user_option('s2member_authnet_payment_failures', $user_id)) + 1 >= $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures']) {
                                 $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                                 $authnet['s2member_log'][] = 'This subscription has `' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures'] . '` or more failed payments.';
                                 $authnet['s2member_log'][] = 'Max failed payments. 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['x_subscription_id'];
                                 $ipn['custom'] = $authnet['s2_custom'];
                                 $ipn['period1'] = $authnet['s2_p1'];
                                 $ipn['period3'] = $authnet['s2_p3'];
                                 $ipn['payer_email'] = $authnet['x_email'];
                                 $ipn['first_name'] = $authnet['x_first_name'];
                                 $ipn['last_name'] = $authnet['x_last_name'];
                                 $ipn['option_name1'] = 'Referencing Customer ID';
                                 $ipn['option_selection1'] = $authnet['x_subscription_id'];
                                 $ipn['option_name2'] = 'Customer IP Address';
                                 $ipn['option_selection2'] = NULL;
                                 $ipn['item_number'] = $authnet['s2_invoice'];
                                 $ipn['item_name'] = $authnet['x_description'];
                                 $ipn['s2member_paypal_proxy'] = 'authnet';
                                 $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_authnet_utilities::authnet_arb_response(array('x_method' => 'cancel', 'x_subscription_id' => $authnet['x_subscription_id']));
                             } else {
                                 $current_payment_failures = get_user_option('s2member_authnet_payment_failures', $user_id);
                                 update_user_option($user_id, 's2member_authnet_payment_failures', $current_payment_failures + 1);
                                 $authnet['s2member_log'][] = 'Bumping payment failures for subscription: `' . $authnet['x_subscription_id'] . '`, to: `' . ($current_payment_failures + 1) . '`';
                                 $authnet['s2member_log'][] = 'Recording number of payment failures only. This does not require any action (at the moment) on the part of s2Member.';
                             }
                         } else {
                             $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                             $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference to an existing user/member.';
                         }
                     } else {
                         $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                         $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.';
                     }
                 } else {
                     if (!$processed) {
                         // If nothing was processed, here we add a message to the logs indicating the IPN was ignored.
                         $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT require any action on the part of s2Member.';
                     }
                 }
             }
         } else {
             $authnet['s2member_log'][] = 'Unable to verify POST vars. This is most likely related to an invalid Authorize.Net configuration. Please check: s2Member → Authorize.Net Options.';
             $authnet['s2member_log'][] = 'If you\'re absolutely SURE that your Authorize.Net 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 Authorize.Net over an HTTPS connection.';
             $authnet['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.';
             $authnet['s2member_log'][] = var_export($_REQUEST, TRUE);
             // Recording _POST + _GET vars for analysis and debugging.
         }
         /*
         If debugging/logging is enabled; we need to append $authnet 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() ? 'authnet-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'authnet-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($authnet, 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 Authorize.Net® IPN URL processing.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after handling IPN processing.
  */
 public static function authnet_notify()
 {
     global $current_site, $current_blog;
     /* For Multisite support. */
     /**/
     if (!empty($_GET["s2member_pro_authnet_notify"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_authnet_api_login_id"]) {
         @ignore_user_abort(true);
         /* Continue processing even if/when connection is broken by the sender. */
         /**/
         if (is_array($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_postvars()) && ($_authnet = $authnet)) {
             $authnet["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T");
             $authnet["s2member_log"][] = "s2Member POST vars verified with Authorize.Net®.";
             /**/
             if ($authnet["x_subscription_id"] && $authnet["x_subscription_paynum"] && $authnet["x_response_code"] === "1") {
                 if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                     $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `ARB / PAYMENT #" . $authnet["x_subscription_paynum"] . "` ).";
                     $authnet["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_payment` ).";
                     $authnet["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"] = $authnet["x_subscription_id"];
                     $ipn["txn_id"] = $authnet["x_trans_id"];
                     /**/
                     $ipn["custom"] = $authnet["s2_custom"];
                     /**/
                     $ipn["mc_gross"] = number_format($authnet["x_amount"], 2, ".", "");
                     $ipn["mc_currency"] = strtoupper("USD");
                     /* Auth.Net® uses USD. */
                     $ipn["tax"] = number_format($authnet["x_tax"], 2, ".", "");
                     /**/
                     $ipn["payer_email"] = $authnet["x_email"];
                     $ipn["first_name"] = $authnet["x_first_name"];
                     $ipn["last_name"] = $authnet["x_last_name"];
                     /**/
                     $ipn["option_name1"] = "Referencing Customer ID";
                     $ipn["option_selection1"] = $authnet["x_subscription_id"];
                     /**/
                     $ipn["option_name2"] = "Customer IP Address";
                     $ipn["option_selection2"] = null;
                     /**/
                     $ipn["item_number"] = $authnet["s2_invoice"];
                     $ipn["item_name"] = $authnet["x_description"];
                     /**/
                     $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 {
                     $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `ARB / PAYMENT #" . $authnet["x_subscription_paynum"] . "` ).";
                     $authnet["s2member_log"][] = "Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.";
                 }
             } else {
                 if ($authnet["x_subscription_id"] && $authnet["x_subscription_paynum"] && preg_match("/^(2|3)\$/", $authnet["x_response_code"])) {
                     if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                         $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `ARB / FAILED PAYMENT` ).";
                         $authnet["s2member_log"][] = "s2Member does NOT respond to individual failed payment notifications.";
                         $authnet["s2member_log"][] = "When multiple consecutive payments fail, s2Member is notified via ARB services.";
                         $authnet["s2member_log"][] = "This does not require any action ( at the moment ) on the part of s2Member.";
                     } else {
                         $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `ARB / FAILED PAYMENT` ).";
                         $authnet["s2member_log"][] = "Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.";
                     }
                 } else {
                     if (!$processed) {
                         /* If nothing was processed, here we add a message to the logs indicating the IPN was ignored. */
                         $authnet["s2member_log"][] = "Ignoring this IPN. The transaction does NOT require any action on the part of s2Member.";
                     }
                 }
             }
         } else {
             $authnet["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid Authorize.Net® configuration. Please check: s2Member -> Authorize.Net® Options.";
             $authnet["s2member_log"][] = "If you're absolutely SURE that your Authorize.Net® 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 Authorize.Net® over an HTTPS connection.";
             $authnet["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.";
             $authnet["s2member_log"][] = var_export($_REQUEST, true);
             /* Recording _POST + _GET vars for analysis and debugging. */
         }
         /*
         If debugging/logging is enabled; we need to append $authnet 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() ? "authnet-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "authnet-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);
                 }
             }
         }
         /**/
         status_header(200);
         /* Send a 200 OK status header. */
         header("Content-Type: text/plain; charset=utf-8");
         /* Content-Type text/plain with UTF-8. */
         eval('while (@ob_end_clean ());');
         /* End/clean all output buffers that may or may not exist. */
         /**/
         exit;
         /* Exit now. */
     }
 }
 /**
  * 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"] = !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 (($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"])) {
                             if (preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/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"];
                                     $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));
                                 }
                                 if ($paypal = array("METHOD" => "ManageRecurringPaymentsProfileStatus", "ACTION" => "Cancel", "PROFILEID" => $cur__subscr_id)) {
                                     c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                     $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 {
                                 if (preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_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 {
                                     $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 && !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 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;
             }
         }
     }
 }
 /**
  * Connect to and process cancellations/refunds/chargebacks/etc via Payflow.
  *
  * 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_payflow_ipns_per_process');``.
  *
  * @package s2Member\PayPal
  * @since 120514
  *
  * @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.
  */
 public static function payflow_service($vars)
 {
     global $wpdb;
     /** @var $wpdb \wpdb */
     global $current_site, $current_blog;
     $counter = 0;
     // Initialize counter at zero.
     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_payflow_api_username']) {
         $scan_time = apply_filters('ws_plugin__s2member_pro_payflow_status_scan_time', strtotime('-1 day'), get_defined_vars());
         $per_process = apply_filters('ws_plugin__s2member_pro_payflow_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` = 'paypal' 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)) {
                     $processed = FALSE;
                     // Initialize and/or reset all of these variables.
                     unset($paypal, $subscr_id, $processing, $ipn, $log4, $_log4, $log2, $logs_dir);
                     if (($subscr_id = get_user_option('s2member_subscr_id', $user_id)) && !get_user_option('s2member_auto_eot_time', $user_id)) {
                         if ($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id)) {
                             $paypal['ipn_signup_vars'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(FALSE, $subscr_id);
                             if ($paypal['ipn_signup_vars'] && preg_match('/expired|too many failures/i', $paypal['STATUS'])) {
                                 $paypal['s2member_log'][] = 'Payflow IPN via polling, processed on: ' . date('D M j, Y g:i:s a T');
                                 $paypal['s2member_log'][] = 'Payflow transaction identified as ( `SUBSCRIPTION EXPIRATION` ).';
                                 $paypal['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `subscr_eot` ).';
                                 $paypal['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'] = $paypal['ipn_signup_vars']['subscr_id'];
                                 $ipn['custom'] = $paypal['ipn_signup_vars']['custom'];
                                 $ipn['period1'] = $paypal['ipn_signup_vars']['period1'];
                                 $ipn['period3'] = $paypal['ipn_signup_vars']['period3'];
                                 $ipn['payer_email'] = $paypal['ipn_signup_vars']['payer_email'];
                                 $ipn['first_name'] = $paypal['ipn_signup_vars']['first_name'];
                                 $ipn['last_name'] = $paypal['ipn_signup_vars']['last_name'];
                                 $ipn['option_name1'] = $paypal['ipn_signup_vars']['option_name1'];
                                 $ipn['option_selection1'] = $paypal['ipn_signup_vars']['option_selection1'];
                                 $ipn['option_name2'] = $paypal['ipn_signup_vars']['option_name2'];
                                 $ipn['option_selection2'] = $paypal['ipn_signup_vars']['option_selection2'];
                                 $ipn['item_number'] = $paypal['ipn_signup_vars']['item_number'];
                                 $ipn['item_name'] = $paypal['ipn_signup_vars']['item_name'];
                                 $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));
                             } else {
                                 if ($paypal['ipn_signup_vars'] && preg_match('/(suspended|canceled|terminated|deactivated)/i', $paypal['STATUS'])) {
                                     $paypal['s2member_log'][] = 'Payflow IPN via polling, processed on: ' . date('D M j, Y g:i:s a T');
                                     $paypal['s2member_log'][] = 'Payflow transaction identified as ( `SUBSCRIPTION ' . strtoupper($paypal['STATUS']) . '` ).';
                                     $paypal['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` ( `subscr_cancel` ).';
                                     $paypal['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'] = $paypal['ipn_signup_vars']['subscr_id'];
                                     $ipn['custom'] = $paypal['ipn_signup_vars']['custom'];
                                     $ipn['period1'] = $paypal['ipn_signup_vars']['period1'];
                                     $ipn['period3'] = $paypal['ipn_signup_vars']['period3'];
                                     $ipn['payer_email'] = $paypal['ipn_signup_vars']['payer_email'];
                                     $ipn['first_name'] = $paypal['ipn_signup_vars']['first_name'];
                                     $ipn['last_name'] = $paypal['ipn_signup_vars']['last_name'];
                                     $ipn['option_name1'] = $paypal['ipn_signup_vars']['option_name1'];
                                     $ipn['option_selection1'] = $paypal['ipn_signup_vars']['option_selection1'];
                                     $ipn['option_name2'] = $paypal['ipn_signup_vars']['option_name2'];
                                     $ipn['option_selection2'] = $paypal['ipn_signup_vars']['option_selection2'];
                                     $ipn['item_number'] = $paypal['ipn_signup_vars']['item_number'];
                                     $ipn['item_name'] = $paypal['ipn_signup_vars']['item_name'];
                                     $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));
                                 } else {
                                     if (!$processed && !$paypal['ipn_signup_vars']) {
                                         $paypal['s2member_log'][] = 'Ignoring status (`' . $paypal['STATUS'] . '`).' . ' The user has no IPN Signup Vars recorded on-site by s2Member.';
                                     } else {
                                         if (!$processed) {
                                             $paypal['s2member_log'][] = 'Ignoring status (`' . $paypal['STATUS'] . '`).' . ' It does NOT require any action on the part of s2Member.';
                                         }
                                     }
                                 }
                             }
                             $logt = c_ws_plugin__s2member_utilities::time_details();
                             $logv = c_ws_plugin__s2member_utilities::ver_details();
                             $logm = c_ws_plugin__s2member_utilities::mem_details();
                             $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\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() ? 'paypal-payflow-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'paypal-payflow-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($paypal, 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.
                 }
             }
         }
     }
 }
 /**
  * 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 AliPay® IPN URL processing.
  *
  * @package s2Member\AliPay
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after handling the Notification.
  */
 public static function alipay_notify()
 {
     global $current_site, $current_blog;
     /* For Multisite support. */
     /**/
     if (!empty($_POST["notify_type"]) && preg_match("/^trade_status_sync\$/i", $_POST["notify_type"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_seller_email"]) {
         @ignore_user_abort(true);
         /* Continue processing even if/when connection is broken by the sender. */
         /**/
         if (is_array($alipay = c_ws_plugin__s2member_pro_alipay_utilities::alipay_postvars()) && ($_alipay = $alipay)) {
             $alipay["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T");
             $alipay["s2member_log"][] = "s2Member POST vars verified through a POST back to AliPay®.";
             /**/
             if (!is_array($alipay_already_p = get_transient("s2m_" . md5("s2member_pro_alipay_notify_ids"))) || !in_array($alipay["notify_id"], $alipay_already_p)) {
                 $alipay_already_p = is_array($alipay_already_p) ? array_push($alipay_already_p, $alipay["notify_id"]) : array($alipay["notify_id"]);
                 set_transient("s2m_" . md5("s2member_pro_alipay_notify_ids"), array_slice(array_unique($alipay_already_p), 0, 1000), 31556926);
                 /**/
                 if (preg_match("/^(TRADE_FINISHED|TRADE_SUCCESS)\$/i", $alipay["trade_status"]) && !$alipay["refund_status"]) {
                     $alipay["s2member_log"][] = "AliPay® transaction identified as ( `TRADE_FINISHED|TRADE_SUCCESS` ).";
                     $alipay["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `web_accept` ).";
                     $alipay["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                     /**/
                     list($alipay["invoice"], $alipay["item_number"], $alipay["referencing"], $alipay["customer_ip"]) = preg_split("/~/", $alipay["out_trade_no"]);
                     list($alipay["first_name"], $alipay["last_name"]) = preg_split("/@/", $alipay["buyer_email"], 2);
                     /**/
                     $ipn = array();
                     /* Reset. */
                     /**/
                     $ipn["txn_type"] = "web_accept";
                     /**/
                     $ipn["txn_id"] = $alipay["trade_no"];
                     /**/
                     $ipn["custom"] = $alipay["extra_common_param"];
                     /**/
                     $ipn["mc_gross"] = number_format($alipay["total_fee"], 2, ".", "");
                     $ipn["mc_currency"] = strtoupper("CNY");
                     /* Yuan. */
                     $ipn["tax"] = number_format("0.00", 2, ".", "");
                     /**/
                     $ipn["payer_email"] = $alipay["buyer_email"];
                     $ipn["first_name"] = $alipay["first_name"];
                     $ipn["last_name"] = $alipay["last_name"];
                     /**/
                     $ipn["option_name1"] = $alipay["referencing"] ? "Referencing Customer ID" : "Originating Domain";
                     $ipn["option_selection1"] = $alipay["referencing"] ? $alipay["referencing"] : $_SERVER["HTTP_HOST"];
                     /**/
                     $ipn["option_name2"] = "Customer IP Address";
                     $ipn["option_selection2"] = $alipay["customer_ip"];
                     /**/
                     $ipn["item_number"] = $alipay["item_number"];
                     $ipn["item_name"] = $alipay["body"];
                     /**/
                     $ipn_q = "&s2member_paypal_proxy=alipay&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("/^(TRADE_CLOSED|TRADE_SUCCESS)\$/i", $alipay["trade_status"]) && $alipay["refund_status"]) {
                         $alipay["s2member_log"][] = "AliPay® transaction identified as ( `REFUND_SUCCESS` ).";
                         $alipay["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `payment_status` ( `refunded` ).";
                         $alipay["s2member_log"][] = "Please check PayPal® IPN logs for further processing details.";
                         /**/
                         list($alipay["invoice"], $alipay["item_number"], $alipay["referencing"], $alipay["customer_ip"]) = preg_split("/~/", $alipay["out_trade_no"]);
                         list($alipay["first_name"], $alipay["last_name"]) = preg_split("/@/", $alipay["buyer_email"], 2);
                         /**/
                         $ipn = array();
                         /* Reset. */
                         /**/
                         $ipn["payment_status"] = "refunded";
                         /**/
                         $ipn["parent_txn_id"] = $alipay["trade_no"];
                         /**/
                         $ipn["custom"] = $alipay["extra_common_param"];
                         /**/
                         $ipn["mc_fee"] = "-" . number_format("0.00", 2, ".", "");
                         $ipn["mc_gross"] = "-" . number_format(abs($alipay["total_fee"]), 2, ".", "");
                         $ipn["mc_currency"] = strtoupper("CNY");
                         /* Yuan. */
                         $ipn["tax"] = "-" . number_format("0.00", 2, ".", "");
                         /**/
                         $ipn["payer_email"] = $alipay["buyer_email"];
                         $ipn["first_name"] = $alipay["first_name"];
                         $ipn["last_name"] = $alipay["last_name"];
                         /**/
                         $ipn["option_name1"] = $alipay["referencing"] ? "Referencing Customer ID" : "Originating Domain";
                         $ipn["option_selection1"] = $alipay["referencing"] ? $alipay["referencing"] : $_SERVER["HTTP_HOST"];
                         /**/
                         $ipn["option_name2"] = "Customer IP Address";
                         $ipn["option_selection2"] = $alipay["customer_ip"];
                         /**/
                         $ipn["item_number"] = $alipay["item_number"];
                         $ipn["item_name"] = $alipay["body"];
                         /**/
                         $ipn_q = "&s2member_paypal_proxy=alipay&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 {
                         $alipay["s2member_log"][] = "Ignoring this IPN request. The status does NOT require any action on the part of s2Member.";
                     }
                 }
             } else {
                 $alipay["s2member_log"][] = "Ignoring duplicate IPN. s2Member has already processed AliPay® Notification ID: " . $alipay["notify_id"] . ".";
             }
         } else {
             $alipay["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid AliPay® configuration. Please check: s2Member -> AliPay® Options.";
             $alipay["s2member_log"][] = "If you're absolutely SURE that your AliPay® 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 AliPay® over an HTTPS connection.";
             $alipay["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.";
             $alipay["s2member_log"][] = var_export($_REQUEST, true);
             /* Recording _POST + _GET vars for analysis and debugging. */
         }
         /*
         If debugging/logging is enabled; we need to append $alipay 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() ? "alipay-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "alipay-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($alipay, true) . "\n\n", FILE_APPEND);
                 }
             }
         }
         /**/
         status_header(200);
         /* 200 OK status header. */
         header("Content-Type: text/plain; charset=utf-8");
         /* Content-Type text/plain with UTF-8. */
         eval('while (@ob_end_clean ());');
         /* End/clean all output buffers that may or may not exist. */
         /**/
         exit("success");
         /* Exit now with "success". */
     }
 }
 /**
  * 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 processing of Pro-Form cancellations.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_cancellation()
 {
     if (!empty($_POST['s2member_pro_stripe_cancellation']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_cancellation']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-cancellation')) {
         $GLOBALS['ws_plugin__s2member_pro_stripe_cancellation_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_cancellation_response'];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_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_stripe_cancellation_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         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('cancellation', $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($cur__subscr_cid = get_user_option('s2member_subscr_cid')) && ($cur__subscr_id = get_user_option('s2member_subscr_id'))) {
                         if (is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
                             if (!preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
                                 if (is_object(c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
                                     if (is_array($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars())) {
                                         $ipn['txn_type'] = 'subscr_cancel';
                                         $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
                                         $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['s2member_paypal_proxy'] = 'stripe';
                                         $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));
                                     }
                                     $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('API failure. Please contact Support for assistance.', 's2member-front', 's2member'), '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('<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 {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
Esempio n. 19
0
 /**
  * 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\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;
             }
         }
     }
 }
Esempio n. 21
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";
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * 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. */
     }
 }
Esempio n. 24
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;
 }
 /**
  * Get ``$_POST`` or ``$_REQUEST`` vars from PayPal.
  *
  * @package s2Member\PayPal
  * @since 3.5
  *
  * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false.
  */
 public static function paypal_postvars()
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_paypal_postvars", get_defined_vars());
     unset($__refs, $__v);
     /*
     Custom conditionals can be applied by filters.
     */
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     if (!($postvars = apply_filters("ws_plugin__s2member_during_paypal_postvars_conditionals", array(), get_defined_vars()))) {
         unset($__refs, $__v);
         if (!empty($_GET["tx"]) && empty($_GET["s2member_paypal_proxy"])) {
             $postback["tx"] = $_GET["tx"];
             $postback["cmd"] = "_notify-synch";
             $postback["at"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"];
             $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
             if (preg_match("/^SUCCESS/i", $response = trim(c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/cgi-bin/webscr", $postback, array("timeout" => 20))))) {
                 foreach (preg_split("/[\r\n]+/", preg_replace("/^SUCCESS/i", "", $response)) as $varline) {
                     list($key, $value) = preg_split("/\\=/", $varline, 2);
                     if (strlen($key = trim($key)) && strlen($value = trim($value))) {
                         $postvars[$key] = trim(stripslashes(urldecode($value)));
                     }
                 }
                 if (!empty($postvars["charset"]) && function_exists("mb_convert_encoding")) {
                     foreach ($postvars as &$value) {
                         $value = @mb_convert_encoding($value, "UTF-8", $postvars["charset"] === "gb2312" ? "GBK" : $postvars["charset"]);
                     }
                 }
                 return apply_filters("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars());
             } else {
                 return false;
             }
         } else {
             if (!empty($_REQUEST) && is_array($postvars = stripslashes_deep($_REQUEST))) {
                 foreach ($postvars as $key => $value) {
                     if (preg_match("/^s2member_/", $key)) {
                         unset($postvars[$key]);
                     }
                 }
                 $postback = $postvars;
                 $postback["cmd"] = "_notify-validate";
                 $postvars = c_ws_plugin__s2member_utils_strings::trim_deep($postvars);
                 if (!empty($postvars["charset"]) && function_exists("mb_convert_encoding")) {
                     foreach ($postvars as &$value) {
                         $value = @mb_convert_encoding($value, "UTF-8", $postvars["charset"] === "gb2312" ? "GBK" : $postvars["charset"]);
                     }
                 }
                 $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                 if (!empty($_REQUEST["s2member_paypal_proxy"]) && !empty($_REQUEST["s2member_paypal_proxy_verification"]) && $_REQUEST["s2member_paypal_proxy_verification"] === c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()) {
                     return apply_filters("ws_plugin__s2member_paypal_postvars", array_merge($postvars, array("proxy_verified" => $_REQUEST["s2member_paypal_proxy"])), get_defined_vars());
                 } else {
                     if (empty($_POST) && !empty($_GET["s2member_paypal_proxy"]) && !empty($_GET["s2member_paypal_proxy_verification"]) && c_ws_plugin__s2member_utils_urls::s2member_sig_ok($_SERVER["REQUEST_URI"], false, false, "s2member_paypal_proxy_verification")) {
                         return apply_filters("ws_plugin__s2member_paypal_postvars", array_merge($postvars, array("proxy_verified" => $_GET["s2member_paypal_proxy"])), get_defined_vars());
                     } else {
                         if (trim(strtolower(c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/cgi-bin/webscr", $postback, array("timeout" => 20)))) === "verified") {
                             return apply_filters("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars());
                         } else {
                             return false;
                         }
                     }
                 }
             } else {
                 return false;
             }
         }
     } else {
         unset($__refs, $__v);
         return apply_filters("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars());
     }
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package s2Member\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function paypal_checkout()
 {
     if (!empty($_POST["s2member_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["s2member_pro_paypal_checkout"];
         $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($post_vars));
         /* And Filter. */
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__s2member_pro_paypal_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__s2member_pro_paypal_utilities::paypal_cost($cp_2gbp_attr["ta"], $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 $use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
                 $is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
                 /* Selling Independent Custom Capabilities? */
                 /**/
                 if (empty($_GET["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /* No notes. */
                         /**/
                         if ($use_recurring_profile) {
                             $paypal_set_xco["L_BILLINGTYPE0"] = "RecurringPayments";
                             $paypal_set_xco["L_BILLINGAGREEMENTDESCRIPTION0"] = $cost_calculations["desc"];
                             /**/
                             if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                 /**/
                                 $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                 $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                 /**/
                                 if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                     /**/
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                     /* Always (1). */
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                 } else {
                                     $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                     $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                     /**/
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                     /* Always (1). */
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                 }
                             }
                         } else {
                             $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         }
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $user ? $user->user_email : $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("s2member_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if ($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (!($cur__subscr_id = get_user_option("s2member_subscr_id")) || !($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                             $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                             /**/
                             if (!($_paypal = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($_paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal_xco_details)) && empty($_paypal_xco_details["__error"])) {
                                     $_paypal["METHOD"] = "DoExpressCheckoutPayment";
                                     /**/
                                     $_paypal["TOKEN"] = $_paypal_xco_details["TOKEN"];
                                     $_paypal["PAYERID"] = $_paypal_xco_details["PAYERID"];
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                     $_paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                 } else {
                                     $_paypal["METHOD"] = "DoDirectPayment";
                                     $_paypal["PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["EMAIL"] = $user->user_email;
                                     $_paypal["FIRSTNAME"] = $post_vars["first_name"];
                                     $_paypal["LASTNAME"] = $post_vars["last_name"];
                                     $_paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $_paypal["DESC"] = $cost_calculations["desc"];
                                     $_paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                     /**/
                                     $_paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $_paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $_paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $_paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $_paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $_paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $_paypal["STREET"] = $post_vars["street"];
                                     $_paypal["CITY"] = $post_vars["city"];
                                     $_paypal["STATE"] = $post_vars["state"];
                                     $_paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $_paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__s2member_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && (!empty($_paypal_xco_details) && empty($_paypal_xco_details["__error"]) && ($paypal_xco_details = $_paypal_xco_details) || ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"]))) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!$_paypal || ($_paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal)) && empty($_paypal["__error"])) {
                                 if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $new__txn_id = $_paypal && !empty($_paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $_paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                     $new__txn_id = !$new__txn_id && $_paypal && !empty($_paypal["TRANSACTIONID"]) ? $_paypal["TRANSACTIONID"] : $new__txn_id;
                                     $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                     $old__subscr_id = get_user_option("s2member_subscr_id");
                                     $new__subscr_id = $paypal["PROFILEID"];
                                     /**/
                                     if (!($ipn = array())) {
                                         $ipn["txn_type"] = "subscr_signup";
                                         $ipn["subscr_id"] = $new__subscr_id;
                                         $ipn["custom"] = $post_vars["attr"]["custom"];
                                         /**/
                                         $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                         /**/
                                         $ipn["period1"] = $period1;
                                         $ipn["period3"] = $period3;
                                         /**/
                                         $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                         $ipn["mc_amount3"] = $cost_calculations["total"];
                                         /**/
                                         $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                         /**/
                                         $ipn["mc_currency"] = $cost_calculations["cur"];
                                         $ipn["tax"] = $cost_calculations["tax"];
                                         /**/
                                         $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                         /**/
                                         $ipn["payer_email"] = $user->user_email;
                                         $ipn["first_name"] = $post_vars["first_name"];
                                         $ipn["last_name"] = $post_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = "Referencing Customer ID";
                                         $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                         /**/
                                         $ipn["option_name2"] = "Customer IP Address";
                                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                         /**/
                                         $ipn["item_name"] = $cost_calculations["desc"];
                                         $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         /**/
                                         $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                         $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                         /* Use as first payment? */
                                         $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         /**/
                                         $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                     }
                                     /**/
                                     if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                         $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                         $paypal["ACTION"] = "Cancel";
                                         /**/
                                         c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                     }
                                     /**/
                                     $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                     /**/
                                     if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 $global_response = array("response" => $_paypal["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         if ($use_recurring_profile && !is_user_logged_in()) {
                             $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__s2member_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             if (!($_paypal = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($_paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal_xco_details)) && empty($_paypal_xco_details["__error"])) {
                                     $_paypal["METHOD"] = "DoExpressCheckoutPayment";
                                     /**/
                                     $_paypal["TOKEN"] = $_paypal_xco_details["TOKEN"];
                                     $_paypal["PAYERID"] = $_paypal_xco_details["PAYERID"];
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                     $_paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                 } else {
                                     $_paypal["METHOD"] = "DoDirectPayment";
                                     $_paypal["PAYMENTACTION"] = "Sale";
                                     /**/
                                     $_paypal["EMAIL"] = $post_vars["email"];
                                     $_paypal["FIRSTNAME"] = $post_vars["first_name"];
                                     $_paypal["LASTNAME"] = $post_vars["last_name"];
                                     $_paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $_paypal["DESC"] = $cost_calculations["desc"];
                                     $_paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                     /**/
                                     if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["trial_sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["trial_tax"];
                                         $_paypal["AMT"] = $cost_calculations["trial_total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["trial_sub_total"];
                                     } else {
                                         $_paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                         $_paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                         $_paypal["TAXAMT"] = $cost_calculations["tax"];
                                         $_paypal["AMT"] = $cost_calculations["total"];
                                         /**/
                                         $_paypal["L_QTY0"] = "1";
                                         /* Always (1). */
                                         $_paypal["L_NAME0"] = $cost_calculations["desc"];
                                         $_paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         $_paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                     }
                                     /**/
                                     $_paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $_paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $_paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $_paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $_paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $_paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $_paypal["STREET"] = $post_vars["street"];
                                     $_paypal["CITY"] = $post_vars["city"];
                                     $_paypal["STATE"] = $post_vars["state"];
                                     $_paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $_paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $post_vars["email"];
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__s2member_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && (!empty($_paypal_xco_details) && empty($_paypal_xco_details["__error"]) && ($paypal_xco_details = $_paypal_xco_details) || ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"]))) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (!$_paypal || ($_paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($_paypal)) && empty($_paypal["__error"])) {
                                 if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $new__txn_id = $_paypal && !empty($_paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $_paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                     $new__txn_id = !$new__txn_id && $_paypal && !empty($_paypal["TRANSACTIONID"]) ? $_paypal["TRANSACTIONID"] : $new__txn_id;
                                     $new__subscr_id = $paypal["PROFILEID"];
                                     /**/
                                     if (!($ipn = array())) {
                                         $ipn["txn_type"] = "subscr_signup";
                                         $ipn["subscr_id"] = $new__subscr_id;
                                         $ipn["custom"] = $post_vars["attr"]["custom"];
                                         /**/
                                         $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                         /**/
                                         $ipn["period1"] = $period1;
                                         $ipn["period3"] = $period3;
                                         /**/
                                         $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                         $ipn["mc_amount3"] = $cost_calculations["total"];
                                         /**/
                                         $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                         /**/
                                         $ipn["mc_currency"] = $cost_calculations["cur"];
                                         $ipn["tax"] = $cost_calculations["tax"];
                                         /**/
                                         $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                         /**/
                                         $ipn["payer_email"] = $post_vars["email"];
                                         $ipn["first_name"] = $post_vars["first_name"];
                                         $ipn["last_name"] = $post_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = "Originating Domain";
                                         $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                         /**/
                                         $ipn["option_name2"] = "Customer IP Address";
                                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                         /**/
                                         $ipn["item_name"] = $cost_calculations["desc"];
                                         $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         /**/
                                         $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                         $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                         /* Use as first payment? */
                                         $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     }
                                     /**/
                                     if (!($create_user = array())) {
                                         $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                         /* Fake this too. */
                                         /**/
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                                 /**/
                                                 if (isset($post_vars["custom_fields"][$field_var])) {
                                                     $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                 }
                                             }
                                         }
                                         /**/
                                         $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("paypal");
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                         /* Fake this too. */
                                         /**/
                                         $create_user["user_login"] = $post_vars["username"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                         $create_user["user_pass"] = wp_generate_password();
                                         /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
                                         $create_user["user_email"] = $post_vars["email"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                     }
                                     /**/
                                     if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     } else {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             update_user_option($new__user_id, "default_password_nag", true, true);
                                             /* Password nag. */
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 $global_response = array("response" => $_paypal["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                                 if ($is_independent_ccaps_sale || !($cur__subscr_id = get_user_option("s2member_subscr_id")) || !($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                                     /**/
                                     if (!($paypal = array())) {
                                         if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $user->user_email;
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $old__subscr_id = get_user_option("s2member_subscr_id");
                                         $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
                                         $new__subscr_id = $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = $new__txn_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $user->user_email;
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Referencing Customer ID";
                                             $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                             /**/
                                             $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         }
                                         /**/
                                         if (!$is_independent_ccaps_sale) {
                                             /* Independent? */
                                             if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                                 $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                                 $paypal["ACTION"] = "Cancel";
                                                 /**/
                                                 c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
                                             }
                                         }
                                         /**/
                                         if ($is_independent_ccaps_sale) {
                                             /* Independent? */
                                             setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
                                         }
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 }
                             } else {
                                 if (!$use_recurring_profile && !is_user_logged_in()) {
                                     if (!($paypal = array())) {
                                         if ($_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $post_vars["email"];
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $new__subscr_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $post_vars["email"];
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Originating Domain";
                                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&s2member_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         }
                                         /**/
                                         if (!($create_user = array())) {
                                             $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                             /* Fake this too. */
                                             /**/
                                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                                     /**/
                                                     if (isset($post_vars["custom_fields"][$field_var])) {
                                                         $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                     }
                                                 }
                                             }
                                             /**/
                                             $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("paypal");
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                             /* Fake this too. */
                                             /**/
                                             $create_user["user_login"] = $post_vars["username"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                             $create_user["user_pass"] = wp_generate_password();
                                             /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
                                             $create_user["user_email"] = $post_vars["email"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                         }
                                         /**/
                                         if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         } else {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 update_user_option($new__user_id, "default_password_nag", true, true);
                                                 /* Password nag. */
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form 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-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;
             }
         }
     }
 }
 public function __construct()
 {
     echo '<div class="wrap ws-menu-page">' . "\n";
     /**/
     echo '<div id="icon-plugins" class="icon32"><br /></div>' . "\n";
     echo '<h2>s2Member® 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">' . "\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>This plugin works in conjunction with <a href="http://www.s2member.com/paypal" target="_blank" rel="external">PayPal® Website 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://pages.ebay.com/help/buy/questions/upgrade-paypal-account.html" target="_blank" rel="external">upgraded</a> from a Personal account to a Business account, simply by going to the `Profile` button under the `My Account` tab, selecting the `Personal Business Information` button, and then clicking the `Upgrade Your Account` button.</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://www.s2member.com/paypal-profile-api-access" target="_blank" rel="external">PayPal® API Credentials</a>. Log into your PayPal® account, and navigate to <code>Profile -> API Access (or Request API Credentials)</code>. You\'ll choose <code>( Request API Signature )</code>.</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-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 'Enter the email address you\'ve associated with your PayPal® Business account.' . "\n";
         echo '</td>' . "\n";
         /**/
         echo '</tr>' . "\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: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\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: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\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: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\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://www.s2member.com/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 *encrypted* PayPal® Buttons. This improves security against fraudulent transactions. For extra security, you should update your PayPal® account too, under: <code>My Profile -> Website Payment Preferences</code>. 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:<br /><code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) . '</code></em>' . "\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_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 /><code>Account Profile -> Instant Payment Notification Preferences</code></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(site_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>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="display:none;">' . "\n";
         echo '<p><em><strong>*Quick Tip*</strong> In addition to the <a href="http://www.s2member.com/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>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="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(site_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 ALWAYS 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 /><code>Account Profile -> Website Payment Preferences</code></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(site_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(site_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 MUST 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 <em>Profile -> Website Payment Preferences</em> 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>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="display:none;">' . "\n";
         echo '<p><em><strong>*Quick Tip*</strong> In addition to the <a href="http://www.s2member.com/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 dynamically sets the Auto-Return URL 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.</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>' . "\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>%%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. This value is <code>always > 0</code>, no matter what. [ <a href="#" onclick="alert(\'This is how much the Subscription costs after an Initial Period expires. The %%regular%% rate is always > 0. 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>' . "\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 '</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_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: <code>s2Member -> Restriction Options -> Specific Post/Page Access</code> ). 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>' . "\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>%%amount%%</code> = The full Amount that you charged for Specific Post/Page Access. This value will <code>always be > 0</code>.</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>' . "\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 '</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.</p>' . "\n";
         echo '<p>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(site_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 '<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-triggers-immediate-eot">' . "\n";
         echo '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"' : '') . '>Neither ( I\'ll review these two events manually )</option>' . "\n";
         echo '<option value="refunds"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds" ? ' selected="selected"' : '') . '>Refunds ( refunds 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 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"' : '') . '>Refunds/Reversals ( ALWAYS trigger an immediate EOT action )</option>' . "\n";
         echo '</select><br />' . "\n";
         echo 'This setting will <a href="#" onclick="alert(\'A Refund/Reversal Notification will ALWAYS be processed internally by s2Member, even if no action is taken by s2Member. This way you\\\'ll have the full ability to listen for these two events on your own; if you prefer ( optional ). For more information, check your Dashboard under: `s2Member -> API Notifications -> Refunds/Reversals`.\'); return false;">NOT affect</a> s2Member\'s internal API Notifications for Refund/Reversal events.' . "\n";
         echo '</td>' . "\n";
         /**/
         echo '</tr>' . "\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 '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.' . "\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 '<div class="ws-menu-page-hr"></div>' . "\n";
     /**/
     echo '<p class="submit"><input type="submit" class="button-primary" 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";
 }