/** * Handles the Shortcode for: `[s2Get /]`. * * @package s2Member\s2Get * @since 3.5 * * @attaches-to ``add_shortcode("s2Get");`` * * @param array $attr An array of Attributes. * @param string $content Content inside the Shortcode. * @param string $shortcode The actual Shortcode name itself. * @return mixed Value of the requested data, or null on failure. * * @todo Prevent this routine from potentially returning objects/arrays? */ public static function sc_get_details($attr = FALSE, $content = FALSE, $shortcode = FALSE) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_sc_get_details", get_defined_vars()); unset($__refs, $__v); $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr); // Force array; trim quote entities. $attr = shortcode_atts(array("constant" => "", "user_field" => "", "user_option" => "", "user_id" => ""), $attr); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_sc_get_details_after_shortcode_atts", get_defined_vars()); unset($__refs, $__v); if ($attr["constant"] && defined($attr["constant"])) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || preg_match("/^S2MEMBER_/i", $attr["constant"])) { $get = constant($attr["constant"]); } } else { if ($attr["user_field"] && (is_user_logged_in() || $attr["user_id"])) { $get = c_ws_plugin__s2member_utils_users::get_user_field($attr["user_field"], (int) $attr["user_id"]); } else { if ($attr["user_option"] && (is_user_logged_in() || $attr["user_id"])) { $get = get_user_option($attr["user_option"], (int) $attr["user_id"]); } } } return apply_filters("ws_plugin__s2member_sc_get_details", isset($get) ? $get : null, get_defined_vars()); }
/** * Handles the Shortcode for: `[s2Get /]`. * * @package s2Member\s2Get * @since 3.5 * * @attaches-to ``add_shortcode('s2Get');`` * * @param array $attr An array of Attributes. * @param string $content Content inside the Shortcode. * @param string $shortcode The actual Shortcode name itself. * * @return mixed Value of the requested data, or null on failure. */ public static function sc_get_details($attr = array(), $content = '', $shortcode = '') { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_sc_get_details', get_defined_vars()); unset($__refs, $__v); // Allow variables to be modified by reference. $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr); // Force array; trim quote entities. $attr = shortcode_atts(array('constant' => '', 'user_field' => '', 'user_option' => '', 'user_id' => ''), $attr); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_sc_get_details_after_shortcode_atts', get_defined_vars()); unset($__refs, $__v); // Allow variables to be modified by reference. if ($attr['constant'] && defined($attr['constant'])) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || preg_match('/^S2MEMBER_/i', $attr['constant'])) { $get = constant($attr['constant']); } } else { if ($attr['user_field'] && (is_user_logged_in() || $attr['user_id'])) { $get = c_ws_plugin__s2member_utils_users::get_user_field($attr['user_field'], (int) $attr['user_id']); } else { if ($attr['user_option'] && (is_user_logged_in() || $attr['user_id'])) { $get = get_user_option($attr['user_option'], (int) $attr['user_id']); } } } if (isset($get) && (is_array($get) || is_object($get))) { $_get_array = $get; // Temporary variable. $get = array(); // New empty array. foreach ($_get_array as $_key_prop => $_value) { if (is_scalar($_value)) { // One dimension only. $get[$_key_prop] = (string) $_value; } } unset($_get_array, $_key_prop, $_value); // Housekeeping. $get = implode(', ', $get); // Convert to a string now. } if (isset($get) && !is_scalar($get)) { $get = ''; } else { if (isset($get)) { $get = (string) $get; } } // Convert to a string. return apply_filters('ws_plugin__s2member_sc_get_details', isset($get) ? $get : '', get_defined_vars()); }
/** * s2Member's PayPal® IPN handler ( inner processing routine ). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars); /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ /**/ if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` )."; /**/ $processing = $during = true; /* Yes, we ARE processing this. */ /**/ $paypal["s2member_log"][] = "This `txn_type` does not require any action on the part of s2Member."; $paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments."; $paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered."; /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` )."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", false, get_defined_vars()); } }
/** * s2Member's PayPal® IPN handler ( inner processing routine ). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars); /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ /**/ if (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_created\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` )."; /**/ $processing = $during = true; /* Yes, we ARE processing this. */ /**/ $paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member."; $paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy."; /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` )."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", false, get_defined_vars()); } }
function s2member_pro_clickbank_order($user_id = 0) { if (!$user_id) { $user_id = get_current_user_id(); } if (!$user_id) { return array(); } // Not possible. $subscr_id = get_user_option('s2member_subscr_id', $user_id); $subscr_gateway = get_user_option('s2member_subscr_gateway', $user_id); $ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars($user_id); if (!$subscr_id || $subscr_gateway !== 'clickbank') { return array(); } // Not applicable. if (!$ipn_signup_vars || empty($ipn_signup_vars['txn_id'])) { return array(); } // Not possible. return c_ws_plugin__s2member_pro_clickbank_utilities::clickbank_api_order($ipn_signup_vars['txn_id']); }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal["txn_type"]) && preg_match("/^web_accept\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && !empty($paypal["payer_email"]) && !empty($paypal["txn_id"])) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; list(, $paypal["sp_ids"], $paypal["hours"]) = preg_split("/\\:/", $paypal["item_number"], 3); $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : ""; $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"]; if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal["sp_ids"], $paypal["hours"])) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $processing = $during = true; // Yes, we ARE processing this. if (preg_match("/(referenc|associat)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) { // Associating this purchase with a Member? if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["option_selection1"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) { $sp_references = (array) get_user_option("s2member_sp_references", $user_id); $_sp_reference = array("time" => time(), "ids" => $paypal["sp_ids"], "hours" => $paypal["hours"], "url" => $sp_access_url); $sp_references = c_ws_plugin__s2member_utils_arrays::array_unique(array_merge($sp_references, $_sp_reference)); update_user_option($user_id, "s2member_sp_references", $sp_references); $paypal["s2member_log"][] = "Specific Post/Page ~ Sale associated with User ID: " . $user_id . "."; } } $sbj = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_subject"]); $sbj = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $sbj); $msg = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_message"]); $msg = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $msg); $rec = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_recipients"]); $rec = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $rec); if (($rec = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $rec))) { if ($rec = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $rec)) { // Full amount of the payment, before fee is subtracted. if (($rec = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $rec)) && ($rec = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $rec))) { if (($rec = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"])), $rec)) && ($rec = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"])), $rec))) { if ($rec = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $rec)) { // **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. "N\"ame" <email>). if ($rec = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $rec)) { if ($rec = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $rec)) { if (($rec = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $rec))) { if (($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $sbj))) { if ($sbj = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $sbj)) { // Full amount of the payment, before fee is subtracted. if (($sbj = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $sbj)) && ($sbj = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $sbj))) { if (($sbj = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $sbj)) && ($sbj = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $sbj))) { if ($sbj = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)) { if ($sbj = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $sbj)) { if (($sbj = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $sbj))) { if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if ($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) { // Full amount of the payment, before fee is subtracted. if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if (($rec = trim(preg_replace("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { $sbj = c_ws_plugin__s2member_utilities::evl($sbj, get_defined_vars()); $msg = c_ws_plugin__s2member_utilities::evl($msg, get_defined_vars()); } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { // Go through a possible list of recipients. c_ws_plugin__s2member_email_configs::email_config() . wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_email_msg", $msg, get_defined_vars()), "From: \"" . preg_replace('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=UTF-8") . c_ws_plugin__s2member_email_configs::email_config_release(); } $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . $rec . "."; } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours")))), $url)) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["ip"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Sale"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "sp_access_url: %%sp_access_url%%\n"; $msg .= "sp_access_exp: %%sp_access_exp%%\n"; $msg .= "amount: %%amount%%\n"; $msg .= "txn_id: %%txn_id%%\n"; $msg .= "item_number: %%item_number%%\n"; $msg .= "item_name: %%item_name%%\n"; $msg .= "first_name: %%first_name%%\n"; $msg .= "last_name: %%last_name%%\n"; $msg .= "full_name: %%full_name%%\n"; $msg .= "payer_email: %%payer_email%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "full_coupon_code: %%full_coupon_code%%\n"; $msg .= "coupon_code: %%coupon_code%%\n"; $msg .= "coupon_affiliate_id: %%coupon_affiliate_id%%\n"; $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $msg))) { if ($msg = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $msg)) { if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_sale_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_sale_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed."; } if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours")))), $url)) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["ip"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if ($url = trim($url)) { // Preserve Remaining replacements. // Because the parent routine may perform replacements too. $paypal["s2member_paypal_proxy_return_url"] = $url; } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready."; } if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $code)) && ($code = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $code))) { if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $code))) { if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $code))) { if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) { if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)) { if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $code)) { if (($code = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $code))) { if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) { $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site."; set_transient("s2m_" . md5("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200); } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars()); unset($__refs, $__v); } else { $paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?"; } } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars()); unset($__refs, $__v); return apply_filters("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", false, get_defined_vars()); } }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110815 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal["txn_type"]) && preg_match("/^web_accept\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $paypal["item_number"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && (!empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && !empty($paypal["payer_email"])) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_before_new_ccaps", get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level."; list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\\:/", $paypal["item_number"], 3); $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : ""; $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"]; if (preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) { if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["txn_id"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) { if (!$user->has_cap("administrator")) { $processing = $during = true; // Yes, we ARE processing this. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps", get_defined_vars()); unset($__refs, $__v); $fields = get_user_option("s2member_custom_fields", $user_id); // These will be needed in the routines below. $user_reg_ip = get_user_option("s2member_registration_ip", $user_id); // Original IP during Registration. $user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally. if (is_multisite() && !is_user_member_of_blog($user_id)) { add_existing_user_to_blog(array("user_id" => $user_id, "role" => get_option("default_role"))); $user = new WP_User($user_id); } if ($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"]))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } if ($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } if (!get_user_option("s2member_registration_ip", $user_id)) { update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]); } $paypal["s2member_log"][] = "s2Member Custom Capabilities updated w/ advanced update routines."; $sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_subject"]; // The same for standard and w/ Pro Forms. $msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_message"]; // The same for standard and w/ Pro Forms. $rec = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_email_recipients"]; // The same for standard and w/ Pro Forms. if (($rec = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $rec))) { if (($rec = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $rec)) && ($rec = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $rec))) { if (($rec = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $rec)) && ($rec = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $rec))) { if (($rec = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"])), $rec)) && ($rec = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"])), $rec))) { if ($rec = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $rec)) { // **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. "N\"ame" <email>). if ($rec = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $rec)) { if (($rec = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $rec))) { if (($rec = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $rec)) && ($rec = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->last_name), $rec))) { if ($rec = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $rec)) { if ($rec = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_email), $rec)) { if ($rec = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_login), $rec)) { if ($rec = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_reg_ip), $rec)) { if ($rec = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $rec)) { if (($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $sbj))) { if (($sbj = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $sbj)) && ($sbj = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $sbj))) { if (($sbj = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $sbj)) && ($sbj = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $sbj))) { if (($sbj = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $sbj)) && ($sbj = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $sbj))) { if ($sbj = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)) { if ($sbj = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $sbj)) { if (($sbj = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $sbj))) { if (($sbj = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $sbj)) && ($sbj = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->last_name), $sbj))) { if ($sbj = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $sbj)) { if ($sbj = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_email), $sbj)) { if ($sbj = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_login), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_reg_ip), $sbj)) { if ($sbj = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $sbj)) { if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $msg))) { if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if (($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $msg)) && ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->last_name), $msg))) { if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $msg)) { if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_email), $msg)) { if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_login), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_reg_ip), $msg)) { if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { $rec = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $rec); $sbj = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $sbj); $msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg); } } if (($rec = trim(preg_replace("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { $sbj = c_ws_plugin__s2member_utilities::evl($sbj, get_defined_vars()); $msg = c_ws_plugin__s2member_utilities::evl($msg, get_defined_vars()); } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { c_ws_plugin__s2member_email_configs::email_config() . wp_mail($recipient, apply_filters("ws_plugin__s2member_capabilities_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_capabilities_email_msg", $msg, get_defined_vars()), "From: \"" . preg_replace('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=UTF-8") . c_ws_plugin__s2member_email_configs::email_config_release(); } $paypal["s2member_log"][] = "Capability Confirmation Email sent to: " . $rec . "."; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["subscr_id"])), $url))) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->last_name)), $url))) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_login)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_reg_ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } if ($url = trim($url)) { // Preserve remaining replacements. // Because the parent routine may perform replacements too. $paypal["s2member_paypal_proxy_return_url"] = $url; } } } } } } } } } } } } } } $paypal["s2member_log"][] = "Capability Return, a Proxy Return URL is ready."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["subscr_id"])), $url))) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->last_name)), $url))) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_login)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_reg_ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } $paypal["s2member_log"][] = "Payment Notification URLs have been processed."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "(s2Member / API Notification Email) - Payment"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "subscr_id: %%subscr_id%%\n"; $msg .= "amount: %%amount%%\n"; $msg .= "txn_id: %%txn_id%%\n"; $msg .= "item_number: %%item_number%%\n"; $msg .= "item_name: %%item_name%%\n"; $msg .= "first_name: %%first_name%%\n"; $msg .= "last_name: %%last_name%%\n"; $msg .= "full_name: %%full_name%%\n"; $msg .= "payer_email: %%payer_email%%\n"; $msg .= "full_coupon_code: %%full_coupon_code%%\n"; $msg .= "coupon_code: %%coupon_code%%\n"; $msg .= "coupon_affiliate_id: %%coupon_affiliate_id%%\n"; $msg .= "user_first_name: %%user_first_name%%\n"; $msg .= "user_last_name: %%user_last_name%%\n"; $msg .= "user_full_name: %%user_full_name%%\n"; $msg .= "user_email: %%user_email%%\n"; $msg .= "user_login: %%user_login%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "user_id: %%user_id%%\n"; if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { $msg .= $var . ": %%" . $var . "%%\n"; } } $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $msg))) { if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if (($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $msg)) && ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->last_name), $msg))) { if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $msg)) { if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_email), $msg)) { if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_login), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_reg_ip), $msg)) { if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_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"]["payment_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } } } } } $paypal["s2member_log"][] = "Payment Notification Emails have been processed."; } if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ccap_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $code))) { if (($code = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $code)) && ($code = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $code))) { if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $code))) { if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $code))) { if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) { if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)) { if (($code = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $code))) { if (($code = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $code)) && ($code = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->last_name), $code))) { if ($code = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $code)) { if ($code = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_email), $code)) { if ($code = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->user_login), $code)) { if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_reg_ip), $code)) { if ($code = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $code)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($code = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $code))) { break; } } } if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) { $paypal["s2member_log"][] = "Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site."; set_transient("s2m_" . md5("s2member_transient_ccap_tracking_codes_" . $paypal["txn_id"]), $code, 43200); } } } } } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_during_new_ccaps", get_defined_vars()); unset($__refs, $__v); } else { $paypal["s2member_log"][] = "Unable to add new Capabilities. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access."; } } else { $paypal["s2member_log"][] = "Unable to add new Capabilities. Could not get the existing User ID from the DB. Please check the `on0` and `os0` variables in your Button Code."; } } else { $paypal["s2member_log"][] = "Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code."; } } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_after_new_ccaps", get_defined_vars()); unset($__refs, $__v); return apply_filters("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level", false, get_defined_vars()); } }
/** * 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 />— Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url))); if ($post_vars["attr"]["success"] && substr($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) { wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit; } } else { $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true); } } else { $global_response = array("response" => $paypal["__error"], "error" => true); } } } else { $global_response = $error; } } } }
/** * Handles processing of Pro-Form checkouts. * * @package s2Member\PayPal * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection. */ public static function paypal_checkout() { if (!empty($_POST["s2member_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) { $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array(); $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 />— 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 />— 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 />— 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 />— 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; } } } }
/** * Connect to and process ARB service information for Authorize.Net®. * * s2Member's Auto EOT System must be enabled for this to work properly. * * If you have a HUGE userbase, increase the max IPNs per process. * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network. * To increase, use: ``add_filter ("ws_plugin__s2member_pro_arb_service_ipns_per_process");``. * * @package s2Member\AuthNet * @since 1.5 * * @attaches-to ``add_action("ws_plugin__s2member_after_auto_eot_system");`` * * @param array $vars Expects an array of defined variables to be passed in by the Action Hook. * @return null */ public static function authnet_arb_service($vars = FALSE) { global $wpdb; /* Need global DB obj. */ global $current_site, $current_blog; /* For Multisite support. */ /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_authnet_api_login_id"]) { $scan_time = apply_filters("ws_plugin__s2member_pro_arb_service_status_scan_time", strtotime("-1 day"), get_defined_vars()); $per_process = apply_filters("ws_plugin__s2member_pro_arb_service_ipns_per_process", $vars["per_process"], get_defined_vars()); /**/ if (is_array($objs = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_gateway' AND `meta_value` = 'authnet' AND `user_id` NOT IN(SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_last_status_scan' AND `meta_value` > '" . esc_sql($scan_time) . "')"))) { foreach ($objs as $obj) { if (($user_id = $obj->ID) && ($counter = (int) $counter + 1)) { unset($authnet, $subscr_id, $ipn_sv, $processing, $processed, $ipn, $ipn_q, $log4, $_log4, $log2, $logs_dir); /* Unset these. */ /**/ if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $subscr_id = get_user_option("s2member_subscr_id", $user_id))) { if (!get_user_option("s2member_auto_eot_time", $user_id) && is_array($ipn_sv = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars(false, $subscr_id))) { if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"] && is_array($authnet["arb_ipn_signup_vars"] = $ipn_sv)) { if (preg_match("/^expired\$/i", $authnet["subscription_status"])) { $authnet["s2member_log"][] = "Authorize.Net® ARB/IPN processed on: " . date("D M j, Y g:i:s a T"); /**/ $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `SUBSCRIPTION EXPIRATION` )."; $authnet["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_eot` )."; $authnet["s2member_log"][] = "Please check PayPal® IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_eot"; $ipn["subscr_id"] = $authnet["arb_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $authnet["arb_ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $authnet["arb_ipn_signup_vars"]["period1"]; $ipn["period3"] = $authnet["arb_ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $authnet["arb_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $authnet["arb_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $authnet["arb_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $authnet["arb_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $authnet["arb_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $authnet["arb_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $authnet["arb_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $authnet["arb_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $authnet["arb_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails"; $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); /**/ c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)); } else { if (preg_match("/^(suspended|canceled|terminated)\$/i", $authnet["subscription_status"])) { $authnet["s2member_log"][] = "Authorize.Net® ARB/IPN processed on: " . date("D M j, Y g:i:s a T"); /**/ $authnet["s2member_log"][] = "Authorize.Net® transaction identified as ( `SUBSCRIPTION " . strtoupper($authnet["subscription_status"]) . "` )."; $authnet["s2member_log"][] = "IPN reformulated. Piping through s2Member's core/standard PayPal® processor as `txn_type` ( `subscr_cancel` )."; $authnet["s2member_log"][] = "Please check PayPal® IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_cancel"; $ipn["subscr_id"] = $authnet["arb_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $authnet["arb_ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $authnet["arb_ipn_signup_vars"]["period1"]; $ipn["period3"] = $authnet["arb_ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $authnet["arb_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $authnet["arb_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $authnet["arb_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $authnet["arb_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $authnet["arb_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $authnet["arb_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $authnet["arb_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $authnet["arb_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $authnet["arb_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails"; $ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); /**/ c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)); } else { if (!$processed) { /* If nothing was processed, here we add a message to the logs indicating the status; which is being ignored by s2Member. */ $authnet["s2member_log"][] = "Ignoring this ARB/Status ( `" . $authnet["subscription_status"] . "` ). It does NOT require any action on the part of s2Member."; } } } /**/ $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "authnet-arb-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "authnet-arb-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($authnet, true) . "\n\n", FILE_APPEND); } } } } } } /**/ update_user_option($user_id, "s2member_last_status_scan", time()); /**/ if ($counter >= $per_process) { /* Only this many. */ break; } /* Break the loop now. */ } } } } /**/ return; /* Return for uniformity. */ }
/** * Handles processing of Pro-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 />— 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 />— 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 />— 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 />— 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 the importation of Users/Members. * * @package s2Member\Imports * @since 110815 */ public static function import_users() { if (!empty($_POST['ws_plugin__s2member_pro_import_users']) && ($nonce = $_POST['ws_plugin__s2member_pro_import_users']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-pro-import-users') && current_user_can('create_users')) { global $wpdb; // Global database object reference. /** @var \wpdb $wpdb This line for IDEs that need a reference. */ global $current_site, $current_blog; // Multisite Networking. @set_time_limit(0); // Make time for processing large import files. @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); remove_all_actions('profile_update') . remove_all_actions('user_register'); remove_all_actions('added_existing_user') . remove_all_actions('add_user_to_blog'); if (!empty($_FILES['ws_plugin__s2member_pro_import_users_file']) && empty($_FILES['ws_plugin__s2member_pro_import_users_file']['error'])) { $file = fopen($_FILES['ws_plugin__s2member_pro_import_users_file']['tmp_name'], 'r'); } else { if (!empty($_POST['ws_plugin__s2member_pro_import_users_direct_input'])) { fwrite($file = tmpfile(), trim(stripslashes($_POST['ws_plugin__s2member_pro_import_users_direct_input']))) . fseek($file, 0); } } $imported = $line = $line_index = 0; // Initialize these counters. $headers = array(); // Initialize the array of CSV import file headers. $user_keys = array(); // Initialize array of user keys. if (is_object($_user_row = $wpdb->get_row("SELECT * FROM `" . $wpdb->users . "` LIMIT 1"))) { foreach (array_keys((array) $_user_row) as $_user_key) { $user_keys[] = $_user_key; } } unset($_user_row, $_user_key); // Housekeeping. $user_keys = array_unique($user_keys); // Only unique keys please. if (isset($file) && is_resource($file)) { while (($_csv_data = version_compare(PHP_VERSION, '5.3', '>=') ? fgetcsv($file, 0, ',', '"', '"') : fgetcsv($file, 0, ',', '"')) !== FALSE) { $line_index = (int) $line_index + 1; // CSV lines. $line = (int) $line + 1; // CSV lines. $_csv_data = c_ws_plugin__s2member_utils_strings::trim_deep($_csv_data); if ($line_index === 1 && isset($_csv_data[0])) { $line = $line - 1; foreach ($_csv_data as $_header) { $headers[] = $_header; } unset($_header); // Housekeeping. continue; // We've got the headers now; let's move to the next line. } if ($line_index >= 1 && (!$headers || !in_array('ID', $headers, TRUE) && !in_array('user_login', $headers, TRUE))) { $errors[] = 'Line #' . $line . '. Missing first-line CSV headers; please try again.' . ' Please note that your CSV headers MUST contain (at a minimum), one of: "ID", or "user_login"'; break; // Stop here; we have no headers in this importation. } $_user_ID_key = array_search('ID', $headers); $_user_id = $_user_ID_key !== FALSE && !empty($_csv_data[$_user_ID_key]) ? (int) $_csv_data[$_user_ID_key] : 0; unset($_user_ID_key); // Housekeeping. $_user_login_key = array_search('user_login', $headers); $_user_login = $_user_login_key !== FALSE && !empty($_csv_data[$_user_login_key]) ? $_csv_data[$_user_login_key] : ''; unset($_user_login_key); // Housekeeping. $_user_pass_key = array_search('user_pass', $headers); $_user_pass = $_user_pass_key !== FALSE && !empty($_csv_data[$_user_pass_key]) ? $_csv_data[$_user_pass_key] : ''; unset($_user_pass_key); // Housekeeping. $_user_email_key = array_search('user_email', $headers); $_user_email = $_user_email_key !== FALSE && !empty($_csv_data[$_user_email_key]) ? $_csv_data[$_user_email_key] : ''; unset($_user_email_key); // Housekeeping. $_user_role_key = array_search('role', $headers); $_user_role = $_user_role_key !== FALSE && !empty($_csv_data[$_user_role_key]) ? $_csv_data[$_user_role_key] : ''; $_user_role = is_numeric($_user_role) ? $_user_role == 0 ? 'subscriber' : 's2member_level' . $_user_role : $_user_role; unset($_user_role_key); // Housekeeping. $_user_ccaps_key = array_search('ccaps', $headers); $_user_ccaps = $_user_ccaps_key !== FALSE && !empty($_csv_data[$_user_ccaps_key]) ? $_csv_data[$_user_ccaps_key] : ''; unset($_user_ccaps_key); // Housekeeping. if ($_user_login) { if (is_multisite()) { $_user_login = strtolower($_user_login); } $_user_login = sanitize_user($_user_login, is_multisite()); } if ($_user_email) { $_user_email = sanitize_email($_user_email); } $_user_id_exists_but_not_on_blog = 0; // Initialize. if (!$_user_id && $_user_login && $_user_email && is_multisite()) { $_user_id = $_user_id_exists_but_not_on_blog = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($_user_login, $_user_email); } if (strcasecmp($_user_role, 'administrator') === 0) { $errors[] = 'Line #' . $line . '. Users cannot be updated to an Administrator. Bypassing this line for security.'; continue; // Skip this line. } if ($_user_email && !is_email($_user_email)) { $errors[] = 'Line #' . $line . '. Invalid email address (<code>' . esc_html($_user_email) . '</code>); please try again.'; continue; // Skip this line. } if ($_user_login && !validate_username($_user_login)) { $errors[] = 'Line #' . $line . '. Invalid username (<code>' . esc_html($_user_login) . '</code>).'; continue; // Skip this line. } if ($_user_id) { if (!is_object($_user = new WP_User($_user_id)) || !$_user->ID) { $errors[] = 'Line #' . $line . '. User ID# <code>' . esc_html($_user_id) . '</code> does NOT belong to an existing User.'; continue; // Skip this line. } if (is_super_admin($_user_id) || $_user->has_cap('administrator')) { $errors[] = 'Line #' . $line . '. User ID# <code>' . esc_html($_user_id) . '</code> belongs to an Administrator. Bypassing this line for security.'; continue; // Skip this line. } if (is_multisite() && $_user_id_exists_but_not_on_blog && add_existing_user_to_blog(array('user_id' => $_user_id, 'role' => 'subscriber')) !== TRUE) { $errors[] = 'Line #' . $line . '. Unknown user/site addition error, please try again.'; continue; // Skip this line. } if (is_multisite() && !is_user_member_of_blog($_user_id)) { $errors[] = 'Line #' . $line . '. User ID# <code>' . esc_html($_user_id) . '</code> does NOT belong to an existing User on this site.'; continue; // Skip this line. } if ($_user_email && strcasecmp($_user_email, $_user->user_email) !== 0 && email_exists($_user_email)) { $errors[] = 'Line #' . $line . '. Conflicting; the email address (<code>' . esc_html($_user_email) . '</code>), already exists.'; continue; // Skip this line. } if ($_user_login && strcasecmp($_user_login, $_user->user_login) !== 0 && username_exists($_user_login)) { $errors[] = 'Line #' . $line . '. Conflicting; the username (<code>' . esc_html($_user_login) . '</code>), already exists.'; continue; // Skip this line. } /** @var WP_Error $_email_login_validation */ if (is_multisite() && strcasecmp($_user_email, $_user->user_email) !== 0 && strcasecmp($_user_login, $_user->user_login) !== 0) { if (is_wp_error($_email_login_validation = wpmu_validate_user_signup($_user_login, $_user_email))) { if ($_email_login_validation->get_error_code()) { $errors[] = 'Line #' . $line . '. Network. The email and/or username (<code>' . esc_html($_user_email) . '</code> / <code>' . esc_html($_user_login) . '</code>) are in conflict w/ network rules.'; continue; // Skip this line. } } } unset($_email_login_validation); // Housekeeping. $_wp_update_user = array(); foreach ($user_keys as $_user_key) { if (($_user_data_key = array_search($_user_key, $headers)) !== FALSE && isset($_csv_data[$_user_data_key])) { $_wp_update_user[$_user_key] = $_csv_data[$_user_data_key]; } } unset($_user_key, $_user_data_key); // Housekeeping. if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { unset($_wp_update_user['user_login'], $_wp_update_user['user_pass']); } if (!wp_update_user(wp_slash($_wp_update_user))) { $errors[] = 'Line #' . $line . '. User ID# <code>' . esc_html($_user_id) . '</code> could NOT be updated. Unknown error, please try again.'; continue; // Skip this line. } unset($_wp_update_user); // Housekeeping. clean_user_cache($_user_id); wp_cache_delete($_user_id, 'user_meta'); $_user = new WP_User($_user_id); $imported = $imported + 1; } else { if (!$_user_email) { $errors[] = 'Line #' . $line . '. Missing email address.'; continue; // Skip this line. } if (email_exists($_user_email)) { $errors[] = 'Line #' . $line . '. Conflicting; the email address (<code>' . esc_html($_user_email) . '</code>), already exists.'; continue; // Skip this line. } if (!$_user_login) { $errors[] = 'Line #' . $line . '. Missing user login (i.e., username).'; continue; // Skip this line. } if (username_exists($_user_login)) { $errors[] = 'Line #' . $line . '. Conflicting; the username (<code>' . esc_html($_user_login) . '</code>), already exists.'; continue; // Skip this line. } /** @var WP_Error $_email_login_validation */ if (is_multisite() && is_wp_error($_email_login_validation = wpmu_validate_user_signup($_user_login, $_user_email))) { if ($_email_login_validation->get_error_code()) { $errors[] = 'Line #' . $line . '. Network. The email and/or username (<code>' . esc_html($_user_email) . '</code> / <code>' . esc_html($_user_login) . '</code>) are in conflict w/ network rules.'; continue; // Skip this line. } } unset($_email_login_validation); // Housekeeping. if (!($_user_id = wp_insert_user(wp_slash(array('user_login' => $_user_login, 'user_pass' => $_user_pass ? $_user_pass : wp_generate_password(12, FALSE), 'user_email' => $_user_email)))) || is_wp_error($_user_id)) { $errors[] = 'Line #' . $line . '. Unknown insertion error, please try again.'; continue; // Skip this line. } $_wp_update_user = array('ID' => $_user_id); foreach ($user_keys as $_user_key) { if (($_user_data_key = array_search($_user_key, $headers)) !== FALSE && isset($_csv_data[$_user_data_key])) { $_wp_update_user[$_user_key] = $_csv_data[$_user_data_key]; } } unset($_user_key, $_user_data_key); // Housekeeping. if (!wp_update_user(wp_slash($_wp_update_user))) { $errors[] = 'Line #' . $line . '. Post insertion update failed on User ID# <code>' . esc_html($_user_id) . '</code>. Unknown error, please try again.'; continue; // Skip this line. } unset($_wp_update_user); // Housekeeping. if (is_multisite()) { // New Users on a Multisite Network need this too. update_user_meta($_user_id, 's2member_originating_blog', $current_blog->blog_id); } clean_user_cache($_user_id); wp_cache_delete($_user_id, 'user_meta'); $_user = new WP_User($_user_id); $imported = $imported + 1; } if ($_user_role) { $_user->set_role($_user_role); } if ($_user_ccaps) { foreach ($_user->allcaps as $_cap => $_cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $_cap)) { $_user->remove_cap($_cap); } } unset($_cap, $_cap_enabled); // Housekeeping. if (preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $_user_ccaps))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $_user_ccaps))) as $_ccap) { if (strlen($_ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $_ccap))))) { $_user->add_cap('access_s2member_ccap_' . $_ccap); } } } } $_user_custom_fields = get_user_option('s2member_custom_fields', $_user_id); $_user_custom_fields = is_array($_user_custom_fields) ? $_user_custom_fields : array(); foreach ($headers as $_index => $_header) { if (strpos($_header, 'meta_key__') === 0) { if (isset($_csv_data[$_index])) { $_new_meta_value = $_csv_data[$_index]; $_user_meta_key = substr($_header, strlen('meta_key__')); if ($_user_meta_key === $wpdb->prefix . 'capabilities' && ($_user_role || $_user_ccaps)) { continue; } // Already handled via `role` and `ccaps`. if ($_user_meta_key === $wpdb->prefix . 'capabilities' && stripos($_new_meta_value, 'administrator') !== FALSE) { continue; } // Do not allow this for security purposes. if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { if (strpos($_user_meta_key, $wpdb->prefix) !== 0 && !in_array($_user_meta_key, array('first_name', 'last_name', 'nickname', 'description'), TRUE)) { continue; } } // Child sites may NOT update meta data for other child blogs. switch ($_user_meta_key) { case $wpdb->prefix . 'capabilities': case $wpdb->prefix . 's2member_sp_references': case $wpdb->prefix . 's2member_ipn_signup_vars': case $wpdb->prefix . 's2member_access_cap_times': case $wpdb->prefix . 's2member_paid_registration_times': case $wpdb->prefix . 's2member_file_download_access_arc': case $wpdb->prefix . 's2member_file_download_access_log': if (isset($_new_meta_value[0])) { // This handles JSON-decoding for known array values. if (!is_null($_new_meta_value_decoded = json_decode($_new_meta_value, TRUE))) { $_new_meta_value = maybe_serialize($_new_meta_value_decoded); } } break; } $_existing_meta_row = $wpdb->get_row("SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . esc_sql($_user_id) . "' AND `meta_key` = '" . esc_sql($_user_meta_key) . "' AND `meta_value` = '" . esc_sql($_new_meta_value) . "' LIMIT 1"); if (is_object($_existing_meta_row)) { continue; } // No need to update this; it is still the same value. $_existing_meta_rows = $wpdb->get_results("SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . esc_sql($_user_id) . "' AND `meta_key` = '" . esc_sql($_user_meta_key) . "' LIMIT 2"); if ($_existing_meta_rows && count($_existing_meta_rows) > 1) { continue; } // We don't update multivalue keys. This can cause database corruption via CSV import files. $_existing_meta_row = $_existing_meta_rows ? $_existing_meta_rows[0] : NULL; /** @var object $_existing_meta_row This line is for IDEs; so they don't choke. */ if (is_object($_existing_meta_row) && $_new_meta_value !== $_existing_meta_row->meta_value) { $wpdb->update($wpdb->usermeta, array('meta_value' => $_new_meta_value), array('umeta_id' => $_existing_meta_row->umeta_id)); } else { if (!is_object($_existing_meta_row)) { $wpdb->insert($wpdb->usermeta, array('user_id' => $_user_id, 'meta_key' => $_user_meta_key, 'meta_value' => $_new_meta_value)); } } } } else { if (strpos($_header, 'custom_field_key__') === 0) { if (isset($_csv_data[$_index])) { $_new_custom_field_value = $_csv_data[$_index]; if (!is_null($_new_custom_field_value_decoded = json_decode($_new_custom_field_value, TRUE))) { $_new_custom_field_value = $_new_custom_field_value_decoded; } $_user_custom_field_key = substr($_header, strlen('custom_field_key__')); $_user_custom_fields[$_user_custom_field_key] = $_new_custom_field_value; } } } } update_user_option($_user_id, 's2member_custom_fields', $_user_custom_fields); unset($_user_custom_fields, $_index, $_header); // Housekeeping. unset($_new_meta_value, $_new_meta_value_decoded, $_user_meta_key, $_existing_meta_rows, $_existing_meta_row); unset($_new_custom_field_value, $_new_custom_field_value_decoded, $_user_custom_field_key); } fclose($file); // Close the file resource handle now. unset($_csv_data, $_user, $_user_id, $_user_login, $_user_email); unset($_user_id_exists_but_not_on_blog, $_user_role, $_user_ccaps); } else { $errors[] = 'No data was received. Please try again.'; } // The upload failed, or it was empty. c_ws_plugin__s2member_admin_notices::display_admin_notice('Operation complete. Users/Members imported: <code>' . (int) $imported . '</code>.'); if (!empty($errors)) { // Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation. c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode('</li><li>', $errors) . '</li></ul>', TRUE); } } }
/** * 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 />— Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url))); if ($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) { wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit; } } else { $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true); } } else { $global_response = array("response" => $authnet["__error"], "error" => true); } } else { $global_response = $error; } } } }
/** * s2Member's PayPal Auto-Return/PDT handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}. * * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal['txn_type']) && preg_match('/^(web_accept|subscr_signup|subscr_payment)$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['subscr_id']) || !empty($paypal['txn_id']) && ($paypal['subscr_id'] = $paypal['txn_id'])) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status']))) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) { $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).'; @(list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3)); $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : ''; $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip']; $paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip']; if (preg_match('/^subscr_payment$/i', $paypal['txn_type']) && !empty($_GET['s2member_paypal_return_tra']) && (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET['s2member_paypal_return_tra'])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra['ta'], $tra['tp'], $tra['tt'], $tra['ra'], $tra['rp'], $tra['rt'], $tra['rr'], $tra['rrt'], $tra['rra'], $tra['invoice'], $tra['checksum'])) && $tra['invoice'] === $paypal['invoice'] && $tra['checksum'] === md5($paypal['invoice'] . $paypal['ip'] . $paypal['item_number'])) { $tracking_properties = TRUE; // Yes, these tracking properties ARE being set here. $paypal['period1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? $tra['tp'] . ' ' . $tra['tt'] : '0 D'; $paypal['mc_amount1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? number_format($tra['ta'], 2, '.', '') : '0.00'; $paypal['period3'] = $tra['rp'] . ' ' . $tra['rt']; $paypal['mc_amount3'] = $tra['ra']; $paypal['recurring'] = $tra['rr'] === '1' ? '1' : '0'; $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; // Defaults to '0 D' (zero days). $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3']; $paypal['regular'] = $paypal['mc_amount3']; // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal. $paypal['regular_term'] = $paypal['period3']; // This is just set to keep a standard; this way both initial_term & regular_term are available. $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0'; // If non-recurring, this should be zero, otherwise Regular. $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); $ipn_signup_vars = $paypal; // Copy of PayPal vars; used as IPN signup vars. unset($ipn_signup_vars['s2member_log']); // Create array of wouldbe IPN signup vars w/o s2member_log. } else { if (preg_match('/^(web_accept|subscr_signup)$/i', $paypal['txn_type'])) { $tracking_properties = TRUE; // Yes, these tracking properties ARE being set here. $paypal['period1'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; // Defaults to '0 D' (zero days). $paypal['mc_amount1'] = strlen($paypal['mc_amount1']) && $paypal['mc_amount1'] > 0 ? $paypal['mc_amount1'] : '0.00'; if (preg_match('/^web_accept$/i', $paypal['txn_type'])) { $paypal['period3'] = $paypal['eotper'] ? $paypal['eotper'] : '1 L'; // 1 Lifetime. $paypal['mc_amount3'] = $paypal['mc_gross']; // The 'Buy Now' amount is the full gross. } $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; // Defaults to '0 D' (zero days). $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3']; $paypal['regular'] = $paypal['mc_amount3']; // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal. $paypal['regular_term'] = $paypal['period3']; // This is just set to keep a standard; this way both initial_term & regular_term are available. $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0'; // If non-recurring, this should be zero, otherwise Regular. $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); $ipn_signup_vars = $paypal; // Copy of PayPal vars; used as IPN signup vars. unset($ipn_signup_vars['s2member_log']); // Create array of wouldbe IPN signup vars w/o s2member_log. } else { $tracking_properties = FALSE; } } // Not possible. /* New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications. */ if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars', get_defined_vars()); unset($__refs, $__v); // Housekeeping. $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.'; if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) { if (!$user->has_cap('administrator')) { $processing = $modifying = $during = TRUE; // Yes, we ARE processing this. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_during_before_subscr_signup_w_update_vars', get_defined_vars()); do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), 'rtn-upgrade-downgrade', 'modification', 's2member_level' . $paypal['level']); unset($__refs, $__v); // Housekeeping. $fields = get_user_option('s2member_custom_fields', $user_id); // These will be needed in the routines below. $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); // Original IP during Registration. $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip']; // Now merge conditionally. if (is_multisite() && !is_user_member_of_blog($user_id)) { add_existing_user_to_blog(array('user_id' => $user_id, 'role' => 's2member_level' . $paypal['level'])); $user = new WP_User($user_id); } $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); if ($current_role !== 's2member_level' . $paypal['level']) { // Only if we need to. $user->set_role('s2member_level' . $paypal['level']); } if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } update_user_option($user_id, 's2member_subscr_gateway', $paypal['subscr_gateway']); update_user_option($user_id, 's2member_subscr_id', $paypal['subscr_id']); update_user_option($user_id, 's2member_subscr_baid', $paypal['subscr_baid']); update_user_option($user_id, 's2member_subscr_cid', $paypal['subscr_cid']); update_user_option($user_id, 's2member_custom', $paypal['custom']); if (!get_user_option('s2member_registration_ip', $user_id)) { update_user_option($user_id, 's2member_registration_ip', $paypal['ip']); } if (!empty($ipn_signup_vars)) { // We should have these from the routines above. update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars); } delete_user_option($user_id, 's2member_file_download_access_log'); if ((preg_match('/^web_accept$/i', $paypal['txn_type']) || $paypal['initial'] <= 0 && $paypal['regular'] <= 0) && $paypal['eotper']) { // Don't update this in the return routine. Leave this for the IPN routine. // EOT Times might be extended, and we don't want the IPN routine to extend an already-extended EOT Time. $eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $paypal['eotper'], '', get_user_option('s2member_auto_eot_time', $user_id)); $paypal['s2member_log'][] = 'Automatic EOT (End Of Term) Time will be set to: ' . date('D M j, Y g:i:s a T', $eot_time) . '.'; } else { // Otherwise, we need to clear the Auto-EOT Time. delete_user_option($user_id, 's2member_auto_eot_time'); } $pr_times = get_user_option('s2member_paid_registration_times', $user_id); $pr_times['level'] = !$pr_times['level'] ? time() : $pr_times['level']; // Preserve existing. $pr_times['level' . $paypal['level']] = !$pr_times['level' . $paypal['level']] ? time() : $pr_times['level' . $paypal['level']]; update_user_option($user_id, 's2member_paid_registration_times', $pr_times); c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, '/^Demoted by s2Member\\:/'); c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, '/^Paid Subscr\\. ID @ time of demotion\\:/'); $paypal['s2member_log'][] = 's2Member Level/Capabilities updated w/ advanced update routines.'; setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['subscr_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking); $paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.'; if ($processing && $tracking_properties && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($code = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $code))) { if (($code = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $code)) && ($code = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $code)) && ($code = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $code)) && ($code = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $code))) { if (($code = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $code)) && ($code = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if (($code = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $code)) && ($code = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $code))) { if ($code = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $code)) { if ($code = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $code)) { if ($code = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $code)) { if ($code = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $code)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { // Custom Registration/Profile Fields. if (!($code = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $code))) { break; } } } if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_modification_tracking_codes_' . $paypal['subscr_id']), $code, 43200); } } } } } } } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if ($redirection_url_after_modification = apply_filters('ws_plugin__s2member_redirection_url_after_modification', FALSE, get_defined_vars())) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL after modification: ' . $redirection_url_after_modification; wp_redirect($redirection_url_after_modification); } else { $paypal['s2member_log'][] = 'Redirecting Customer to the Login Page (after displaying a quick thank-you message). They need to log back in.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], '<strong>' . _x('Thank you! You\'ve been updated to:', 's2member-front', 's2member') . '<br /><em>' . esc_html($paypal['item_name']) . '</em></strong>', _x('Please Log Back In (Click Here)', 's2member-front', 's2member'), wp_login_url()); } } else { $paypal['s2member_log'][] = 'Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } } else { $paypal['s2member_log'][] = 'Unable to modify Subscription. Could not get the existing User ID from the DB.'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars', get_defined_vars()); unset($__refs, $__v); // Housekeeping. } else { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); $processing = $during = TRUE; // Yes, we ARE processing this new Subscription request. $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.'; setcookie('s2member_subscr_gateway', $s2member_subscr_gateway = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['subscr_gateway']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_subscr_gateway', $s2member_subscr_gateway, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_subscr_gateway'] = $s2member_subscr_gateway); setcookie('s2member_subscr_id', $s2member_subscr_id = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['subscr_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_subscr_id', $s2member_subscr_id, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_subscr_id'] = $s2member_subscr_id); setcookie('s2member_custom', $s2member_custom = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['custom']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_custom', $s2member_custom, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_custom'] = $s2member_custom); setcookie('s2member_item_number', $s2member_item_number = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['item_number']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_item_number', $s2member_item_number, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_item_number'] = $s2member_item_number); $paypal['s2member_log'][] = 'Registration Cookies set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.'; setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['subscr_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking); $paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.'; if ($processing && $tracking_properties && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['signup_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($code = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $code))) { if (($code = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $code)) && ($code = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $code)) && ($code = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $code)) && ($code = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $code))) { if (($code = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $code)) && ($code = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $code)) { if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_signup_tracking_codes_' . $paypal['subscr_id']), $code, 43200); } } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site()) { if ($redirection_url_after_mms_farm_signup = apply_filters('ws_plugin__s2member_redirection_url_after_mms_farm_signup', FALSE, get_defined_vars())) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL after signup: ' . $redirection_url_after_mms_farm_signup; wp_redirect($redirection_url_after_mms_farm_signup); } else { if (!empty($custom_success_redirection)) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL on success: ' . $custom_success_redirection; wp_redirect($custom_success_redirection); } else { $paypal['s2member_log'][] = 'Redirecting Customer to Signup Page (after displaying a quick thank-you message). They need to Signup/Register now.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', 's2member-front', 's2member'), _x('Please Register Now (Click Here)', 's2member-front', 's2member'), c_ws_plugin__s2member_utils_urls::wp_signup_url()); } } } else { if ($redirection_url_after_signup = apply_filters('ws_plugin__s2member_redirection_url_after_signup', FALSE, get_defined_vars())) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL after signup: ' . $redirection_url_after_signup; wp_redirect($redirection_url_after_signup); } else { if (!empty($custom_success_redirection)) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL on success: ' . $custom_success_redirection; wp_redirect($custom_success_redirection); } else { $paypal['s2member_log'][] = 'Redirecting Customer to Registration Page (after displaying a quick thank-you message). They need to Register now.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', 's2member-front', 's2member'), _x('Please Register Now (Click Here)', 's2member-front', 's2member'), c_ws_plugin__s2member_utils_urls::wp_register_url()); } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); // Housekeeping. } } else { $paypal['s2member_log'][] = 'Page Expired. Duplicate Return-Data.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).'; $paypal['s2member_log'][] = 'Page Expired. Instructing customer to check their email for further details about how to obtain access to what they purchased.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], '<strong>' . _x('Thank you! Please check your email for further details regarding your purchase.', 's2member-front', 's2member') . '</strong>', _x('Return to Home Page', 's2member-front', 's2member'), home_url("/")); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_after_subscr_signup', get_defined_vars()); unset($__refs, $__v); // Housekeeping. return apply_filters('c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level', $paypal, get_defined_vars()); } else { return apply_filters('c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level', FALSE, get_defined_vars()); } }
/** * For Multisite Networks, this function is used to add a User to an existing Blog; and to simulate ``wp_create_user()`` behavior. * * The ``$user_id`` value will be returned by this function, just like ``wp_create_user()`` does. * This function will fire the Hook `user_register`. * * @package s2Member\Registrations * @since 3.5 * * @param string $user_login Expects the User's Username. * @param string $user_email Expects the User's Email Address. * @param string $user_pass Expects the User's plain text Password. * @param int|string $user_id Optional. A numeric WordPress User ID. * If unspecified, a lookup is performed with ``$user_login`` and ``$user_email``. * * @return int|false Returns numeric ``$user_id`` on success, else false on failure. */ public static function ms_create_existing_user($user_login = '', $user_email = '', $user_pass = '', $user_id = '') { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_ms_create_existing_user', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if (is_multisite()) { if (($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email))) && $user_pass) { $role = get_option('default_role'); // Use default Role. add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $role)); // Add User. wp_update_user(wp_slash(array('ID' => $user_id, 'user_pass' => $user_pass))); // Update to ``$user_pass``. do_action('ws_plugin__s2member_during_ms_create_existing_user', get_defined_vars()); do_action('user_register', $user_id); // So s2Member knows a User is registering. return apply_filters('ws_plugin__s2member_ms_create_existing_user', $user_id, get_defined_vars()); } } return apply_filters('ws_plugin__s2member_ms_create_existing_user', FALSE, get_defined_vars()); }
/** * Shortcode `[s2Member-Pro-ccBill-Button /]`. * * @package s2Member\ccBill * @since 1.5 * * @attaches-to ``add_shortcode("s2Member-Pro-ccBill-Button");`` * * @param array $attr An array of Attributes. * @param string $content Content inside the Shortcode. * @param string $shortcode The actual Shortcode name itself. * @return string The resulting ccBill Button Code, HTML markup. */ public static function sc_ccbill_button($attr = FALSE, $content = FALSE, $shortcode = FALSE) { c_ws_plugin__s2member_no_cache::no_cache_constants(true); $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr); $attr = shortcode_atts(array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "2.95", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "sub_account" => "", "form" => "", "output" => "anchor"), $attr); $attr["tt"] = strtoupper($attr["tt"]); $attr["rt"] = strtoupper($attr["rt"]); $attr["ccaps"] = strtolower($attr["ccaps"]); $attr["ccaps"] = str_replace(" ", "", $attr["ccaps"]); $attr["rr"] = $attr["rt"] === "L" ? "0" : $attr["rr"]; $attr["rr"] = $attr["level"] === "*" ? "0" : $attr["rr"]; if ($attr["rr"] && ($attr["ta"] <= 0 || $attr["tp"] <= 0 || !$attr["tt"])) { eval('$attr["ta"] = $attr["ra"]; $attr["tp"] = $attr["rp"]; $attr["tt"] = $attr["rt"];'); } if ($attr["modify"] || $attr["cancel"]) { $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/ccbill-edit-button.png"; $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/ccbill-cancellation-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? $code : $code; if ($attr["output"] === "url" && preg_match('/ href\\="(.*?)"/', $code, $m) && ($href = $m[1])) { $code = $url = c_ws_plugin__s2member_utils_urls::n_amps($href); } unset($href, $url, $m); } else { if ($attr["sp"]) { $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/ccbill-button.png"; $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"]; $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/ccbill-sp-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code); $vars = array("clientAccnum" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $attr["sub_account"] ? $attr["sub_account"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"], "formName" => $attr["form"] ? $attr["form"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_form_name"], "formPrice" => $attr["ra"], "formPeriod" => round($attr["exp"] / 24), "currencyCode" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_numr($attr["cc"]), "s2_desc" => $attr["desc"], "s2_invoice" => $attr["sp_ids_exp"], "s2_custom" => $attr["custom"], "s2_customer_ip" => $_SERVER["REMOTE_ADDR"]); if ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) { $vars["s2_referencing"] = $referencing; } $code = preg_replace("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($url = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_link_gen($vars))), $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? $code : $code; $code = $attr["output"] === "url" ? $url : $code; unset($href, $url, $m); } else { if ($attr["level"] === "*") { $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/ccbill-button.png"; $attr["level_ccaps_eotper"] = !$attr["rr"] && $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/ccbill-ccaps-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code); $vars = array("clientAccnum" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $attr["sub_account"] ? $attr["sub_account"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"], "formName" => $attr["form"] ? $attr["form"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_form_name"], "formPrice" => $attr["ra"], "formPeriod" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_per_term_2_days($attr["rp"], $attr["rt"]), "currencyCode" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_numr($attr["cc"]), "s2_desc" => $attr["desc"], "s2_invoice" => $attr["level_ccaps_eotper"], "s2_custom" => $attr["custom"], "s2_customer_ip" => $_SERVER["REMOTE_ADDR"]); if ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) { $vars["s2_referencing"] = $referencing; } $code = preg_replace("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($url = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_link_gen($vars))), $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? $code : $code; $code = $attr["output"] === "url" ? $url : $code; unset($href, $url, $m); } else { $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/ccbill-button.png"; $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; $attr["level_ccaps_eotper"] = !$attr["rr"] && $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/buttons/ccbill-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr(home_url())), $code); if (!$attr["rr"]) { $vars = array("clientAccnum" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $attr["sub_account"] ? $attr["sub_account"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"], "formName" => $attr["form"] ? $attr["form"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_form_name"], "formPrice" => $attr["ra"], "formPeriod" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_per_term_2_days($attr["rp"], $attr["rt"]), "currencyCode" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_numr($attr["cc"]), "s2_p1" => "0 D", "s2_p3" => $attr["rp"] . " " . $attr["rt"], "s2_desc" => $attr["desc"], "s2_invoice" => $attr["level_ccaps_eotper"], "s2_custom" => $attr["custom"], "s2_customer_ip" => $_SERVER["REMOTE_ADDR"]); } else { // Otherwise, we need to include both an Initial and Regular/Recurring period. This will ALWAYS recur. $vars = array("clientAccnum" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $attr["sub_account"] ? $attr["sub_account"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"], "formName" => $attr["form"] ? $attr["form"] : $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_form_name"], "formPrice" => $attr["ta"], "formPeriod" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_per_term_2_days($attr["tp"], $attr["tt"]), "formRecurringPrice" => $attr["ra"], "formRecurringPeriod" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_per_term_2_days($attr["rp"], $attr["rt"]), "formRebills" => "99", "currencyCode" => c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_currency_numr($attr["cc"]), "s2_p1" => $attr["tp"] . " " . $attr["tt"], "s2_p3" => $attr["rp"] . " " . $attr["rt"], "s2_desc" => $attr["desc"], "s2_invoice" => $attr["level_ccaps_eotper"], "s2_custom" => $attr["custom"], "s2_customer_ip" => $_SERVER["REMOTE_ADDR"]); } if ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) { $vars["s2_referencing"] = $referencing; } $code = preg_replace("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($url = c_ws_plugin__s2member_pro_ccbill_utilities::ccbill_link_gen($vars))), $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_refs(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? $code : $code; $code = $attr["output"] === "url" ? $url : $code; unset($href, $url, $m); } } } return $code; }
function get_user_field($field_id = FALSE, $user_id = FALSE) { return c_ws_plugin__s2member_utils_users::get_user_field($field_id, $user_id); }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal['txn_type']) && preg_match('/^subscr_modify$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && !empty($paypal['subscr_id']) && !empty($paypal['payer_email']) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id']))) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_modify', get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `subscr_modify` ).'; list($paypal['level'], $paypal['ccaps']) = preg_split('/\\:/', $paypal['item_number'], 2); $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : ''; $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip']; $paypal['period1'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; // Defaults to '0 D' (zero days). $paypal['mc_amount1'] = strlen($paypal['mc_amount1']) && $paypal['mc_amount1'] > 0 ? $paypal['mc_amount1'] : '0.00'; // '0.00'. $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; // Defaults to '0 D' (zero days). $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3']; $paypal['regular'] = $paypal['mc_amount3']; // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal. $paypal['regular_term'] = $paypal['period3']; // This is just set to keep a standard; this way both initial_term & regular_term are available. $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0'; // If non-recurring, this should be zero, otherwise Regular. $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); $ipn_signup_vars = $paypal; unset($ipn_signup_vars['s2member_log']); // Create array of IPN signup vars w/o s2member_log. if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && $user->ID) { if (!$user->has_cap('administrator')) { $processing = $modifying = $during = TRUE; // Yes, we ARE processing this. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify', get_defined_vars()); do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), 'ipn-upgrade-downgrade', 'modification', 's2member_level' . $paypal['level']); unset($__refs, $__v); $fields = get_user_option('s2member_custom_fields', $user_id); // These will be needed in the routines below. $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); // Original IP during Registration. $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip']; // Now merge conditionally. if (is_multisite() && !is_user_member_of_blog($user_id)) { add_existing_user_to_blog(array('user_id' => $user_id, 'role' => 's2member_level' . $paypal['level'])); $user = new WP_User($user_id); } $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); if ($current_role !== 's2member_level' . $paypal['level']) { // Only if we need to. $user->set_role('s2member_level' . $paypal['level']); } // (upgrade/downgrade) if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } update_user_option($user_id, 's2member_subscr_gateway', $paypal['subscr_gateway']); update_user_option($user_id, 's2member_subscr_id', $paypal['subscr_id']); update_user_option($user_id, 's2member_subscr_baid', $paypal['subscr_baid']); update_user_option($user_id, 's2member_subscr_cid', $paypal['subscr_cid']); update_user_option($user_id, 's2member_custom', $paypal['custom']); if (!get_user_option('s2member_registration_ip', $user_id)) { update_user_option($user_id, 's2member_registration_ip', $paypal['ip']); } update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars); delete_user_option($user_id, 's2member_file_download_access_log'); delete_user_option($user_id, 's2member_auto_eot_time'); $pr_times = get_user_option('s2member_paid_registration_times', $user_id); $pr_times['level'] = !$pr_times['level'] ? time() : $pr_times['level']; // Preserves existing. $pr_times['level' . $paypal['level']] = !$pr_times['level' . $paypal['level']] ? time() : $pr_times['level' . $paypal['level']]; update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now. c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, '/^Demoted by s2Member\\:/'); c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, '/^Paid Subscr\\. ID @ time of demotion\\:/'); $paypal['s2member_log'][] = 's2Member Level/Capabilities updated on Subscription modification.'; $sbj = $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_email_subject']; // The same for standard and w/ Pro-Forms. $msg = $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_email_message']; // The same for standard and w/ Pro-Forms. $rec = $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_email_recipients']; // The same for standard and w/ Pro-Forms. if (($rec = c_ws_plugin__s2member_utils_strings::fill_cvs($rec, $paypal['custom'])) && ($rec = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $rec))) { if (($rec = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $rec)) && ($rec = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $rec))) { if (($rec = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $rec)) && ($rec = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $rec))) { if (($rec = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $rec)) && ($rec = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $rec))) { if (($rec = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $rec)) && ($rec = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $rec))) { if (($rec = preg_replace('/%%initial_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['initial_term'])), $rec)) && ($rec = preg_replace('/%%regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], $paypal['recurring'])), $rec))) { if (($rec = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $rec)) && ($rec = preg_replace('/%%recurring\\/regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring'] ? $paypal['recurring'] . ' / ' . c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], TRUE) : '0 / non-recurring'), $rec))) { if (($rec = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $rec)) && ($rec = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $rec))) { if (($rec = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name'])), $rec)) && ($rec = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name'])), $rec))) { if ($rec = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $rec)) { // **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. 'N\'ame' <email>). if ($rec = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $rec)) { if (($rec = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $rec)) && ($rec = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $rec))) { if ($rec = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $rec)) { if ($rec = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $rec)) { if ($rec = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $rec)) { if ($rec = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $rec)) { if ($rec = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $rec)) { if (($sbj = c_ws_plugin__s2member_utils_strings::fill_cvs($sbj, $paypal['custom'])) && ($sbj = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $sbj))) { if (($sbj = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $sbj)) && ($sbj = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $sbj))) { if (($sbj = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $sbj)) && ($sbj = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $sbj))) { if (($sbj = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $sbj)) && ($sbj = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $sbj))) { if (($sbj = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $sbj)) && ($sbj = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $sbj))) { if (($sbj = preg_replace('/%%initial_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['initial_term'])), $sbj)) && ($sbj = preg_replace('/%%regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], $paypal['recurring'])), $sbj))) { if (($sbj = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $sbj)) && ($sbj = preg_replace('/%%recurring\\/regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring'] ? $paypal['recurring'] . ' / ' . c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], TRUE) : '0 / non-recurring'), $sbj))) { if (($sbj = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $sbj)) && ($sbj = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $sbj))) { if (($sbj = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $sbj)) && ($sbj = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $sbj))) { if ($sbj = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $sbj)) { if ($sbj = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $sbj)) { if (($sbj = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $sbj)) && ($sbj = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $sbj))) { if ($sbj = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $sbj)) { if ($sbj = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $sbj)) { if ($sbj = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $sbj)) { if ($sbj = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $sbj)) { if ($sbj = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $sbj)) { if (($msg = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $msg))) { if (($msg = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $msg)) && ($msg = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $msg))) { if (($msg = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $msg)) && ($msg = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $msg))) { if (($msg = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $msg)) && ($msg = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $msg))) { if (($msg = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $msg)) && ($msg = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $msg))) { if (($msg = preg_replace('/%%initial_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['initial_term'])), $msg)) && ($msg = preg_replace('/%%regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], $paypal['recurring'])), $msg))) { if (($msg = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $msg)) && ($msg = preg_replace('/%%recurring\\/regular_cycle%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring'] ? $paypal['recurring'] . ' / ' . c_ws_plugin__s2member_utils_time::period_term($paypal['regular_term'], TRUE) : '0 / non-recurring'), $msg))) { if (($msg = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $msg)) && ($msg = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $msg))) { if (($msg = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $msg)) && ($msg = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $msg))) { if ($msg = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $msg)) { if ($msg = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $msg)) { if (($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) && ($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $msg))) { if ($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $msg)) { if ($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $msg)) { if ($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $msg)) { if ($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { $rec = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $rec); $sbj = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $sbj); $msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg); } } if (($rec = trim(preg_replace('/%%(.+?)%%/i', '', $rec))) && ($sbj = trim(preg_replace('/%%(.+?)%%/i', '', $sbj))) && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { $sbj = c_ws_plugin__s2member_utilities::evl($sbj, get_defined_vars()); $msg = c_ws_plugin__s2member_utilities::evl($msg, get_defined_vars()); } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { c_ws_plugin__s2member_email_configs::email_config() . wp_mail($recipient, apply_filters('ws_plugin__s2member_modification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_modification_email_msg', $msg, get_defined_vars()), 'From: "' . preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '" <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>' . "\r\n" . 'Content-Type: text/plain; charset=UTF-8') . c_ws_plugin__s2member_email_configs::email_config_release(); } $paypal['s2member_log'][] = 'Modification Confirmation Email sent to: ' . $rec . '.'; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_notification_urls']) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_notification_urls']) as $url) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_id'])), $url))) { if (($url = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_baid'])), $url)) && ($url = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_cid'])), $url))) { if (($url = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency'])), $url)) && ($url = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency_symbol'])), $url))) { if (($url = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['initial'])), $url)) && ($url = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['regular'])), $url)) && ($url = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['recurring'])), $url))) { if (($url = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['initial_term'])), $url)) && ($url = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['regular_term'])), $url))) { if (($url = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_number'])), $url)) && ($url = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_name'])), $url))) { if (($url = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['first_name'])), $url)) && ($url = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['last_name'])), $url))) { if ($url = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $url)) { if ($url = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['payer_email'])), $url)) { if (($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) { if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . ' ' . $user->last_name))), $url)) { if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) { if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) { if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) { if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } } if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } } } $paypal['s2member_log'][] = 'Modification Notification URLs have been processed.'; } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_notification_recipients']) { $msg = $sbj = '(s2Member / API Notification Email) - Modification'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'subscr_id: %%subscr_id%%' . "\n"; $msg .= 'subscr_baid: %%subscr_baid%%' . "\n"; $msg .= 'subscr_cid: %%subscr_cid%%' . "\n"; $msg .= 'currency: %%currency%%' . "\n"; $msg .= 'currency_symbol: %%currency_symbol%%' . "\n"; $msg .= 'initial: %%initial%%' . "\n"; $msg .= 'regular: %%regular%%' . "\n"; $msg .= 'recurring: %%recurring%%' . "\n"; $msg .= 'initial_term: %%initial_term%%' . "\n"; $msg .= 'regular_term: %%regular_term%%' . "\n"; $msg .= 'item_number: %%item_number%%' . "\n"; $msg .= 'item_name: %%item_name%%' . "\n"; $msg .= 'first_name: %%first_name%%' . "\n"; $msg .= 'last_name: %%last_name%%' . "\n"; $msg .= 'full_name: %%full_name%%' . "\n"; $msg .= 'payer_email: %%payer_email%%' . "\n"; $msg .= 'user_first_name: %%user_first_name%%' . "\n"; $msg .= 'user_last_name: %%user_last_name%%' . "\n"; $msg .= 'user_full_name: %%user_full_name%%' . "\n"; $msg .= 'user_email: %%user_email%%' . "\n"; $msg .= 'user_login: %%user_login%%' . "\n"; $msg .= 'user_ip: %%user_ip%%' . "\n"; $msg .= 'user_id: %%user_id%%' . "\n"; if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { $msg .= $var . ': %%' . $var . '%%' . "\n"; } } $msg .= 'cv0: %%cv0%%' . "\n"; $msg .= 'cv1: %%cv1%%' . "\n"; $msg .= 'cv2: %%cv2%%' . "\n"; $msg .= 'cv3: %%cv3%%' . "\n"; $msg .= 'cv4: %%cv4%%' . "\n"; $msg .= 'cv5: %%cv5%%' . "\n"; $msg .= 'cv6: %%cv6%%' . "\n"; $msg .= 'cv7: %%cv7%%' . "\n"; $msg .= 'cv8: %%cv8%%' . "\n"; $msg .= 'cv9: %%cv9%%'; if (($msg = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $msg))) { if (($msg = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $msg)) && ($msg = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $msg))) { if (($msg = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $msg)) && ($msg = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $msg))) { if (($msg = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $msg)) && ($msg = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $msg)) && ($msg = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $msg))) { if (($msg = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $msg)) && ($msg = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $msg))) { if (($msg = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $msg)) && ($msg = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $msg))) { if (($msg = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $msg)) && ($msg = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $msg))) { if ($msg = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $msg)) { if ($msg = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $msg)) { if (($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) && ($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $msg))) { if ($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $msg)) { if ($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $msg)) { if ($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $msg)) { if ($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } } if ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_modification_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_modification_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } } } } } } } } $paypal['s2member_log'][] = 'Modification Notification Emails have been processed.'; } if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($code = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_id']), $code))) { if (($code = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_baid']), $code)) && ($code = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['subscr_cid']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%initial%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial']), $code)) && ($code = preg_replace('/%%regular%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular']), $code)) && ($code = preg_replace('/%%recurring%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['recurring']), $code))) { if (($code = preg_replace('/%%initial_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['initial_term']), $code)) && ($code = preg_replace('/%%regular_term%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['regular_term']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if (($code = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $code)) && ($code = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $code))) { if ($code = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $code)) { if ($code = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $code)) { if ($code = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $code)) { if ($code = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $code)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($code = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $code))) { break; } } } if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_modification_tracking_codes_' . $paypal['subscr_id']), $code, 43200); } } } } } } } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_during_subscr_modify', get_defined_vars()); unset($__refs, $__v); } else { $paypal['s2member_log'][] = 'Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.'; } } else { $paypal['s2member_log'][] = 'Unable to modify Subscription. Could not get the existing User ID from the DB.'; } } else { $paypal['s2member_log'][] = 'Not processing. Duplicate IPN.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `subscr_modify` ).'; $paypal['s2member_log'][] = 'Duplicate IPN. Already processed. This IPN will be ignored.'; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_after_subscr_modify', get_defined_vars()); unset($__refs, $__v); return apply_filters('c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level', $paypal, get_defined_vars()); } else { return apply_filters('c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level', FALSE, get_defined_vars()); } }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_payment|recurring_payment)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!empty($paypal["subscr_baid"]) || ($paypal["subscr_baid"] = $paypal["subscr_id"])) && (!empty($paypal["subscr_cid"]) || ($paypal["subscr_cid"] = $paypal["subscr_id"])) && !empty($paypal["txn_id"]) && !empty($paypal["mc_gross"])) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_payment|recurring_payment` )") . "."; if (empty($_REQUEST["s2member_paypal_proxy"])) { $paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` )."; sleep(5); // Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify. $paypal["s2member_log"][] = "Awake. It's " . date("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . "."; } list($paypal["level"], $paypal["ccaps"]) = preg_split("/\\:/", $paypal["item_number"], 3); $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : ""; $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"]; if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) { $processing = $during = true; // Yes, we ARE processing this. $pr_times = get_user_option("s2member_paid_registration_times", $user_id); $pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"]; // Preserves existing. $pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]]; update_user_option($user_id, "s2member_paid_registration_times", $pr_times); // Update now. if (!get_user_option("s2member_first_payment_txn_id", $user_id)) { // 1st payment? update_user_option($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]); } update_user_option($user_id, "s2member_last_payment_time", time()); // Also update last payment time. $paypal["s2member_log"][] = "Updated Payment Times for this Member."; // Flag this action in the log. $fields = get_user_option("s2member_custom_fields", $user_id); // These will be needed in the routines below. $user_reg_ip = get_user_option("s2member_registration_ip", $user_id); // Original IP during Registration. $user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"]; // Now merge conditionally. if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_id"])), $url))) { if (($url = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_baid"])), $url)) && ($url = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_cid"])), $url))) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["payer_email"])), $url)) { if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } } if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } $paypal["s2member_log"][] = "Payment Notification URLs have been processed."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "(s2Member / API Notification Email) - Payment"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "subscr_id: %%subscr_id%%\n"; $msg .= "subscr_baid: %%subscr_baid%%\n"; $msg .= "subscr_cid: %%subscr_cid%%\n"; $msg .= "amount: %%amount%%\n"; $msg .= "txn_id: %%txn_id%%\n"; $msg .= "item_number: %%item_number%%\n"; $msg .= "item_name: %%item_name%%\n"; $msg .= "first_name: %%first_name%%\n"; $msg .= "last_name: %%last_name%%\n"; $msg .= "full_name: %%full_name%%\n"; $msg .= "payer_email: %%payer_email%%\n"; $msg .= "user_first_name: %%user_first_name%%\n"; $msg .= "user_last_name: %%user_last_name%%\n"; $msg .= "user_full_name: %%user_full_name%%\n"; $msg .= "user_email: %%user_email%%\n"; $msg .= "user_login: %%user_login%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "user_id: %%user_id%%\n"; if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { $msg .= $var . ": %%" . $var . "%%\n"; } } $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_id"]), $msg))) { if (($msg = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_baid"]), $msg)) && ($msg = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["subscr_cid"]), $msg))) { if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["txn_id"]), $msg))) { if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($paypal["payer_email"]), $msg)) { if (($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) && ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $msg))) { if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . " " . $user->last_name)), $msg)) { if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $msg)) { if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $msg)) { if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } } if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } } } } } $paypal["s2member_log"][] = "Payment Notification Emails have been processed."; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars()); unset($__refs, $__v); } else { $paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member."; $ipn = array("txn_type" => "subscr_payment"); // Create a simulated IPN response for txn_type=subscr_payment. foreach ($paypal as $var => $val) { if (in_array($var, array("subscr_gateway", "subscr_id", "subscr_baid", "subscr_cid", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2"))) { $ipn[$var] = $val; } } $paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration."; set_transient("s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200); } } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_payment|recurring_payment` )."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars()); unset($__refs, $__v); return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level", false, get_defined_vars()); } }
/** * Handles the importation of Users/Members. * * @package s2Member\Imports * @since 110815 * * @return null */ public static function import_users() { if (!empty($_POST["ws_plugin__s2member_pro_import_users"]) && ($nonce = $_POST["ws_plugin__s2member_pro_import_users"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-pro-import-users") && current_user_can("create_users")) { global $wpdb; global $current_site, $current_blog; @set_time_limit(0); @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT)); remove_all_actions("profile_update") . remove_all_actions("user_register"); remove_all_actions("added_existing_user") . remove_all_actions("add_user_to_blog"); if (!empty($_FILES["ws_plugin__s2member_pro_import_users_file"]) && empty($_FILES["ws_plugin__s2member_pro_import_users_file"]["error"])) { $file = fopen($_FILES["ws_plugin__s2member_pro_import_users_file"]["tmp_name"], "r"); } else { if (!empty($_POST["ws_plugin__s2member_pro_import_users_direct_input"])) { fwrite($file = tmpfile(), trim(stripslashes($_POST["ws_plugin__s2member_pro_import_users_direct_input"]))) . fseek($file, 0); } } if (isset($file) && is_resource($file) && !($imported = 0)) { $custom_field_vars = array(); if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) { foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], TRUE) as $field) { $custom_field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); $custom_field_vars[] = $custom_field_var; } } sort($custom_field_vars, SORT_STRING); while (($data = version_compare(PHP_VERSION, "5.3", ">=") ? fgetcsv($file, 0, ",", '"', '"') : fgetcsv($file, 0, ",", '"')) !== false) { $line = (int) $line + 1; $data = c_ws_plugin__s2member_utils_strings::trim_deep($data); $data = stripslashes_deep($data); if ($line === 1 && strtoupper($data[0]) === "ID") { $line = $line - 1; continue; } if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { $ID = $data[0]; $user_login = is_multisite() ? strtolower($data[1]) : $data[1]; $user_login = preg_replace("/\\s+/", "", sanitize_user($user_login, is_multisite())); $user_pass = (string) ""; $first_name = $data[2]; $last_name = $data[3]; $display_name = $data[4]; $user_email = sanitize_email($data[5]); $user_url = $data[6]; $role = $data[7]; $custom_capabilities = $data[8]; $user_registered = $data[9] ? date("Y-m-d H:i:s", strtotime($data[9])) : ""; $paid_registration_times = $data[10] ? maybe_unserialize($data[10]) : ""; $last_payment_time = $data[11] ? strtotime($data[11]) : ""; $auto_eot_time = $data[12] ? strtotime($data[12]) : ""; $custom = $data[13]; $subscr_id = $data[14]; $subscr_gateway = strtolower($data[15]); $custom_fields = array(); if (count($data) > 16) { for ($i = 16, $j = 0; $i < count($data); $i++, $j++) { if (isset($custom_field_vars[$j])) { $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]); } } } } else { $ID = $data[0]; $user_login = is_multisite() ? strtolower($data[1]) : $data[1]; $user_login = preg_replace("/\\s+/", "", sanitize_user($user_login, is_multisite())); $user_pass = $data[2]; $first_name = $data[3]; $last_name = $data[4]; $display_name = $data[5]; $user_email = sanitize_email($data[6]); $user_url = $data[7]; $role = $data[8]; $custom_capabilities = $data[9]; $user_registered = $data[10] ? date("Y-m-d H:i:s", strtotime($data[10])) : ""; $paid_registration_times = $data[11] ? maybe_unserialize($data[11]) : ""; $last_payment_time = $data[12] ? strtotime($data[12]) : ""; $auto_eot_time = $data[13] ? strtotime($data[13]) : ""; $custom = $data[14]; $subscr_id = $data[15]; $subscr_gateway = strtolower($data[16]); $custom_fields = array(); if (count($data) > 17) { for ($i = 17, $j = 0; $i < count($data); $i++, $j++) { if (isset($custom_field_vars[$j])) { $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]); } } } } $role = is_numeric($role) ? $role == 0 ? "subscriber" : "s2member_level" . $role : $role; if ($paid_registration_times && !is_array($paid_registration_times)) { $paid_registration_times = array("level" => strtotime($paid_registration_times)); } $paid_registration_times = !$paid_registration_times || !is_array($paid_registration_times) ? array() : $paid_registration_times; $user_details = compact("ID", "user_login", "user_pass", "first_name", "last_name", "display_name", "user_email", "user_url", "role", "user_registered"); if (empty($user_details["user_pass"])) { // If there was NO Password given. unset($user_details["user_pass"]); } // Unset the Password array element. if ($ID) { if (is_object($user = new WP_User($ID)) && $user->ID) { if (!is_multisite() || is_user_member_of_blog($ID)) { if ((!is_multisite() || !is_super_admin($ID)) && !$user->has_cap("administrator")) { if (strtolower($role) !== "administrator") { if ($user_email && is_email($user_email)) { if ($user_login) { if (validate_username($user_login)) { if (($_same_email = strtolower($user_email) === strtolower($user->user_email)) || !email_exists($user_email)) { if (($_same_login = strtolower($user_login) === strtolower($user->user_login)) || !username_exists($user_login)) { if (!is_multisite() || $_same_email && $_same_login || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_["errors"]) || !$_["errors"]->get_error_code())) { if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { unset($user_details["user_login"], $user_details["user_pass"]); } if ($user_id = wp_update_user($user_details)) { $user = new WP_User($ID); // Refresh object value. update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_paid_registration_times", $paid_registration_times); update_user_option($user_id, "s2member_last_payment_time", $last_payment_time); update_user_option($user_id, "s2member_custom_fields", $custom_fields); foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } $imported = $imported + 1; } else { $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> could NOT be updated. Unknown error, please try again."; } } else { $errors[] = "Line #" . $line . ". Network. The Username and/or Email (<code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code>) are in conflict w/ Network rules."; } } else { $errors[] = "Line #" . $line . ". Conflicting. The Username (<code>" . esc_html($user_login) . "</code>), already exists."; } } else { $errors[] = "Line #" . $line . ". Conflicting. The Email address (<code>" . esc_html($user_email) . "</code>), already exists."; } } else { $errors[] = "Line #" . $line . ". Invalid Username (<code>" . esc_html($user_login) . "</code>). Lowercase alphanumerics are required."; } } else { $errors[] = "Line #" . $line . ". Missing Username; please try again."; } // We have two separate errors for Usernames. This provides clarity. } else { $errors[] = "Line #" . $line . ". Missing or invalid Email address (<code>" . esc_html($user_email) . "</code>); please try again."; } } else { $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> cannot be updated to an Administrator. Bypassing this line for security."; } } else { $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> belongs to an Administrator. Bypassing this line for security."; } } else { $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User on this site."; } } else { $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User."; } } else { if (is_multisite() && ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email)) && !is_super_admin($user_id)) { if (strtolower($role) !== "administrator") { if (add_existing_user_to_blog(array("user_id" => $user_id, "role" => $role))) { if (is_object($user = new WP_User($user_id)) && $user->ID) { update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_paid_registration_times", $paid_registration_times); update_user_option($user_id, "s2member_last_payment_time", $last_payment_time); update_user_option($user_id, "s2member_custom_fields", $custom_fields); foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } $imported = $imported + 1; } else { $errors[] = "Line #" . $line . ". Unknown object error, please try again."; } } else { $errors[] = "Line #" . $line . ". Unknown User/site addition error, please try again."; } } else { $errors[] = "Line #" . $line . ". Role cannot be Administrator. Bypassing this line for security."; } } else { if (strtolower($role) !== "administrator") { if ($user_email && is_email($user_email)) { if ($user_login) { if (validate_username($user_login)) { if (!email_exists($user_email)) { if (!username_exists($user_login)) { if (!is_multisite() || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_["errors"]) || !$_["errors"]->get_error_code())) { if ($user_id = wp_insert_user($user_details)) { if (is_object($user = new WP_User($user_id)) && $user->ID) { if ($user_pass) { // If we are given an "un-encrypted Password". wp_update_user(array("ID" => $user_id, "user_pass" => $user_pass)); } if (is_multisite()) { // New Users on a Multisite Network need this too. update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id); } update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_paid_registration_times", $paid_registration_times); update_user_option($user_id, "s2member_last_payment_time", $last_payment_time); update_user_option($user_id, "s2member_custom_fields", $custom_fields); foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } $imported = $imported + 1; } else { $errors[] = "Line #" . $line . ". Unknown object error, please try again."; } } else { $errors[] = "Line #" . $line . ". Unknown insertion error, please try again."; } } else { $errors[] = "Line #" . $line . ". Network. The Username and/or Email (<code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code>) are in conflict w/ Network rules."; } } else { $errors[] = "Line #" . $line . ". Conflicting. The Username (<code>" . esc_html($user_login) . "</code>), already exists."; } } else { $errors[] = "Line #" . $line . ". Conflicting. The Email address (<code>" . esc_html($user_email) . "</code>), already exists."; } } else { $errors[] = "Line #" . $line . ". Invalid Username (<code>" . esc_html($user_login) . "</code>). Lowercase alphanumerics are required."; } } else { $errors[] = "Line #" . $line . ". Missing Username; please try again."; } // We have two separate errors for Usernames. This provides clarity. } else { $errors[] = "Line #" . $line . ". Missing or invalid Email address (<code>" . esc_html($user_email) . "</code>); please try again."; } } else { $errors[] = "Line #" . $line . ". Role cannot be Administrator. Bypassing this line for security."; } } } } fclose($file); } else { $errors[] = "No data was received. Please try again."; } // The upload failed, or it was empty. c_ws_plugin__s2member_admin_notices::display_admin_notice('Operation complete. Users/Members imported: <code>' . (int) $imported . '</code>.'); if (!empty($errors)) { // Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation. c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode("</li><li>", $errors) . '</li></ul>', true); } } return; }
/** * s2Member's PayPal Auto-Return/PDT handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}. * * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_wo_level_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['txn_id']) && !empty($paypal['payer_email']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_before_new_ccaps', get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) { $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.'; list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3); $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : ''; $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip']; $paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip']; $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) { if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['txn_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) { if (!$user->has_cap('administrator')) { $processing = $during = TRUE; // Yes, we ARE processing this. $fields = get_user_option('s2member_custom_fields', $user_id); // These will be needed in the routines below. $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); // Original IP during Registration. $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip']; // Now merge conditionally. if (is_multisite() && !is_user_member_of_blog($user_id)) { add_existing_user_to_blog(array('user_id' => $user_id, 'role' => get_option('default_role'))); $user = new WP_User($user_id); } if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } if (!get_user_option('s2member_registration_ip', $user_id)) { update_user_option($user_id, 's2member_registration_ip', $paypal['ip']); } $paypal['s2member_log'][] = 's2Member Custom Capabilities updated w/ advanced update routines.'; setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['txn_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking); $paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept` ) w/ update vars for Capabilities w/o Level.'; if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_tracking_codes']) && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { if (($code = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $code)) && ($code = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) { if (($code = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $code)) && ($code = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if (($code = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $code)) && ($code = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $code))) { if ($code = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $code)) { if ($code = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $code)) { if ($code = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $code)) { if ($code = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $code)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($code = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $code))) { break; } } } if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_ccap_tracking_codes_' . $paypal['txn_id']), $code, 43200); } } } } } } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_during_new_ccaps', get_defined_vars()); unset($__refs, $__v); if ($redirection_url_after_capabilities = apply_filters('ws_plugin__s2member_redirection_url_after_capabilities', FALSE, get_defined_vars())) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL after Capabilities: ' . $redirection_url_after_capabilities; wp_redirect($redirection_url_after_capabilities); } else { $paypal['s2member_log'][] = 'Redirecting Customer to the Login Page (after displaying a quick thank-you message). They need to log back in.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], '<strong>' . _x('Thank you! You now have access to:', 's2member-front', 's2member') . '<br /><em>' . esc_html($paypal['item_name']) . '</em></strong>', _x('Please Log Back In (Click Here)', 's2member-front', 's2member'), wp_login_url()); } } else { $paypal['s2member_log'][] = 'Unable to add new Capabilities. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } } else { $paypal['s2member_log'][] = 'Unable to add new Capabilities. Could not get the existing User ID from the DB.'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } } else { $paypal['s2member_log'][] = 'Unable to add new Capabilities. Missing User/Member details. Please check the `on0` and `os0` variables in your Button Code.'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to add new Capabilities.<br />Please contact Support for assistance.<br /><br />Missing User/Member details.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } } else { $paypal['s2member_log'][] = 'Page Expired. Duplicate Return-Data.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.'; $paypal['s2member_log'][] = 'Page Expired. Instructing customer to check their email for further details about how to obtain access to what they purchased.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], '<strong>' . _x('Thank you! Please check your email for further details regarding your purchase.', 's2member-front', 's2member') . '</strong>', _x('Return to Home Page', 's2member-front', 's2member'), home_url('/')); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_after_new_ccaps', get_defined_vars()); unset($__refs, $__v); return apply_filters('c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level', $paypal, get_defined_vars()); } else { return apply_filters('c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level', FALSE, get_defined_vars()); } }
/** * For Multisite Networks, this function is used to add a User to an existing Blog; and to simulate ``wp_create_user()`` behavior. * * The ``$user_id`` value will be returned by this function, just like ``wp_create_user()`` does. * This function will fire the Hook `user_register`. * * @package s2Member\Registrations * @since 3.5 * * @param str $user_login Expects the User's Username. * @param str $user_email Expects the User's Email Address. * @param str $user_pass Expects the User's plain text Password. * @param int|str $user_id Optional. A numeric WordPress User ID. * If unspecified, a lookup is performed with ``$user_login`` and ``$user_email``. * @return int|false Returns numeric ``$user_id`` on success, else false on failure. */ public static function ms_create_existing_user($user_login = FALSE, $user_email = FALSE, $user_pass = FALSE, $user_id = FALSE) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_ms_create_existing_user", get_defined_vars()); unset($__refs, $__v); if (is_multisite()) { if (($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email))) && $user_pass) { $role = get_option("default_role"); // Use default Role. add_existing_user_to_blog(array("user_id" => $user_id, "role" => $role)); // Add User. wp_update_user(array("ID" => $user_id, "user_pass" => $user_pass)); // Update to ``$user_pass``. do_action("ws_plugin__s2member_during_ms_create_existing_user", get_defined_vars()); do_action("user_register", $user_id); // So s2Member knows a User is registering. return apply_filters("ws_plugin__s2member_ms_create_existing_user", $user_id, get_defined_vars()); } } return apply_filters("ws_plugin__s2member_ms_create_existing_user", false, 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 />— 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; } } } }
/** * Google JWT generator. * * @package s2Member\Google * @since 131123 * * @param array $attr An array of Attributes. * @param str $content Content inside the Shortcode. * @param str $shortcode The actual Shortcode name itself. * @return str The resulting Google Button Code, HTML markup. */ public static function google_jwt() { if (empty($_GET["s2member_pro_google_jwt"])) { return; } // Nothing to do. 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. $current_user = wp_get_current_user(); if (!empty($_REQUEST["s2member_pro_google_jwt_vars"]["email"])) { $em = stripslashes((string) $_REQUEST["s2member_pro_google_jwt_vars"]["email"]); } else { if ($current_user && !empty($current_user->user_email)) { $em = $current_user->user_email; } else { exit; } } // Not possible. if (!empty($_REQUEST["s2member_pro_google_jwt_vars"]["fname"])) { $fn = stripslashes((string) $_REQUEST["s2member_pro_google_jwt_vars"]["fname"]); } else { if ($current_user && !empty($current_user->first_name)) { $fn = $current_user->first_name; } else { if ($current_user && !empty($current_user->display_name)) { $fn = $current_user->display_name; } else { $fn = $em; } } } if (!empty($_REQUEST["s2member_pro_google_jwt_vars"]["lname"])) { $ln = stripslashes((string) $_REQUEST["s2member_pro_google_jwt_vars"]["lname"]); } else { if ($current_user && !empty($current_user->last_name)) { $ln = $current_user->last_name; } else { $ln = ""; } } // No last name available. if (empty($_REQUEST["s2member_pro_google_jwt_vars"]["attr"])) { exit; } $attr = stripslashes((string) $_REQUEST["s2member_pro_google_jwt_vars"]["attr"]); $attr = (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($attr)); $attr = array_merge(array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "rrt" => "", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "anchor", "success" => "", "failure" => ""), $attr); $attr["tt"] = strtoupper($attr["tt"]); $attr["rt"] = strtoupper($attr["rt"]); $attr["rr"] = strtoupper($attr["rr"]); $attr["ccaps"] = strtolower($attr["ccaps"]); $attr["ccaps"] = str_replace(" ", "", $attr["ccaps"]); $attr["rr"] = $attr["rt"] === "L" ? "BN" : $attr["rr"]; $attr["rr"] = $attr["level"] === "*" ? "BN" : $attr["rr"]; $attr["rr"] = !$attr["tp"] && !$attr["rr"] ? "BN" : $attr["rr"]; $attr["referencing"] = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id(); include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/_xtnls/JWT.php'; if ($attr["sp"]) { $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"]; $jwt["iss"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]; $jwt["aud"] = "Google"; $jwt["typ"] = "google/payments/inapp/item/v1"; $jwt["exp"] = time() + 3600; $jwt["iat"] = time(); $jwt["request"] = array("name" => substr($_SERVER["HTTP_HOST"], 0, 50), "description" => substr($attr["desc"], 0, 100), "price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "sellerData" => json_encode(array("cs" => $attr["custom"], "in" => $attr["sp_ids_exp"], "ip" => $_SERVER["REMOTE_ADDR"], "rf" => $attr["referencing"], "fn" => $fn, "ln" => $ln, "em" => $em))); $jwt = JWT::encode($jwt, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]); } else { if ($attr["level"] === "*") { $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); // Right-trim separators from this string so we don't have trailing colons. $jwt["iss"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]; $jwt["aud"] = "Google"; $jwt["typ"] = "google/payments/inapp/item/v1"; $jwt["exp"] = time() + 3600; $jwt["iat"] = time(); $jwt["request"] = array("name" => substr($_SERVER["HTTP_HOST"], 0, 50), "description" => substr($attr["desc"], 0, 100), "price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "sellerData" => json_encode(array("cs" => $attr["custom"], "in" => $attr["level_ccaps_eotper"], "ip" => $_SERVER["REMOTE_ADDR"], "rf" => $attr["referencing"], "fn" => $fn, "ln" => $ln, "em" => $em))); $jwt = JWT::encode($jwt, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]); } else { if ($attr["rr"] === "BN" || !$attr["tp"] && !$attr["rr"]) { $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); // Right-trim separators from this string so we don't have trailing colons. $jwt["iss"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]; $jwt["aud"] = "Google"; $jwt["typ"] = "google/payments/inapp/item/v1"; $jwt["exp"] = time() + 3600; $jwt["iat"] = time(); $jwt["request"] = array("name" => substr($_SERVER["HTTP_HOST"], 0, 50), "description" => substr($attr["desc"], 0, 100), "price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "sellerData" => json_encode(array("cs" => $attr["custom"], "in" => $attr["level_ccaps_eotper"], "ip" => $_SERVER["REMOTE_ADDR"], "rf" => $attr["referencing"], "fn" => $fn, "ln" => $ln, "em" => $em))); $jwt = JWT::encode($jwt, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]); } else { $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; $attr["level_ccaps_eotper"] = $attr["level"] . ":" . $attr["ccaps"]; // Actual Subscriptions will always end on their own. $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); // Clean any trailing separators from this string. $attr["periodicity"] = c_ws_plugin__s2member_pro_google_utilities::google_periodicity($attr["rp"] . " " . $attr["rt"]); if ($attr["tp"]) { $attr["start_time"] = c_ws_plugin__s2member_pro_google_utilities::google_start_time($attr["tp"] . " " . $attr["tt"]); $jwt["iss"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]; $jwt["aud"] = "Google"; $jwt["typ"] = "google/payments/inapp/subscription/v1"; $jwt["exp"] = time() + 3600; $jwt["iat"] = time(); $jwt["request"] = array("name" => substr($_SERVER["HTTP_HOST"], 0, 50), "description" => substr($attr["desc"], 0, 100), "initialPayment" => array("price" => number_format($attr["ta"], 2, ".", ""), "currencyCode" => $attr["cc"], "paymentType" => $attr["ta"] > 0 ? "prorated" : "free_trial"), "recurrence" => array("price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "startTime" => $attr["start_time"], "frequency" => $attr["periodicity"], "numRecurrences" => !$attr["rr"] ? 1 : ($attr["rrt"] ? $attr["rrt"] : NULL)), "sellerData" => json_encode(array("cs" => $attr["custom"], "in" => $attr["level_ccaps_eotper"], "p1" => $attr["tp"] . " " . $attr["tt"], "p3" => $attr["rp"] . " " . $attr["rt"], "rr" => $attr["rr"], "ip" => $_SERVER["REMOTE_ADDR"], "rf" => $attr["referencing"], "fn" => $fn, "ln" => $ln, "em" => $em))); } else { if (!$attr["tp"] && $attr["rr"]) { $attr["start_time"] = c_ws_plugin__s2member_pro_google_utilities::google_start_time($attr["rp"] . " " . $attr["rt"]); $jwt["iss"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]; $jwt["aud"] = "Google"; $jwt["typ"] = "google/payments/inapp/subscription/v1"; $jwt["exp"] = time() + 3600; $jwt["iat"] = time(); $jwt["request"] = array("name" => substr($_SERVER["HTTP_HOST"], 0, 50), "description" => substr($attr["desc"], 0, 100), "initialPayment" => array("price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "paymentType" => "prorated"), "recurrence" => array("price" => number_format($attr["ra"], 2, ".", ""), "currencyCode" => $attr["cc"], "startTime" => $attr["start_time"], "frequency" => $attr["periodicity"], "numRecurrences" => !$attr["rr"] ? 1 : ($attr["rrt"] ? $attr["rrt"] : NULL)), "sellerData" => json_encode(array("cs" => $attr["custom"], "in" => $attr["level_ccaps_eotper"], "p1" => "0 D", "p3" => $attr["rp"] . " " . $attr["rt"], "rr" => $attr["rr"], "ip" => $_SERVER["REMOTE_ADDR"], "rf" => $attr["referencing"], "fn" => $fn, "ln" => $ln, "em" => $em))); } } $jwt = JWT::encode($jwt, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]); } } } exit(!empty($jwt) ? $jwt : ""); }
/** * Get `period3` from either an array with `PROFILEREFERENCE|rp_invoice_id|period3`, or use an existing string. * * This will also convert `1 Day`, into `1 D`, and so on. * This will also convert `1 SemiMonth`, into `2 W`, and so on. * The Regular Period can never be less than 1 day ( `1 D` ). * * @package s2Member\PayPal * @since 3.5 * * @param string|array $array_or_string Either an array of PayPal post vars, or a string. * If it's a string, we make sure it is a valid `period term` combination. * @param string $default Optional. Value if unavailable. Defaults to `1 D`. * @return string A `period3` string if possible, or defaults to `1 D`. */ public static function paypal_pro_period3($array_or_string = FALSE, $default = "1 D") { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars()); unset($__refs, $__v); if (is_array($array_or_string) && isset($array_or_string["PROFILENAME"])) { $array_or_string["PROFILEREFERENCE"] = $array_or_string["PROFILENAME"]; } if (is_array($array = $array_or_string) && !empty($array["period3"])) { $_period3 = trim($array["period3"]); } else { if (is_array($array = $array_or_string) && (!empty($array["PROFILEREFERENCE"]) || !empty($array["rp_invoice_id"]))) { list($_reference, $_domain, $_item_number) = array_map("trim", preg_split("/~/", !empty($array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"], 3)); list($_start_time, $_period1, $_period3) = array_map("trim", preg_split("/\\:/", $_reference, 3)); } else { if (is_array($array = $array_or_string) && !empty($array["mp_id"]) && ($ipn_signup_var_period3 = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period3", FALSE, $array["mp_id"]))) { $_period3 = trim($ipn_signup_var_period3); } else { if (is_string($string = $array_or_string) && !empty($string)) { $_period3 = trim($string); } } } } if (!empty($_period3)) { list($num, $span) = array_map("trim", preg_split("/ /", $_period3, 2)); if (strtoupper($span) === "SEMIMONTH" && is_numeric($num) && $num >= 1) { $num = "2"; $span = "W"; } if (strlen($span) !== 1) { $span = c_ws_plugin__s2member_paypal_utilities::paypal_std_term($span); } $span = preg_match("/^[DWMY]\$/i", $span) ? $span : ""; $num = $span && is_numeric($num) && $num >= 0 ? $num : ""; $period3 = $num && $span ? $num . " " . strtoupper($span) : $default; return apply_filters("ws_plugin__s2member_paypal_pro_period3", $period3, get_defined_vars()); } else { return apply_filters("ws_plugin__s2member_paypal_pro_period3", $default, get_defined_vars()); } }
/** * Handles the Shortcode for: `[s2Member-PayPal-Button /]`. * * @package s2Member\PayPal * @since 3.5 * * @attaches-to ``add_shortcode("s2Member-PayPal-Button");`` * * @param array $attr An array of Attributes. * @param str $content Content inside the Shortcode. * @param str $shortcode The actual Shortcode name itself. * @return str The resulting PayPal Button Code. */ public static function sc_paypal_button($attr = FALSE, $content = FALSE, $shortcode = FALSE) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_sc_paypal_button", get_defined_vars()); unset($__refs, $__v); c_ws_plugin__s2member_no_cache::no_cache_constants(true); $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr); $attr = shortcode_atts(apply_filters("ws_plugin__s2member_sc_paypal_button_default_attrs", array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "ps" => "paypal", "lc" => "", "lang" => "", "cc" => "USD", "dg" => "0", "ns" => "1", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "rrt" => "", "rra" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "button"), get_defined_vars()), $attr); $attr["modify"] = $attr["modify"] === "1" && (!is_user_logged_in() || !get_user_option("s2member_subscr_id")) && $attr["tp"] ? "0" : $attr["modify"]; $attr["lc"] = strtoupper($attr["lc"]); $attr["tt"] = strtoupper($attr["tt"]); $attr["rt"] = strtoupper($attr["rt"]); $attr["rr"] = strtoupper($attr["rr"]); $attr["ccaps"] = strtolower($attr["ccaps"]); $attr["ccaps"] = str_replace(" ", "", $attr["ccaps"]); $attr["rr"] = $attr["rt"] === "L" ? "BN" : $attr["rr"]; $attr["rr"] = $attr["level"] === "*" ? "BN" : $attr["rr"]; $attr["ns"] = $attr["dg"] === "1" ? "1" : $attr["ns"]; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_sc_paypal_button_after_shortcode_atts", get_defined_vars()); unset($__refs, $__v); if ($attr["cancel"]) { $default_image = "https://www.paypal.com/" . ($attr["lang"] ? $attr["lang"] : _x("en_US", "s2member-front paypal-button-lang-code", "s2member")) . "/i/btn/btn_unsubscribe_LG.gif"; $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/buttons/paypal-cancellation-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url())), $code); $code = preg_replace("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com")), $code); $code = preg_replace("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? $code : $code; if ($attr["output"] === "url" && preg_match('/ href\\="(.*?)"/', $code, $m) && ($href = $m[1])) { $code = $url = c_ws_plugin__s2member_utils_urls::n_amps($href); } unset($href, $url, $m); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_sc_paypal_cancellation_button", get_defined_vars()); unset($__refs, $__v); } else { if ($attr["sp"]) { $default_image = "https://www.paypal.com/" . ($attr["lang"] ? $attr["lang"] : _x("en_US", "s2member-front paypal-button-lang-code", "s2member")) . "/i/btn/btn_xpressCheckout.gif"; $paypal_on0_input_value = ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) ? "Referencing Customer ID" : "Originating Domain"; $paypal_os0_input_value = $referencing ? $referencing : $_SERVER["HTTP_HOST"]; $paypal_on1_input_value = "Customer IP Address"; $paypal_os1_input_value = $_SERVER["REMOTE_ADDR"]; $paypal_invoice_input_value = uniqid() . "~" . $_SERVER["REMOTE_ADDR"]; $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"]; $success_return_url = site_url("/?s2member_paypal_return=1"); $success_return_url = apply_filters("ws_plugin__s2member_during_sc_paypal_button_success_return_url", $success_return_url, get_defined_vars()); $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/buttons/paypal-sp-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url())), $code); $code = preg_replace("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com")), $code); $code = preg_replace("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code); $code = preg_replace("/%%cancel_return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(home_url("/"))), $code); $code = preg_replace("/%%notify_url%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url("/?s2member_paypal_notify=1"))), $code); $code = preg_replace("/%%return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($success_return_url)), $code); $code = preg_replace("/%%custom%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])), $code); $code = preg_replace('/ name\\="lc" value\\="(.*?)"/', ' name="lc" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["lc"])) . '"', $code); $code = preg_replace('/ name\\="no_shipping" value\\="(.*?)"/', ' name="no_shipping" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ns"])) . '"', $code); $code = preg_replace('/ name\\="item_name" value\\="(.*?)"/', ' name="item_name" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["desc"])) . '"', $code); $code = preg_replace('/ name\\="item_number" value\\="(.*?)"/', ' name="item_number" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["sp_ids_exp"])) . '"', $code); $code = preg_replace('/ name\\="page_style" value\\="(.*?)"/', ' name="page_style" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ps"])) . '"', $code); $code = preg_replace('/ name\\="currency_code" value\\="(.*?)"/', ' name="currency_code" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["cc"])) . '"', $code); $code = preg_replace('/ name\\="custom" value\\="(.*?)"/', ' name="custom" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])) . '"', $code); $code = preg_replace('/ name\\="invoice" value\\="(.*?)"/', ' name="invoice" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_invoice_input_value)) . '"', $code); $code = preg_replace('/ name\\="on0" value\\="(.*?)"/', ' name="on0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on0_input_value)) . '"', $code); $code = preg_replace('/ name\\="os0" value\\="(.*?)"/', ' name="os0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os0_input_value)) . '"', $code); $code = preg_replace('/ name\\="on1" value\\="(.*?)"/', ' name="on1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on1_input_value)) . '"', $code); $code = preg_replace('/ name\\="os1" value\\="(.*?)"/', ' name="os1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os1_input_value)) . '"', $code); $code = preg_replace('/ name\\="amount" value\\="(.*?)"/', ' name="amount" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ra"])) . '"', $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? '<a href="' . esc_attr(c_ws_plugin__s2member_utils_forms::form_whips_2_url($code)) . '"><img src="' . esc_attr($attr["image"] && $attr["image"] !== "default" ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal" /></a>' : $code; $code = $attr["output"] === "url" ? c_ws_plugin__s2member_utils_forms::form_whips_2_url($code) : $code; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_sc_paypal_sp_button", get_defined_vars()); unset($__refs, $__v); } else { if ($attr["level"] === "*") { $default_image = "https://www.paypal.com/" . ($attr["lang"] ? $attr["lang"] : _x("en_US", "s2member-front paypal-button-lang-code", "s2member")) . "/i/btn/btn_xpressCheckout.gif"; $paypal_on0_input_value = ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) ? "Referencing Customer ID" : "Originating Domain"; $paypal_os0_input_value = $referencing ? $referencing : $_SERVER["HTTP_HOST"]; $paypal_on1_input_value = "Customer IP Address"; $paypal_os1_input_value = $_SERVER["REMOTE_ADDR"]; $paypal_invoice_input_value = uniqid() . "~" . $_SERVER["REMOTE_ADDR"]; $attr["level_ccaps_eotper"] = $attr["rr"] === "BN" && $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); $success_return_url = site_url("/?s2member_paypal_return=1"); $success_return_url = apply_filters("ws_plugin__s2member_during_sc_paypal_button_success_return_url", $success_return_url, get_defined_vars()); $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/buttons/paypal-ccaps-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url())), $code); $code = preg_replace("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com")), $code); $code = preg_replace("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code); $code = preg_replace("/%%cancel_return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(home_url("/"))), $code); $code = preg_replace("/%%notify_url%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url("/?s2member_paypal_notify=1"))), $code); $code = preg_replace("/%%return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($success_return_url)), $code); $code = preg_replace("/%%custom%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])), $code); $code = preg_replace('/ name\\="lc" value\\="(.*?)"/', ' name="lc" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["lc"])) . '"', $code); $code = preg_replace('/ name\\="no_shipping" value\\="(.*?)"/', ' name="no_shipping" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ns"])) . '"', $code); $code = preg_replace('/ name\\="item_name" value\\="(.*?)"/', ' name="item_name" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["desc"])) . '"', $code); $code = preg_replace('/ name\\="item_number" value\\="(.*?)"/', ' name="item_number" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["level_ccaps_eotper"])) . '"', $code); $code = preg_replace('/ name\\="page_style" value\\="(.*?)"/', ' name="page_style" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ps"])) . '"', $code); $code = preg_replace('/ name\\="currency_code" value\\="(.*?)"/', ' name="currency_code" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["cc"])) . '"', $code); $code = preg_replace('/ name\\="custom" value\\="(.*?)"/', ' name="custom" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])) . '"', $code); $code = preg_replace('/ name\\="invoice" value\\="(.*?)"/', ' name="invoice" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_invoice_input_value)) . '"', $code); $code = preg_replace('/ name\\="on0" value\\="(.*?)"/', ' name="on0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on0_input_value)) . '"', $code); $code = preg_replace('/ name\\="os0" value\\="(.*?)"/', ' name="os0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os0_input_value)) . '"', $code); $code = preg_replace('/ name\\="on1" value\\="(.*?)"/', ' name="on1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on1_input_value)) . '"', $code); $code = preg_replace('/ name\\="os1" value\\="(.*?)"/', ' name="os1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os1_input_value)) . '"', $code); $code = preg_replace('/ name\\="amount" value\\="(.*?)"/', ' name="amount" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ra"])) . '"', $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? '<a href="' . esc_attr(c_ws_plugin__s2member_utils_forms::form_whips_2_url($code)) . '"><img src="' . esc_attr($attr["image"] && $attr["image"] !== "default" ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal" /></a>' : $code; $code = $attr["output"] === "url" ? c_ws_plugin__s2member_utils_forms::form_whips_2_url($code) : $code; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_sc_paypal_ccaps_button", get_defined_vars()); unset($__refs, $__v); } else { $default_image = "https://www.paypal.com/" . ($attr["lang"] ? $attr["lang"] : _x("en_US", "s2member-front paypal-button-lang-code", "s2member")) . "/i/btn/btn_xpressCheckout.gif"; $paypal_on0_input_value = ($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id()) ? "Referencing Customer ID" : "Originating Domain"; $paypal_os0_input_value = $referencing ? $referencing : $_SERVER["HTTP_HOST"]; $paypal_on1_input_value = "Customer IP Address"; $paypal_os1_input_value = $_SERVER["REMOTE_ADDR"]; $paypal_invoice_input_value = uniqid() . "~" . $_SERVER["REMOTE_ADDR"]; $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; $attr["level_ccaps_eotper"] = $attr["rr"] === "BN" && $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); $success_return_tra = array("ta" => $attr["ta"], "tp" => $attr["tp"], "tt" => $attr["tt"], "ra" => $attr["ra"], "rp" => $attr["rp"], "rt" => $attr["rt"], "rr" => $attr["rr"], "rrt" => $attr["rrt"], "rra" => $attr["rra"], "invoice" => $paypal_invoice_input_value, "checksum" => md5($paypal_invoice_input_value . $_SERVER["REMOTE_ADDR"] . $attr["level_ccaps_eotper"])); $success_return_url = site_url("/?s2member_paypal_return=1"); $success_return_url = add_query_arg("s2member_paypal_return_tra", urlencode(c_ws_plugin__s2member_utils_encryption::encrypt(serialize($success_return_tra))), $success_return_url); $success_return_url = apply_filters("ws_plugin__s2member_during_sc_paypal_button_success_return_url", $success_return_url, get_defined_vars()); $code = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/buttons/paypal-checkout-button.php"))); $code = preg_replace("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images")), $code); $code = preg_replace("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url())), $code); $code = preg_replace("/%%endpoint%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com")), $code); $code = preg_replace("/%%paypal_business%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])), $code); $code = preg_replace("/%%level_label%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"])), $code); $code = preg_replace("/%%cancel_return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(home_url("/"))), $code); // This brings them back to Front Page. $code = preg_replace("/%%notify_url%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr(site_url("/?s2member_paypal_notify=1"))), $code); $code = preg_replace("/%%return%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($success_return_url)), $code); $code = preg_replace("/%%custom%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])), $code); $code = preg_replace("/%%level%%/", c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["level"])), $code); $code = preg_replace('/ \\<\\!--(\\<input type\\="hidden" name\\="(amount|src|srt|sra|a1|p1|t1|a3|p3|t3)" value\\="(.*?)" \\/\\>)--\\>/', " \$1", $code); $code = $attr["rr"] === "BN" ? preg_replace('/ (\\<input type\\="hidden" name\\="cmd" value\\=")(.*?)(" \\/\\>)/', " \$1_xclick\$3", $code) : $code; $code = $attr["rr"] === "BN" ? preg_replace('/ (\\<input type\\="hidden" name\\="(src|srt|sra|a1|p1|t1|a3|p3|t3)" value\\="(.*?)" \\/\\>)/', " <!--\$1-->", $code) : $code; $code = $attr["rr"] === "BN" || !$attr["tp"] ? preg_replace('/ (\\<input type\\="hidden" name\\="(a1|p1|t1)" value\\="(.*?)" \\/\\>)/', " <!--\$1-->", $code) : $code; $code = $attr["rr"] !== "BN" ? preg_replace('/ (\\<input type\\="hidden" name\\="cmd" value\\=")(.*?)(" \\/\\>)/', " \$1_xclick-subscriptions\$3", $code) : $code; $code = $attr["rr"] !== "BN" ? preg_replace('/ (\\<input type\\="hidden" name\\="amount" value\\="(.*?)" \\/\\>)/', " <!--\$1-->", $code) : $code; $code = preg_replace('/ name\\="lc" value\\="(.*?)"/', ' name="lc" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["lc"])) . '"', $code); $code = preg_replace('/ name\\="no_shipping" value\\="(.*?)"/', ' name="no_shipping" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ns"])) . '"', $code); $code = preg_replace('/ name\\="item_name" value\\="(.*?)"/', ' name="item_name" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["desc"])) . '"', $code); $code = preg_replace('/ name\\="item_number" value\\="(.*?)"/', ' name="item_number" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["level_ccaps_eotper"])) . '"', $code); $code = preg_replace('/ name\\="page_style" value\\="(.*?)"/', ' name="page_style" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ps"])) . '"', $code); $code = preg_replace('/ name\\="currency_code" value\\="(.*?)"/', ' name="currency_code" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["cc"])) . '"', $code); $code = preg_replace('/ name\\="custom" value\\="(.*?)"/', ' name="custom" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["custom"])) . '"', $code); $code = preg_replace('/ name\\="invoice" value\\="(.*?)"/', ' name="invoice" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_invoice_input_value)) . '"', $code); $code = preg_replace('/ name\\="on0" value\\="(.*?)"/', ' name="on0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on0_input_value)) . '"', $code); $code = preg_replace('/ name\\="os0" value\\="(.*?)"/', ' name="os0" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os0_input_value)) . '"', $code); $code = preg_replace('/ name\\="on1" value\\="(.*?)"/', ' name="on1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_on1_input_value)) . '"', $code); $code = preg_replace('/ name\\="os1" value\\="(.*?)"/', ' name="os1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($paypal_os1_input_value)) . '"', $code); $code = preg_replace('/ name\\="modify" value\\="(.*?)"/', ' name="modify" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["modify"])) . '"', $code); $code = preg_replace('/ name\\="amount" value\\="(.*?)"/', ' name="amount" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ra"])) . '"', $code); $code = preg_replace('/ name\\="src" value\\="(.*?)"/', ' name="src" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["rr"])) . '"', $code); $code = preg_replace('/ name\\="srt" value\\="(.*?)"/', ' name="srt" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["rrt"])) . '"', $code); $code = preg_replace('/ name\\="sra" value\\="(.*?)"/', ' name="sra" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["rra"])) . '"', $code); $code = preg_replace('/ name\\="a1" value\\="(.*?)"/', ' name="a1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ta"])) . '"', $code); $code = preg_replace('/ name\\="p1" value\\="(.*?)"/', ' name="p1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["tp"])) . '"', $code); $code = preg_replace('/ name\\="t1" value\\="(.*?)"/', ' name="t1" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["tt"])) . '"', $code); $code = preg_replace('/ name\\="a3" value\\="(.*?)"/', ' name="a3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["ra"])) . '"', $code); $code = preg_replace('/ name\\="p3" value\\="(.*?)"/', ' name="p3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["rp"])) . '"', $code); $code = preg_replace('/ name\\="t3" value\\="(.*?)"/', ' name="t3" value="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["rt"])) . '"', $code); $code = $_code = $attr["image"] && $attr["image"] !== "default" ? preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($attr["image"])) . '"', $code) : preg_replace('/ src\\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds(esc_attr($default_image)) . '"', $code); $code = $attr["output"] === "anchor" ? '<a href="' . esc_attr(c_ws_plugin__s2member_utils_forms::form_whips_2_url($code)) . '"><img src="' . esc_attr($attr["image"] && $attr["image"] !== "default" ? $attr["image"] : $default_image) . '" style="width:auto; height:auto; border:0;" alt="PayPal" /></a>' : $code; $code = $attr["output"] === "url" ? c_ws_plugin__s2member_utils_forms::form_whips_2_url($code) : $code; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } $attr["modify"] ? do_action("ws_plugin__s2member_during_sc_paypal_modification_button", get_defined_vars()) : do_action("ws_plugin__s2member_during_sc_paypal_button", get_defined_vars()); unset($__refs, $__v); } } } $code = c_ws_plugin__s2member_sc_paypal_button_e::sc_paypal_button_encryption($code, get_defined_vars()); return apply_filters("ws_plugin__s2member_sc_paypal_button", $code, get_defined_vars()); }
/** * Handles processing of Pro Form checkouts. * * @package s2Member\PayPal * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection. */ public static function paypal_checkout() { if (!empty($_POST["s2member_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) { $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array(); /* 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 />— 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 />— 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 />— 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 />— 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 />— 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 />— 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; } } } }
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>Imports / Exports</h2>' . "\n"; echo '<table class="ws-menu-page-table">' . "\n"; echo '<tbody class="ws-menu-page-table-tbody">' . "\n"; echo '<tr class="ws-menu-page-table-tr">' . "\n"; echo '<td class="ws-menu-page-table-l">' . "\n"; if (isset($_REQUEST['enable_advanced_tools'])) { c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_pro_import_export_advanced_mode' => (string) (int) $_REQUEST['enable_advanced_tools']), TRUE, FALSE, FALSE, FALSE, FALSE); } $enable_advanced_tools = $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_import_export_advanced_mode']; if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { if (!$enable_advanced_tools) { echo '<p><i class="fa fa-eye"></i> <a href="' . esc_attr(add_query_arg('enable_advanced_tools', '1')) . '">click here to enable the Advanced Import/Export Tools</a> <i class="fa fa-eye"></i></p>'; } else { echo '<p><i class="fa fa-eye-slash"></i> <a href="' . esc_attr(add_query_arg('enable_advanced_tools', '0')) . '">click here to disable the Advanced Import/Export Tools</a> <i class="fa fa-eye-slash"></i></p>'; } } /* * Advanced version. */ if ($enable_advanced_tools) { echo '<div class="ws-menu-page-group" title="Advanced User/Member CSV Importation"' . (isset($_POST["ws_plugin__s2member_pro_import_users"]) ? ' default-state="open"' : '') . '>' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-user-importation-section">' . "\n"; echo '<h3>User/Member Importation (upload file / or direct input)</h3>' . "\n"; echo '<p>Import files can be uploaded in CSV format, or you can copy/paste data into the form field provided. In either case, you must follow the <a href="http://www.s2member.com/kb/advanced-import-tools/" target="_blank" rel="external">examples given here</a>. Please double-check your data before clicking the Import button. Make sure that all data fields are properly encapsulated by double-quotes, and separated by commas. After importing Users/Members, you can inspect your work by going to: <strong>WordPress → Users</strong>.</p>' . "\n"; echo '<p><em><strong>No Email Notification:</strong> This import routine works silently. Users/Members will not be contacted by s2Member—that is, unless you have another plugin installed that conflicts with s2Member\'s ability to perform the Import properly. You should always test one or two accounts before importing a large number of Users all at once. If you want Users/Members to be contacted, you can add them manually, by going to <strong>WordPress → Users → Add New</strong>, and selecting one of the s2Member Roles from the drop-down menu.</em></p>' . "\n"; echo version_compare(PHP_VERSION, "5.3", "<") ? '<p><em><strong>PHP v5.3+ recommended:</strong> In order for s2Member to properly import CSV files containing escape sequences, PHP v5.3 or higher is required. While s2Member may be able to parse import files in most cases, PHP v5.3 provides the best stability.</em></p>' . "\n" : ''; echo '<p class="info"><em><strong>Advanced:</strong> This importer uses an entirely different format. See <a href="http://www.s2member.com/kb/advanced-import-tools/" target="_blank" rel="external">this KB article for details</a>.</em></p>' . "\n"; echo '<p class="warning"><em><strong>Important Warning:</strong> Please do not attempt to import a file that you originally exported with the default s2Member User Export system; it is not compatible. This tool uses an entirely different format; i.e., the Advanced Export Tool format is required here. Importing with the wrong format may result in User database table corruption.</em></p>' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<form method="post" enctype="multipart/form-data" name="ws_plugin__s2member_pro_import_users_form" id="ws-plugin--s2member-pro-import-users-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_import_users" id="ws-plugin--s2member-pro-import-users" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-import-users")) . '" />' . "\n"; echo '<input type="file" name="ws_plugin__s2member_pro_import_users_file" id="ws-plugin--s2member-pro-import-users-file" /> (up to 1000 lines per file) <input type="submit" value="Import Now" style="font-size:120%; font-weight:normal;" /><br /><br />' . "\n"; echo '<textarea name="ws_plugin__s2member_pro_import_users_direct_input" id="ws-plugin--s2member-pro-import-users-direct-input" rows="10" wrap="off" spellcheck="false" style="width:99%;">' . format_to_edit(trim(stripslashes(@$_POST["ws_plugin__s2member_pro_import_users_direct_input"]))) . '</textarea><br />' . "\n"; echo 'One User/Member per line please. See <a href="http://www.s2member.com/kb/advanced-import-tools/" target="_blank" rel="external">this KB article for details</a>.' . "\n"; echo '</form>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; } /* * Simple version. */ if (!$enable_advanced_tools) { if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { echo '<div class="ws-menu-page-group" title="User/Member CSV Importation"' . (isset($_POST["ws_plugin__s2member_pro_import_simple_users"]) ? ' default-state="open"' : '') . '>' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-user-importation-section">' . "\n"; echo '<h3>User/Member Importation (upload file / or direct input)</h3>' . "\n"; echo '<p>Import files can be uploaded in CSV format, or you can copy/paste data into the form field provided. In either case, you must follow the examples given below. Please double-check your data before clicking the Import button. Make sure that all data fields are properly encapsulated by double-quotes, and separated by commas. You\'ll also need to make sure that all of your data fields are in the proper order, based on the examples given below. After importing Users/Members, you can inspect your work by going to: <strong>WordPress → Users</strong>.</p>' . "\n"; echo '<p><em><strong>No Email Notification:</strong> This import routine works silently. Users/Members will not be contacted by s2Member—that is, unless you have another plugin installed that conflicts with s2Member\'s ability to perform the Import properly. You should always test one or two accounts before importing a large number of Users all at once. If you want Users/Members to be contacted, you can add them manually, by going to <strong>WordPress → Users → Add New</strong>, and selecting one of the s2Member Roles from the drop-down menu.</em></p>' . "\n"; echo version_compare(PHP_VERSION, "5.3", "<") ? '<p><em><strong>PHP v5.3+ recommended:</strong> In order for s2Member to properly import CSV files containing escape sequences, PHP v5.3 or higher is required. While s2Member may be able to parse import files in most cases, PHP v5.3 provides the best stability.</em></p>' . "\n" : ''; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<form method="post" enctype="multipart/form-data" name="ws_plugin__s2member_pro_import_users_form" id="ws-plugin--s2member-pro-import-users-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_import_simple_users" id="ws-plugin--s2member-pro-import-users" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-import-users")) . '" />' . "\n"; echo '<input type="file" name="ws_plugin__s2member_pro_import_users_file" id="ws-plugin--s2member-pro-import-users-file" /> (up to 1000 lines per file) <input type="submit" value="Import Now" style="font-size:120%; font-weight:normal;" /><br /><br />' . "\n"; echo '<textarea name="ws_plugin__s2member_pro_import_users_direct_input" id="ws-plugin--s2member-pro-import-users-direct-input" rows="10" wrap="off" spellcheck="false" style="width:99%;">' . format_to_edit(trim(stripslashes(@$_POST["ws_plugin__s2member_pro_import_users_direct_input"]))) . '</textarea><br />' . "\n"; echo 'One User/Member per line please. Here is a quick example:<br />' . "\n"; echo '<code>"ID","Username","First Name","Last Name","Display Name","Email"</code>' . "\n"; echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo 'If you fill the ID field, the Import routine will update an account matching the ID you specify (so long as the account ID does not belong to an Administrator, this is for security). When importing new Users/Members, you can leave the ID field empty Don\'t remove it, just leave it empty(i.e., <code>""</code>).<br /><br />' . "\n"; echo 'Example: <code>"","Username","First Name","Last Name","Display Name","Email"</code><br /><br />' . "\n"; echo 'Additional extended information can also be included; even Custom Registration/Profile Fields:<br />' . "\n"; echo '<code>"ID","Username","First Name","Last Name","Display Name","Email","Website","Level[0-9]+ or Role ID","Custom Capabilities","Registration Date (mm/dd/yyyy)","First Payment Date (mm/dd/yyyy)","Last Payment Date (mm/dd/yyyy)","Auto-EOT Date (mm/dd/yyyy)","Custom Value (starts w/domain)","Paid Subscr. ID","Paid Subscr. Gateway","Custom Registration/Profile Field Value","another Custom Registration/Profile Field Value", ... and so on—for as many Custom Registration/Profile Fields that you\'d like import.</code><br /><br />' . "\n"; echo 'Here is a full example with all fields filled in, including extended details; and two Custom Field values:<br />' . "\n"; echo '<code>"","johnsmith22","John","Smith","John Smith","*****@*****.**","http://www.example.com/","2","music,videos","12/31/2000","01/10/2001","12/31/2020","12/31/2021","www.example.com|123.357.125.654","I-2342934SSER243","paypal","fishing,biking,computers","xx-large"</code><br /><br />' . "\n"; echo 'Here is a full example with some fields left empty:<br />' . "\n"; echo '<code>"","johnsmith22","John","Smith","John Smith","*****@*****.**","","s2member_level2","","","","","12/31/2021"</code>' . "\n"; echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo '<em>* If you supply a Paid Subscr. Gateway, you must use one of these values: <code>paypal</code>, <code>alipay</code>, <code>authnet</code>, <code>ccbill</code>, <code>clickbank</code>, <code>google</code>.</em><br /><br />' . "\n"; echo '<em>* If you supply Custom Fields, your Custom Field values should be listed in alphabetical order, based on your Custom Field IDs (i.e., values listed in the order of your alphabetized Custom Field IDs). This is based on the Custom Field IDs you\'ve configured with s2Member. See: <strong>s2Member → General Options → Registration/Profile Fields</strong>. In the example above, you will see two Custom Field values (<code>... "fishing,biking,computers","xx-large"</code>). The first value comes first, because it maps to the Custom Field ID <code>interests</code>, and the second one comes last, because it maps to the Custom Field ID <code>t_shirt_size</code> (i.e., alphabetical order—based on the underlying Custom Field IDs that you\'re mapping this data to).</em><br /><br />' . "\n"; echo '<em>* If you have a Custom Field that contains an array of multiple values, you can import the array using PHP\'s <a href="http://php.net/manual/en/function.serialize.php" target="_blank" rel="external">serialize()</a> function. This allows you to convert the array into a string representation. s2Member will automatically unserialize the value during importation. If you have any trouble, please perform an export first. s2Member\'s export files are already formatted for easy re-importation. In other words, you can use them as a guideline for building your own import files.</em><br /><br />' . "\n"; echo '<em>* If you supply "First Payment Date", you have two options available. You can either supply a simple date in this format (mm/dd/yyyy), or you can import an array of First Payment Dates, in the form of Unix timestamps. s2Member has the ability to record and monitor First Payment Dates at each specific Membership Level. The array it expects, consists of the following: <code>array("level" => [timestamp of first payment date regardless of level], "level1" => [timestamp of first payment date at level #1], "level2" => [timestamp], "level3" => [timestamp], "level4" => [timestamp])</code>. Of course, if you decide to import an array with some of these timestamps, you will need to use PHP\'s <a href="http://php.net/manual/en/function.serialize.php" target="_blank" rel="external">serialize()</a> function to convert the array into a string representation. If you have any trouble, please perform an export first. s2Member\'s export files are already formatted for easy re-importation. In other words, you can use them as a guideline for building your own import files. By default, s2Member exports an array of timestamps.</em>' . "\n"; echo '</form>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; } else { echo '<div class="ws-menu-page-group" title="User/Member CSV Importation"' . (isset($_POST["ws_plugin__s2member_pro_import_simple_users"]) ? ' default-state="open"' : '') . '>' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-user-importation-section">' . "\n"; echo '<h3>User/Member Importation (upload file / or direct input)</h3>' . "\n"; echo '<p>Import files can be uploaded in CSV format, or you can copy/paste data into the form field provided. In either case, you must follow the examples given below. Please double-check your data before clicking the Import button. Make sure that all data fields are properly encapsulated by double-quotes, and separated by commas. You\'ll also need to make sure that all of your data fields are in the proper order, based on the examples given below. After importing Users/Members, you can inspect your work by going to: <strong>WordPress → Users</strong>.</p>' . "\n"; echo '<p><em><strong>No Email Notification:</strong> This import routine works silently. Users/Members will not be contacted by s2Member—that is, unless you have another plugin installed that conflicts with s2Member\'s ability to perform the Import properly. You should always test one or two accounts before importing a large number of Users all at once. If you want Users/Members to be contacted, you can add them manually, by going to <strong>WordPress → Users → Add New</strong>, and selecting one of the s2Member Roles from the drop-down menu.</em></p>' . "\n"; echo version_compare(PHP_VERSION, "5.3", "<") ? '<p><em><strong>PHP v5.3+ recommended:</strong> In order for s2Member to properly import CSV files containing escape sequences, PHP v5.3 or higher is required. While s2Member may be able to parse import files in most cases, PHP v5.3 provides the best stability.</em></p>' . "\n" : ''; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<form method="post" enctype="multipart/form-data" name="ws_plugin__s2member_pro_import_users_form" id="ws-plugin--s2member-pro-import-users-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_import_simple_users" id="ws-plugin--s2member-pro-import-users" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-import-users")) . '" />' . "\n"; echo '<input type="file" name="ws_plugin__s2member_pro_import_users_file" id="ws-plugin--s2member-pro-import-users-file" /> (up to 1000 lines per file) <input type="submit" value="Import Now" style="font-size:120%; font-weight:normal;" /><br /><br />' . "\n"; echo '<textarea name="ws_plugin__s2member_pro_import_users_direct_input" id="ws-plugin--s2member-pro-import-users-direct-input" rows="10" wrap="off" spellcheck="false" style="width:99%;">' . format_to_edit(trim(stripslashes(@$_POST["ws_plugin__s2member_pro_import_users_direct_input"]))) . '</textarea><br />' . "\n"; echo 'One User/Member per line please. Here is a quick example:<br />' . "\n"; echo '<code>"ID","Username","Password","First Name","Last Name","Display Name","Email"</code><br /><br />' . "\n"; echo 'If you fill the ID field, the Import routine will update an account matching the ID you specify (so long as the account ID does not belong to an Administrator, this is for security). When importing new Users/Members, you can leave the ID field empty Don\'t remove it, just leave it empty(i.e., <code>""</code>).<br /><br />' . "\n"; echo 'Example: <code>"","Username","Password","First Name","Last Name","Display Name","Email"</code>' . "\n"; echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo 'Additional extended information can also be included; even Custom Registration/Profile Fields:<br />' . "\n"; echo 'Please see this KB article for more detailed instructions: <a href="http://www.s2member.com/kb/importing-updating-users/" target="_blank" rel="external nofollow x-link">Import (Or Mass Update Users)</a>' . "\n"; echo '</form>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; } } /* * Advanced version. */ if ($enable_advanced_tools) { echo '<div class="ws-menu-page-group" title="Advanced User/Member CSV Exportation">' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-user-exportation-section">' . "\n"; echo '<h3>User/Member Exportation (download CSV export files)</h3>' . "\n"; echo '<p class="info"><em><strong>Advanced:</strong> This exporter uses an entirely different format. See <a href="http://www.s2member.com/kb/advanced-import-tools/" target="_blank" rel="external">this KB article for details</a>.</em></p>' . "\n"; echo '<p class="warning"><em><strong>Important Warning:</strong> The export you receive from this Advanced Tool is not compatible with the default s2Member User Import system. This tool uses an entirely different format; i.e., files exported here are in the Advanced Import Tool format. If you plan to reimport and/or mass update existing Users/Members based on these Advanced files, you must use the Advanced Import Tool to do so. Attempting to import an Advanced Export file with the Default Import Tool may result in User database table corruption.</em></p>' . "\n"; echo '<form method="post" name="ws_plugin__s2member_pro_export_users_form" id="ws-plugin--s2member-pro-export-users-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_export_users" id="ws-plugin--s2member-pro-export-users" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-export-users")) . '" />' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-format">' . "\n"; echo 'CSV File Preference:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<select name="ws_plugin__s2member_pro_export_users_format" id="ws-plugin--s2member-pro-export-users-format">' . "\n"; echo '<option value="" selected="selected">Default (CSV, perfectly formatted for easy re-importation)</option>' . "\n"; echo '<option value="readable">Easy-Read (CSV w/ improved readability; cannot be re-imported)</option>' . "\n"; echo '</select><br />' . "\n"; echo '<em>Open CSV files with Notepad, TextEdit (Mac), Numbers (Mac), MS Excel, or <a href="http://s2member.com/r/openoffice/" target="_blank" rel="external">OpenOffice</a> (recommended).</em>'; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-utf8-bom">' . "\n"; echo 'Add UTF-8 BOM (Byte Order Marker)?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<select name="ws_plugin__s2member_pro_export_users_utf8_bom" id="ws-plugin--s2member-pro-export-users-utf8-bom">' . "\n"; echo '<option value="0" selected="selected">Default (no, I will choose UTF-8 encoding when I open the file)</option>' . "\n"; echo '<option value="1">Yes (add a UTF-8 Byte Order Marker so that UTF-8 encoding is always in use for this file)</option>' . "\n"; echo '</select><br />' . "\n"; echo '<em>If <code>Yes</code>—please open CSV files with Numbers (Mac) or <a href="http://s2member.com/r/openoffice/" target="_blank" rel="external">OpenOffice</a> (recommended).</em>'; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-start">' . "\n"; echo 'CSV File Exportation:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo 'You have a total of ' . number_format(c_ws_plugin__s2member_utils_users::users_in_database()) . ' User/Member rows in the database' . (is_multisite() ? ' for this site' : '') . '.<br />' . "\n"; if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { echo 'You can export up to 1000 database rows in each file; starting from a particular row that you specify.<br />' . "\n"; echo 'Export, starting with row#: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_start" id="ws-plugin--s2member-pro-export-users-start" style="width:100px;" value="1" /> <input type="submit" value="Export Now" style="font-size:120%; font-weight:normal;" />' . "\n"; } else { echo 'Export, starting with row#: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_start" id="ws-plugin--s2member-pro-export-users-start" style="width:100px;" value="1" /> limit to: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_limit" id="ws-plugin--s2member-pro-export-users-limit" style="width:100px;" value="1000" /> rows <input type="submit" value="Export Now" style="font-size:120%; font-weight:normal;" />' . "\n"; } echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo '<em>Please note. Export files do not contain Passwords. Passwords are stored by WordPress with one-way encryption. In other words, it\'s not possible for s2Member to include them in the export file. However, this does not create a problem, because when/if you re-import existing Users/Members with the Password field empty, s2Member will simply keep the existing Password that is already on file. For further information, please read all Import instructions, regarding Passwords.</em>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</form>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; } /* * Simple version. */ if (!$enable_advanced_tools) { echo '<div class="ws-menu-page-group" title="User/Member CSV Exportation">' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-user-exportation-section">' . "\n"; echo '<h3>User/Member Exportation (download CSV export files)</h3>' . "\n"; echo '<form method="post" name="ws_plugin__s2member_pro_export_users_form" id="ws-plugin--s2member-pro-export-users-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_export_simple_users" id="ws-plugin--s2member-pro-export-users" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-export-users")) . '" />' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-format">' . "\n"; echo 'CSV File Preference:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<select name="ws_plugin__s2member_pro_export_users_format" id="ws-plugin--s2member-pro-export-users-format">' . "\n"; echo '<option value="" selected="selected">Default (CSV, perfectly formatted for easy re-importation)</option>' . "\n"; echo '<option value="readable">Easy-Read (CSV w/ improved readability; cannot be re-imported)</option>' . "\n"; echo '</select><br />' . "\n"; echo '<em>Open CSV files with Notepad, TextEdit (Mac), Numbers (Mac), MS Excel, or <a href="http://s2member.com/r/openoffice/" target="_blank" rel="external">OpenOffice</a> (recommended).</em>'; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-utf8-bom">' . "\n"; echo 'Add UTF-8 BOM (Byte Order Marker)?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<select name="ws_plugin__s2member_pro_export_users_utf8_bom" id="ws-plugin--s2member-pro-export-users-utf8-bom">' . "\n"; echo '<option value="0" selected="selected">Default (no, I will choose UTF-8 encoding when I open the file)</option>' . "\n"; echo '<option value="1">Yes (add a UTF-8 Byte Order Marker so that UTF-8 encoding is always in use for this file)</option>' . "\n"; echo '</select><br />' . "\n"; echo '<em>If <code>Yes</code>—please open CSV files with Numbers (Mac) or <a href="http://s2member.com/r/openoffice/" target="_blank" rel="external">OpenOffice</a> (recommended).</em>'; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<th>' . "\n"; echo '<label for="ws-plugin--s2member-pro-export-users-start">' . "\n"; echo 'CSV File Exportation:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo 'You have a total of ' . number_format(c_ws_plugin__s2member_utils_users::users_in_database()) . ' User/Member rows in the database' . (is_multisite() ? ' for this site' : '') . '.<br />' . "\n"; if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) { echo 'You can export up to 1000 database rows in each file; starting from a particular row that you specify.<br />' . "\n"; echo 'Export, starting with row#: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_start" id="ws-plugin--s2member-pro-export-users-start" style="width:100px;" value="1" /> <input type="submit" value="Export Now" style="font-size:120%; font-weight:normal;" />' . "\n"; } else { echo 'Export, starting with row#: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_start" id="ws-plugin--s2member-pro-export-users-start" style="width:100px;" value="1" /> limit to: <input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_limit" id="ws-plugin--s2member-pro-export-users-limit" style="width:100px;" value="1000" /> rows <input type="submit" value="Export Now" style="font-size:120%; font-weight:normal;" />' . "\n"; } echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo '<em>Please note. Export files do not contain Passwords. Passwords are stored by WordPress with one-way encryption. In other words, it\'s not possible for s2Member to include them in the export file. However, this does not create a problem, because when/if you re-import existing Users/Members with the Password field empty, s2Member will simply keep the existing Password that is already on file. For further information, please read all Import instructions, regarding Passwords.</em>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</form>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; } /* * There is no variation on this one; always the same. */ echo '<div class="ws-menu-page-group" title="s2Member Options (Import/Export)"' . (isset($_POST["ws_plugin__s2member_pro_import_ops"]) ? ' default-state="open"' : '') . '>' . "\n"; echo '<div class="ws-menu-page-section ws-plugin--s2member-pro-ops-importation-exportation-section">' . "\n"; echo '<h3 style="margin-bottom:5px;">s2Member Options Export <small>(<a href="' . esc_attr(home_url("/?ws_plugin__s2member_pro_export_ops=" . urlencode(wp_create_nonce("ws-plugin--s2member-pro-export-ops")))) . '">download serialized export file</a>)</small></h3>' . "\n"; echo '<p style="margin-top:5px;">This allows you to export your current s2Member configuration, and then import it into another instance of WordPress.' . "\n"; echo '<div class="ws-menu-page-hr"></div>' . "\n"; echo '<h3 style="margin-bottom:5px;">s2Member Options Import <small>(upload your serialized export file)</small></h3>' . "\n"; echo '<p style="margin-top:5px;">This allows you to import your s2Member configuration export file, from another instance of WordPress.' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<form method="post" enctype="multipart/form-data" name="ws_plugin__s2member_pro_import_ops_form" id="ws-plugin--s2member-pro-import-ops-form" autocomplete="off">' . "\n"; echo '<input type="hidden" name="ws_plugin__s2member_pro_import_ops" id="ws-plugin--s2member-pro-import-ops" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-pro-import-ops")) . '" />' . "\n"; echo '<input type="file" name="ws_plugin__s2member_pro_import_ops_file" id="ws-plugin--s2member-pro-import-ops-file" /> <input type="submit" value="Import Now" style="font-size:120%; font-weight:normal;" />' . "\n"; echo '</form>' . "\n"; echo '</td>' . "\n"; echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\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"; }
/** * Validates different kinds of form submissions. * * Free Registration Forms do NOT require API Credentials. * * @package s2Member\PayPal * @since 1.5 * * @param string $form The type of Pro-Form being submitted. * @param array $s An array of data submitted through the Pro-Form. * @return null|array Null if there are no errors, else a response array. */ public static function paypal_form_submission_validation_errors($form = FALSE, $s = FALSE) { if ($form === "registration" || !($response = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors())) { if ($form === "cancellation") { if (!is_user_logged_in()) { $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to cancel your account.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true); } else { if ($s["attr"]["captcha"] && (empty($s["recaptcha_challenge_field"]) || empty($s["recaptcha_response_field"]) || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"]))) { $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) { // NOT for Administrators. $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true); } } } } else { if ($form === "update") { if (!is_user_logged_in()) { $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to update your billing information.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true); } else { if (is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) { $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true); } else { if (empty($s["card_type"]) || !is_string($s["card_type"])) { $response = array("response" => _x('Missing Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) || !is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"])) { $response = array("response" => _x('Invalid Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_number"]) || !is_string($s["card_number"]))) { $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_expiration"]) || !is_string($s["card_expiration"]))) { $response = array("response" => _x('Missing Card Expiration Date (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $s["card_expiration"])) { $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_verification"]) || !is_string($s["card_verification"]))) { $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Maestro", "Solo")) && (empty($s["card_start_date_issue_number"]) || !is_string($s["card_start_date_issue_number"]))) { $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["street"]) || !is_string($s["street"]))) { $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["city"]) || !is_string($s["city"]))) { $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["state"]) || !is_string($s["state"]))) { $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["country"]) || !is_string($s["country"]))) { $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["zip"]) || !is_string($s["zip"]))) { $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($s["attr"]["captcha"] && (empty($s["recaptcha_challenge_field"]) || empty($s["recaptcha_response_field"]) || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"]))) { $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true); } } } } } } } } } } } } } } } } else { if ($form === "registration") { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && (empty($s["first_name"]) || !is_string($s["first_name"]))) { $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && (empty($s["last_name"]) || !is_string($s["last_name"]))) { $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["email"]) || !is_string($s["email"])) { $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_email($s["email"])) { $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (email_exists($s["email"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog(@$s["username"], $s["email"]))) { $response = array("response" => _x('That Email Address is already in use. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["username"]) || !is_string($s["username"]) || empty($s["_o_username"]) || !is_string($s["_o_username"])) { $response = array("response" => _x('Missing or invalid Username. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!validate_username($s["username"]) || !validate_username($s["_o_username"])) { $response = array("response" => _x('Invalid Username. Please try again. Use ONLY lowercase alphanumerics.', "s2member-front", "s2member"), "error" => true); } else { if (username_exists($s["username"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]))) { $response = array("response" => _x('That Username is already in use. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (is_multisite() && !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]) && ($_response = wpmu_validate_user_signup($s["username"], $s["email"])) && is_wp_error($_errors = $_response["errors"]) && $_errors->get_error_message()) { $response = array("response" => $_errors->get_error_message(), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && (empty($s["password1"]) || !is_string($s["password1"]))) { $response = array("response" => _x('Missing Password. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && strlen($s["password1"]) < 6) { $response = array("response" => _x('Invalid Password. Must be at least 6 characters. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && strlen($s["password1"]) > 20) { $response = array("response" => _x('Invalid Password. Max length is 20 characters. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && (empty($s["password2"]) || $s["password2"] !== $s["password1"])) { $response = array("response" => _x('Password fields do NOT match. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($custom_field_validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(isset($s["custom_fields"]) ? $s["custom_fields"] : array(), c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($s["attr"]["level"], "registration", TRUE))) { $response = array("response" => array_shift($custom_field_validation_errors), "error" => true); } else { if ($s["attr"]["captcha"] && (empty($s["recaptcha_challenge_field"]) || empty($s["recaptcha_response_field"]) || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"]))) { $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true); } } } } } } } } } } } } } } } } else { if ($form === "sp-checkout") { if (empty($s["first_name"]) || !is_string($s["first_name"])) { $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["last_name"]) || !is_string($s["last_name"])) { $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["email"]) || !is_string($s["email"])) { $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_email($s["email"])) { $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["card_type"]) || !is_string($s["card_type"])) { $response = array("response" => _x('Missing Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal", "Free"))) { $response = array("response" => _x('Invalid Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) && (!is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"]))) { $response = array("response" => _x('Invalid Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_number"]) || !is_string($s["card_number"]))) { $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_expiration"]) || !is_string($s["card_expiration"]))) { $response = array("response" => _x('Missing Card Expiration Date (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $s["card_expiration"])) { $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_verification"]) || !is_string($s["card_verification"]))) { $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Maestro", "Solo")) && (empty($s["card_start_date_issue_number"]) || !is_string($s["card_start_date_issue_number"]))) { $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["street"]) || !is_string($s["street"]))) { $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["city"]) || !is_string($s["city"]))) { $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["state"]) || !is_string($s["state"]))) { $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["country"]) || !is_string($s["country"]))) { $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["zip"]) || !is_string($s["zip"]))) { $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($s["attr"]["captcha"] && (empty($s["recaptcha_challenge_field"]) || empty($s["recaptcha_response_field"]) || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"]))) { $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true); } } } } } } } } } } } } } } } } } } } else { if ($form === "checkout") { if ($s["attr"]["modify"] && !is_user_logged_in()) { $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to modify your billing plan.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true); } else { if ($s["attr"]["level"] === "*" && !is_user_logged_in()) { $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> before making this purchase.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true); } else { if (is_user_logged_in() && is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) { // NOT for Administrators. $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true); } else { if (empty($s["first_name"]) || !is_string($s["first_name"])) { $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (empty($s["last_name"]) || !is_string($s["last_name"])) { $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && (empty($s["email"]) || !is_string($s["email"]))) { $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && !is_email($s["email"])) { $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && email_exists($s["email"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog(@$s["username"], $s["email"]))) { $response = array("response" => _x('That Email Address is already in use. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && (empty($s["username"]) || !is_string($s["username"]) || empty($s["_o_username"]) || !is_string($s["_o_username"]))) { $response = array("response" => _x('Missing or invalid Username. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && (!validate_username($s["username"]) || !validate_username($s["_o_username"]))) { $response = array("response" => _x('Invalid Username. Please try again. Use ONLY lowercase alphanumerics.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && username_exists($s["username"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]))) { $response = array("response" => _x('That Username is already in use. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && is_multisite() && !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]) && ($_response = wpmu_validate_user_signup($s["username"], $s["email"])) && is_wp_error($_errors = $_response["errors"]) && $_errors->get_error_message()) { $response = array("response" => $_errors->get_error_message(), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !is_user_logged_in() && (empty($s["password1"]) || !is_string($s["password1"]))) { $response = array("response" => _x('Missing Password. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !is_user_logged_in() && strlen($s["password1"]) < 6) { $response = array("response" => _x('Invalid Password. Must be at least 6 characters. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !is_user_logged_in() && strlen($s["password1"]) > 20) { $response = array("response" => _x('Invalid Password. Max length is 20 characters. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && !is_user_logged_in() && (empty($s["password2"]) || $s["password2"] !== $s["password1"])) { $response = array("response" => _x('Password fields do NOT match. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!is_user_logged_in() && ($custom_field_validation_errors = c_ws_plugin__s2member_custom_reg_fields::validation_errors(isset($s["custom_fields"]) ? $s["custom_fields"] : array(), c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($s["attr"]["level"] === "*" ? "auto-detection" : $s["attr"]["level"], "registration", TRUE)))) { $response = array("response" => array_shift($custom_field_validation_errors), "error" => true); } else { if (empty($s["card_type"]) || !is_string($s["card_type"])) { $response = array("response" => _x('Missing Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal", "Free"))) { $response = array("response" => _x('Invalid Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) && (!is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"]))) { $response = array("response" => _x('Invalid Card Type (Billing Method). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_number"]) || !is_string($s["card_number"]))) { $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_expiration"]) || !is_string($s["card_expiration"]))) { $response = array("response" => _x('Missing Card Expiration Date (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $s["card_expiration"])) { $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format (mm/yyyy). Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["card_verification"]) || !is_string($s["card_verification"]))) { $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Maestro", "Solo")) && (empty($s["card_start_date_issue_number"]) || !is_string($s["card_start_date_issue_number"]))) { $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["street"]) || !is_string($s["street"]))) { $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["city"]) || !is_string($s["city"]))) { $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["state"]) || !is_string($s["state"]))) { $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["country"]) || !is_string($s["country"]))) { $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if (in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (empty($s["zip"]) || !is_string($s["zip"]))) { $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true); } else { if ($s["attr"]["captcha"] && (empty($s["recaptcha_challenge_field"]) || empty($s["recaptcha_response_field"]) || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"]))) { $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } else { // Else we are dealing with an unknown form submission type. $response = array("response" => _x('Unknown form submission type. Please contact Support.', "s2member-front", "s2member"), "error" => true); } } } } } } return apply_filters("ws_plugin__s2member_pro_paypal_form_submission_validation_response", empty($response) ? null : $response, $form, $s); }
/** * 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; } } } }