/** * 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. */ 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']['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_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']; $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); if (!empty($coupon['coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $coupon_class = new c_ws_plugin__s2member_pro_coupons(); $coupon_class->update_uses($coupon['coupon_code']); } 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']); } if (!empty($coupon['full_coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $user_coupons = is_array($user_coupons = get_user_option('s2member_coupon_codes', $user_id)) ? $user_coupons : array(); $user_coupons = array_unique(array_merge($user_coupons, (array) $coupon['full_coupon_code'])); update_user_option($user_id, 's2member_coupon_codes', $user_coupons); } $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 = c_ws_plugin__s2member_utils_strings::fill_cvs($rec, $paypal['custom'])) && ($rec = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $rec))) { if (($rec = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $rec)) && ($rec = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_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('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $rec)) && ($rec = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $sbj))) { if (($sbj = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $sbj)) && ($sbj = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_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('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $sbj)) && ($sbj = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $msg))) { if (($msg = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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_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\n" . 'Content-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'])) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_id'])), $url))) { if (($url = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $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($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']) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['payment_notification_urls']) as $url) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_id'])), $url))) { if (($url = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $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']) { $msg = $sbj = '(s2Member / API Notification Email) - Payment'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'currency: %%currency%%' . "\n"; $msg .= 'currency_symbol: %%currency_symbol%%' . "\n"; $msg .= 'amount: %%amount%%' . "\n"; $msg .= 'txn_id: %%txn_id%%' . "\n"; $msg .= 'txn_baid: %%txn_baid%%' . "\n"; $msg .= 'txn_cid: %%txn_cid%%' . "\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 = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $msg))) { if (($msg = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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.'; } if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $code)) && ($code = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $code)) && ($code = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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_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 User removals/deletions. * * @package s2Member\User_Deletions * @since 3.5 * * @attaches-to ``add_action('delete_user');`` * @attaches-to ``add_action('wpmu_delete_user');`` * * @param int|string $user_id Numeric WordPress User ID. */ public static function handle_user_deletions($user_id = 0) { static $processed = array(); // No duplicate processing. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_handle_user_deletions', get_defined_vars()); unset($__refs, $__v); if ($user_id && empty($processed[$user_id]) && ($processed[$user_id] = TRUE)) { $eot_del_type = !empty($GLOBALS['ws_plugin__s2member_eot_del_type']) ? $GLOBALS['ws_plugin__s2member_eot_del_type'] : 'user-removal-deletion'; // Else use default. $custom = get_user_option('s2member_custom', $user_id); $subscr_id = get_user_option('s2member_subscr_id', $user_id); $subscr_baid = get_user_option('s2member_subscr_baid', $user_id); $subscr_cid = get_user_option('s2member_subscr_cid', $user_id); $fields = get_user_option('s2member_custom_fields', $user_id); $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_handle_user_before_deletions', get_defined_vars()); do_action('ws_plugin__s2member_during_collective_eots', $user_id, get_defined_vars(), $eot_del_type, 'removal-deletion'); unset($__refs, $__v); delete_user_option($user_id, 's2member_custom'); delete_user_option($user_id, 's2member_subscr_id'); delete_user_option($user_id, 's2member_subscr_baid'); delete_user_option($user_id, 's2member_subscr_cid'); delete_user_option($user_id, 's2member_subscr_gateway'); delete_user_option($user_id, 's2member_custom_fields'); delete_user_option($user_id, 's2member_registration_ip'); delete_user_option($user_id, 's2member_ipn_signup_vars'); delete_user_option($user_id, 's2member_paid_registration_times'); delete_user_option($user_id, 's2member_access_cap_times'); delete_user_option($user_id, 's2member_sp_references'); delete_user_option($user_id, 's2member_last_status_scan'); delete_user_option($user_id, 's2member_first_payment_txn_id'); delete_user_option($user_id, 's2member_last_payment_time'); delete_user_option($user_id, 's2member_auto_eot_time'); delete_user_option($user_id, 's2member_file_download_access_arc'); delete_user_option($user_id, 's2member_file_download_access_log'); delete_user_option($user_id, 's2member_login_counter'); delete_user_option($user_id, 's2member_notes'); if (is_object($user = new WP_User($user_id)) && $user->ID && $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls'] && is_array($cv = preg_split('/\\|/', $custom))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls']) as $url) { // Handle EOT Notifications on user deletion. if (($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($eot_del_type)), $url)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_id)), $url))) { if (($url = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_baid)), $url)) && ($url = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_cid)), $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); } } } } } } } } } } } if (is_object($user = new WP_User($user_id)) && $user->ID && $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_recipients'] && is_array($cv = preg_split('/\\|/', $custom))) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = '(s2Member / API Notification Email) - EOT/Deletion'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'eot_del_type: %%eot_del_type%%' . "\n"; $msg .= 'subscr_id: %%subscr_id%%' . "\n"; $msg .= 'subscr_baid: %%subscr_baid%%' . "\n"; $msg .= 'subscr_cid: %%subscr_cid%%' . "\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('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($eot_del_type), $msg)) && ($msg = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_id), $msg))) { if (($msg = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_baid), $msg)) && ($msg = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_cid), $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']['eot_del_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_eot_del_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_eot_del_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_handle_user_deletions', get_defined_vars()); unset($__refs, $__v); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_after_handle_user_deletions', get_defined_vars()); unset($__refs, $__v); }
/** * Handles new User/Member notifications. * * @package s2Member\Email_Configs * @since 110707 * * @param string|int $user_id A numeric WordPress User ID. * @param string $user_pass Optional. A plain text version of the User's password. * If omitted, only the administrative notification will be sent. * @param array $notify An array of directives. Must be non-empty, with at least one of these values `user,admin`. * @param string $user_email Optional. This defaults to the user's currently configured email address. * @return bool True if all required parameters are supplied, else false. */ public static function new_user_notification($user_id = FALSE, $user_pass = FALSE, $notify = array("user", "admin"), $user_email = FALSE) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_new_user_notification", get_defined_vars()); unset($__refs, $__v); if ($user_id && ($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && is_array($notify) && !empty($notify)) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); if (in_array("user", $notify) && $user_pass) { $fields = get_user_option("s2member_custom_fields", $user_id); $cv = preg_split("/\\|/", get_user_option("s2member_custom", $user_id)); $role = c_ws_plugin__s2member_user_access::user_access_role($user); $label = c_ws_plugin__s2member_user_access::user_access_label($user); $level = c_ws_plugin__s2member_user_access::user_access_level($user); $ccaps = implode(",", c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $user->user_email = $user_email ? $user_email : $user->user_email; $user_full_name = trim($user->first_name . " " . $user->last_name); $user_ip = $_SERVER["REMOTE_ADDR"]; if ($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_subject"]) { if ($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $sbj)) { if ($sbj = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $sbj)) { if ($sbj = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($role), $sbj)) { if ($sbj = preg_replace("/%%label%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($label), $sbj)) { if ($sbj = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($level), $sbj)) { if ($sbj = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $sbj)) { if ($sbj = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $sbj)) { if ($sbj = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($sbj = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $sbj))) { break; } } } if ($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_message"]) { if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $msg)) { if ($msg = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $msg)) { if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace("/%%label%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($label), $msg)) { if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_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 = 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()); } c_ws_plugin__s2member_email_configs::email_config() . wp_mail($user->user_email, apply_filters("ws_plugin__s2member_welcome_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_welcome_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(); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if (in_array("admin", $notify)) { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]) { $fields = get_user_option("s2member_custom_fields", $user_id); $cv = preg_split("/\\|/", get_user_option("s2member_custom", $user_id)); $role = c_ws_plugin__s2member_user_access::user_access_role($user); $label = c_ws_plugin__s2member_user_access::user_access_label($user); $level = c_ws_plugin__s2member_user_access::user_access_level($user); $ccaps = implode(",", c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $user->user_email = $user_email ? $user_email : $user->user_email; $user_full_name = trim($user->first_name . " " . $user->last_name); $user_ip = $_SERVER["REMOTE_ADDR"]; if ($rec = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]) { if ($rec = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $rec)) { if ($rec = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $rec)) { if ($rec = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($role), $rec)) { if ($rec = preg_replace("/%%label%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($label), $rec)) { if ($rec = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($level), $rec)) { if ($rec = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $rec)) { if ($rec = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name)), $rec)) { if ($rec = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(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_dq(c_ws_plugin__s2member_utils_strings::esc_refs($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $rec)) { if ($rec = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $rec)) { if ($rec = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $rec)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($rec = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $rec))) { break; } } } if ($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_subject"]) { if ($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $sbj)) { if ($sbj = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $sbj)) { if ($sbj = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($role), $sbj)) { if ($sbj = preg_replace("/%%label%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($label), $sbj)) { if ($sbj = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($level), $sbj)) { if ($sbj = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $sbj)) { if ($sbj = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $sbj)) { if ($sbj = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { if (!($sbj = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $sbj))) { break; } } } if ($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_message"]) { if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim(@$cv[$1])', $msg)) { if ($msg = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $msg)) { if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace("/%%label%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($label), $msg)) { if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs($user_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 (($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()) { $rec = c_ws_plugin__s2member_utilities::evl($rec, get_defined_vars()); $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) { wp_mail($recipient, apply_filters("ws_plugin__s2member_admin_new_user_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_admin_new_user_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } return apply_filters("ws_plugin__s2member_new_user_notification", true, get_defined_vars()); } else { return apply_filters("ws_plugin__s2member_new_user_notification", false, get_defined_vars()); } }
/** * Configures all new Users. * * The Hook `user_register` is also fired by calling: * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``. * * This function also receives hand-offs from s2Member's handlers for these two Hooks: * `wpmu_activate_user` and `wpmu_activate_blog`. * * @package s2Member\Registrations * @since 3.5 * * @attaches-to ``add_action("user_register");`` * * @param int|str $user_id A numeric WordPress User ID. * @param str $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources. * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member. * @return null No return value. Returns `null` in possible every scenario. * * @todo Impossible to delete cookies when fired inside: `/wp-activate.php`? */ public static function configure_user_registration($user_id = FALSE, $password = FALSE, $meta = FALSE) { global $wpdb; global $pagenow; // We need this to detect the current administration page. global $current_site, $current_blog; // Adds support for Multisite Networking. static $email_config, $processed; // Static vars prevent duplicate processing. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_configure_user_registration", get_defined_vars()); unset($__refs, $__v); // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`. if (!isset($email_config) && ($email_config = true)) { // Anytime this routine is fired; we configure email. c_ws_plugin__s2member_email_configs::email_config(); } // Configures `From:` email header. $_p = isset($_POST) ? $_POST : null; $rvs = isset($GLOBALS["ws_plugin__s2member_registration_vars"]) ? $GLOBALS["ws_plugin__s2member_registration_vars"] : null; if (!$processed) { if (is_array($_p) || is_array($meta) || is_array($rvs)) { if (!(is_multisite() && is_blog_admin() && $pagenow === "user-new.php" && isset($_p["noconfirmation"]) && is_super_admin() && !is_array($meta))) { if (!(preg_match("/\\/wp-activate\\.php/", $_SERVER["REQUEST_URI"]) && !is_array($meta))) { if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) { if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user") && !is_array($rvs))) { if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = true)) { settype($_p, "array") . settype($meta, "array") . settype($rvs, "array"); $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p)); $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta)); $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs); foreach ($_p as $_key => $_value) { // Scan ``$_p`` vars; adding `custom_reg_field` keys. if (preg_match("/^ws_plugin__s2member_user_new_/", $_key)) { // Look for keys. if ($_key = str_replace("_user_new_", "_custom_reg_field_", $_key)) { $_p[$_key] = $_value; } } } // Add each of these key conversions. unset($_key, $_value); if (!is_admin() && (isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_custom"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_notes"]))) { exit(_x("s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!", "s2member-front", "s2member")); } $_pmr = array_merge($_p, $meta, $rvs); // Merge all of these arrays together now, in this specific order. unset($_p, $meta, $rvs); // These variables can all be unset now; we have them all in the ``$_pmr`` array. $custom_reg_display_name = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_display_name"]; // Can be configured by the site owner. if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin — via `/user-new.php`. */ $processed = "yes"; // Mark this as yes. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); @(list($level, $ccaps, $eotper) = preg_split("/\\:/", $item_number, 3)); $role = "s2member_level" . $level; // Membership Level. $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"]; $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip; // Else use environment variable. $cv = preg_split("/\\|/", $custom); if (!($auto_eot_time = "") && $eotper) { // If a specific EOT Period is included. $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $eotper); } $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"]; $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false; $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in; if (!($fname = $user->first_name)) { if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"]; } } if (!$fname) { // Also try BuddyPress. if (!empty($_pmr["field_1"])) { // BuddyPress? $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"])); } } if (!($lname = $user->last_name)) { if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"]; } } if (!$lname) { // Also try BuddyPress. if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) { $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"])); } } if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) { $fname = trim($login); $lname = ""; } // Username and empty Last Name. $name = trim($fname . " " . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"]; } } if (!$pass) { // Also try BuddyPress Password. if (!empty($_pmr["signup_password"])) { // BuddyPress? $pass = (string) $_pmr["signup_password"]; } } if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } update_user_option($user_id, "s2member_registration_ip", $ip); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_notes", $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } // No Main Site Role. if (!get_user_meta($user_id, "s2member_originating_blog", true)) { // Recorded yet? update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) { foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) { $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); $field_id_class = preg_replace("/_/", "-", $field_var); if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, "s2member_custom_fields", $fields); } if ($level > 0) { $pr_times = get_user_option("s2member_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "s2member_paid_registration_times", $pr_times); // Update now. } if (($transient = "s2m_" . md5("s2member_transient_ipn_signup_vars_" . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) { update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars); // For future reference. delete_transient($transient); // This can be deleted now. } if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment["subscr_gateway"])) { $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_payment["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_payment), $proxy), array("timeout" => 20)); delete_transient($transient); // This can be deleted now. } if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_eot_" . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot["subscr_gateway"])) { $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_eot["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_eot), $proxy), array("timeout" => 20)); delete_transient($transient); // This can be deleted now. } if (!headers_sent()) { // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies. @setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars()); do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars()); unset($__refs, $__v); } else { if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user"))) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */ $processed = "yes"; // Mark this as yes. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); $role = ""; // Initialize ``$role`` to an empty string here, before processing. $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role; $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role; $role = !$role && $current_role ? $current_role : $role; // Use existing Role? $role = !$role ? get_option("default_role") : $role; // Otherwise default. $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]; $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level; $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level; $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level; $level = !$level ? "0" : $level; $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]; $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"]; $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip; // Else use environment variable. $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]; $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]; $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]; $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]); $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : ""; $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"]; $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false; $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in; if (!($fname = $user->first_name)) { if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"]; } } if (!$fname) { // Also try BuddyPress. if (!empty($_pmr["field_1"])) { // BuddyPress? $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"])); } } if (!($lname = $user->last_name)) { if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"]; } } if (!$lname) { // Also try BuddyPress. if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) { $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"])); } } if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) { $fname = trim($login); $lname = ""; } // Username and empty Last Name. $name = trim($fname . " " . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"]; } } if (!$pass) { // Also try BuddyPress Password. if (!empty($_pmr["signup_password"])) { // BuddyPress? $pass = (string) $_pmr["signup_password"]; } } if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } update_user_option($user_id, "s2member_registration_ip", $ip); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_notes", $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } if (!get_user_meta($user_id, "s2member_originating_blog", true)) { update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) { foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) { $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); $field_id_class = preg_replace("/_/", "-", $field_var); if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, "s2member_custom_fields", $fields); } if ($level > 0) { $pr_times = get_user_option("s2member_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "s2member_paid_registration_times", $pr_times); // Update now. } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars()); do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars()); unset($__refs, $__v); } else { if (is_blog_admin() && $pagenow === "user-new.php" || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) { // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`. $processed = "yes"; // Mark this as yes, to indicate that a routine was processed. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); $role = ""; // Initialize $role to an empty string here, before processing. $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role; $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role; $role = !$role && $current_role ? $current_role : $role; // Use existing Role? $role = !$role ? get_option("default_role") : $role; // Otherwise default. $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]; $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level; $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level; $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level; $level = !$level ? "0" : $level; $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]; $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"]; $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]; $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]; $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]; $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]); $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : ""; $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"]; $opt_in = !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false; if (!($fname = $user->first_name)) { // `Users -› Add New`. if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"]; } } if (!($lname = $user->last_name)) { // `Users -› Add New`. if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"]; } } if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) { $fname = trim($login); $lname = ""; } // Username and empty Last Name. $name = trim($fname . " " . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"]; } } if (!$pass) { // Also try the `Users -› Add New` form. if (!empty($_pmr["pass1"])) { // Field in `/user-new.php`. $pass = (string) $_pmr["pass1"]; } } if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } update_user_option($user_id, "s2member_registration_ip", $ip); update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway); update_user_option($user_id, "s2member_subscr_id", $subscr_id); update_user_option($user_id, "s2member_custom", $custom); update_user_option($user_id, "s2member_notes", $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } // No Main Site Role. if (!get_user_meta($user_id, "s2member_originating_blog", true)) { // Recorded yet? update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_s2member_ccap_" . $ccap); } } } if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) { foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) { $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); $field_id_class = preg_replace("/_/", "-", $field_var); if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, "s2member_custom_fields", $fields); } if ($level > 0) { $pr_times = get_user_option("s2member_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "s2member_paid_registration_times", $pr_times); // Update now. } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars()); unset($__refs, $__v); } } } if ($processed === "yes") { if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) { foreach (preg_split("/[\r\n\t]+/", $urls) as $url) { // Notify each of the URLs. if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) { if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) { if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) { if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) { if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) { if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) { if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } } unset($urls, $url, $var, $val); // Housekeeping. if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = "(s2Member / API Notification Email) - Registration"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "role: %%role%%\n"; $msg .= "level: %%level%%\n"; $msg .= "ccaps: %%ccaps%%\n"; $msg .= "auto_eot_time: %%auto_eot_time%%\n"; $msg .= "user_first_name: %%user_first_name%%\n"; $msg .= "user_last_name: %%user_last_name%%\n"; $msg .= "user_full_name: %%user_full_name%%\n"; $msg .= "user_email: %%user_email%%\n"; $msg .= "user_login: %%user_login%%\n"; $msg .= "user_pass: %%user_pass%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "user_id: %%user_id%%\n"; foreach ($fields as $var => $val) { $msg .= $var . ": %%" . $var . "%%\n"; } $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) { if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($role), $msg)) { if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($level), $msg)) { if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ccaps), $msg)) { if ($msg = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($auto_eot_time), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($fname), $msg)) { if ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($lname), $msg)) { if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($name), $msg)) { if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($email), $msg)) { if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($login), $msg)) { if ($msg = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ip), $msg)) { if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_registration_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_registration_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } } } } } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on); // Housekeeping. } if ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"]) { if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) { if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) { if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) { if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) { if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) { if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) { if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } if ($url = trim($url)) { // Preserve remaining Replacements; because the parent routine may perform replacements too. $GLOBALS["ws_plugin__s2member_registration_return_url"] = $url; } } } } } } } } } } } } } } } unset($url, $var, $val); // Housekeeping. c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, true, $user_id); /* Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques. @todo It may also be impossible to delete cookies when fired inside: `/wp-activate.php`. */ if (!headers_sent()) { @setcookie("s2member_subscr_gateway", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_gateway", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("s2member_subscr_id", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_id", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("s2member_custom", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_custom", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("s2member_item_number", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_item_number", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); } /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file. Logging now supports Multisite Networking as well. */ $reg_vars = get_defined_vars(); // All defined vars. // No need to include these in the logs. Unset before log entry. unset($reg_vars["wpdb"], $reg_vars["current_site"], $reg_vars["current_blog"]); $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "reg-handler-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "reg-handler.log"; if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($reg_vars, true)) . "\n\n", FILE_APPEND); } } } unset($logt, $logv, $logm, $log4, $_log4, $log2, $logs_dir, $reg_vars); // Housekeeping. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_configure_user_registration", get_defined_vars()); unset($__refs, $__v); } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_after_configure_user_registration", get_defined_vars()); unset($__refs, $__v); return; }
/** * 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()); } }
/** * 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 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()); } }
/** * Handles PayPal® IPN processing. * * These same routines also handle s2Member Pro/PayPal® Pro operations; * giving you the ability *( as needed )* to Hook into these routines using * WordPress® Hooks/Filters; as seen in the source code below. * * Please do NOT modify the source code directly. * Instead, use WordPress® Hooks/Filters. * * For example, if you'd like to add your own custom conditionals, use: * ``add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");`` * * @package s2Member\PayPal * @since 3.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling IPN procesing. */ public static function paypal_notify() { global $current_site, $current_blog; /* For Multisite support. */ /**/ do_action("ws_plugin__s2member_before_paypal_notify", get_defined_vars()); /**/ if (!empty($_GET["s2member_paypal_notify"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty($_GET["s2member_paypal_proxy"]))) { @ignore_user_abort(true); /* Important. Continue processing even if/when the connection is broken by the sending party. */ /**/ include_once ABSPATH . "wp-admin/includes/admin.php"; /* Get administrative functions. Needed for `wp_delete_user()`. */ /**/ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); /* Filters on? */ c_ws_plugin__s2member_email_configs::email_config_release(); /* Release s2Member Filters. */ /**/ if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars()) && ($_paypal = $paypal) && ($_paypal_s = serialize($_paypal))) { $paypal["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $paypal["s2member_log"][] = "s2Member POST vars verified " . (!empty($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®."); /**/ $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)\$/i"; /**/ $paypal["subscr_gateway"] = !empty($_GET["s2member_paypal_proxy"]) ? esc_html(trim(stripslashes($_GET["s2member_paypal_proxy"]))) : "paypal"; /**/ if (empty($paypal["custom"]) && !empty($paypal["recurring_payment_id"])) { /* Lookup on Recurring Profiles? */ $paypal["custom"] = c_ws_plugin__s2member_utils_users::get_user_custom_with($paypal["recurring_payment_id"]); } /**/ if (!empty($paypal["custom"]) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"])) { $paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated."; /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); if (!apply_filters("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars())) { unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_virtual_terminal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_express_checkout::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_cart::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_send_money::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_web_accept_sp::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { /* Ignoring this IPN request. The txn_type/status does NOT require any action. */ $paypal["s2member_log"][] = "Ignoring this IPN request. The `txn_type/status` does NOT require any action on the part of s2Member."; } } } } } } } } } } } } } } } else { /* Else a custom conditional has been applied by Filters. */ unset($__refs, $__v); } /* Unset defined __refs, __v. */ } else { if (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_cancel\$/i", $paypal["txn_type"])) { $paypal["s2member_log"][] = "Transaction type ( `recurring_payment_profile_cancel` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible."; $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here."; } else { if (!empty($paypal["txn_type"]) && preg_match("/^recurring_/i", $paypal["txn_type"])) { /* Otherwise, is this a ^recurring_ txn_type? */ $paypal["s2member_log"][] = "Transaction type ( `^recurring_?` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible."; } else { /* Else, use the default ``$_SERVER["HTTP_HOST"]`` error. */ $paypal["s2member_log"][] = "Unable to verify `\$_SERVER[\"HTTP_HOST\"]`. Please check the `custom` value in your Button Code. It MUST start with your domain name."; } } } } else { $paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility."; $paypal["s2member_log"][] = "If you're absolutely SURE that your configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect/communicate with your Payment Gateway over an HTTPS connection."; $paypal["s2member_log"][] = "s2Member uses the `WP_Http` class for remote connections; which will try to use `cURL` first, and then fall back on the `FOPEN` method when `cURL` is not available. On a Windows® server, you may have to disable your `cURL` extension; and instead, set `allow_url_fopen = yes` in your php.ini file. The `cURL` extension (usually) does NOT support SSL connections on a Windows® server."; $paypal["s2member_log"][] = "Please see this thread: `http://www.primothemes.com/forums/viewtopic.php?f=36&t=2636` for details regarding the ideal server configuration for s2Member."; $paypal["s2member_log"][] = var_export($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */ } /**/ if ($email_configs_were_on) { /* Back on? */ c_ws_plugin__s2member_email_configs::email_config(); } /* Add IPN proxy ( when available ) to the ``$paypal`` array. */ if (!empty($_GET["s2member_paypal_proxy"])) { $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"]; } /* Add IPN proxy use vars ( when available ) to the ``$paypal`` array. */ if (!empty($_GET["s2member_paypal_proxy_use"])) { $paypal["s2member_paypal_proxy_use"] = $_GET["s2member_paypal_proxy_use"]; } /* Also add IPN proxy self-verification ( when available ) to the ``$paypal`` array. */ if (!empty($_GET["s2member_paypal_proxy_verification"])) { $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"]; } /* If debugging/logging is enabled; we need to append ``$paypal`` to the log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "paypal-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-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($paypal, true) . "\n\n", FILE_APPEND); } } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ status_header(200); /* Send a 200 OK status header. */ header("Content-Type: text/plain; charset=utf-8"); /* Content-Type text/plain with UTF-8. */ eval('while (@ob_end_clean ());'); /* End/clean all output buffers that may or may not exist. */ /**/ exit(!empty($paypal["s2member_paypal_proxy_return_url"]) ? $paypal["s2member_paypal_proxy_return_url"] : ""); } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_after_paypal_notify", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal["txn_type"]) && preg_match("/^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"])) { 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. $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_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 = 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $rec)) && ($rec = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $rec))) { if (($rec = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $rec)) && ($rec = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $rec))) { if (($rec = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $rec)) && ($rec = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $sbj)) && ($sbj = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $sbj))) { if (($sbj = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $sbj))) { if (($sbj = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $sbj)) && ($sbj = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $msg)) && ($msg = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $msg))) { if (($msg = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $msg)) && ($msg = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $msg))) { if (($msg = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $msg)) && ($msg = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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_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_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\nContent-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"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial"])), $url)) && ($url = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular"])), $url)) && ($url = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["recurring"])), $url))) { if (($url = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial_term"])), $url)) && ($url = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular_term"])), $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_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"][] = "Modification Notification URLs have been processed."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "(s2Member / API Notification Email) - Modification"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "subscr_id: %%subscr_id%%\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 = 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $msg)) && ($msg = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $msg)) && ($msg = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $msg))) { if (($msg = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $msg)) && ($msg = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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_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"]["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"]) && 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $code)) && ($code = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $code)) && ($code = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $code))) { if (($code = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $code)) && ($code = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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_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 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('/^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']) && (!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_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']; $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); if (!empty($coupon['coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $coupon_class = new c_ws_plugin__s2member_pro_coupons(); $coupon_class->update_uses($coupon['coupon_code']); } if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal['sp_ids'], $paypal['hours'])) { $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); if (!empty($coupon['full_coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $user_coupons = is_array($user_coupons = get_user_option('s2member_coupon_codes', $user_id)) ? $user_coupons : array(); $user_coupons = array_unique(array_merge($user_coupons, (array) $coupon['full_coupon_code'])); update_user_option($user_id, 's2member_coupon_codes', $user_coupons); } $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_refs($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_refs(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_refs($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_refs(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_refs($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_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $rec); if (($rec = c_ws_plugin__s2member_utils_strings::fill_cvs($rec, $paypal['custom'])) && ($rec = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $rec))) { if ($rec = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $rec)) { // Full amount of the payment, before fee is subtracted. 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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $rec)) && ($rec = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $rec)) { if (($rec = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $rec))) { if (($sbj = c_ws_plugin__s2member_utils_strings::fill_cvs($sbj, $paypal['custom'])) && ($sbj = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $sbj))) { if ($sbj = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $sbj)) { // Full amount of the payment, before fee is subtracted. 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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $sbj)) && ($sbj = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $sbj)) { if (($sbj = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $sbj))) { if (($msg = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $msg))) { if ($msg = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $msg)) { // Full amount of the payment, before fee is subtracted. 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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($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\n" . 'Content-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']) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_sale_notification_urls']) as $url) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours')))), $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('/%%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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_cid'])), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['ip'])), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(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']) { $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 .= 'currency: %%currency%%' . "\n"; $msg .= 'currency_symbol: %%currency_symbol%%' . "\n"; $msg .= 'amount: %%amount%%' . "\n"; $msg .= 'txn_id: %%txn_id%%' . "\n"; $msg .= 'txn_baid: %%txn_baid%%' . "\n"; $msg .= 'txn_cid: %%txn_cid%%' . "\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 = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($sp_access_url), $msg))) { if ($msg = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $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('/%%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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($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'])) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours')))), $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('/%%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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_cid'])), $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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['ip'])), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(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'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($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('/%%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('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $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 = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $code)) && ($code = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $code)) && ($code = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($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()); } }
/** * Processes List Server removals for s2Member. * * @package s2Member\List_Servers * @since 3.5 * * @param str $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`. * @param int|str $level A numeric s2Member Access Level number. * @param str $login Username for the User. * @param str $pass Plain Text Password for the User. * @param str $email Email address for the User. * @param str $fname First Name for the User. * @param str $lname Last Name for the User. * @param str $ip IP Address for the User. * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out. * @param int|str $user_id A WordPress User ID, numeric string or integer. * @return bool True if at least one List Server is processed successfully, else false. * * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}. * @todo Add a separate option for mail debugging; or consolidate? * @todo Integrate AWeber® API ( much like the MailChimp® API ). */ public static function process_list_server_removals($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE) { global $current_site, $current_blog; /* For Multisite support. */ /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (c_ws_plugin__s2member_list_servers::list_servers_integrated() && ($args = func_get_args()) && $role && is_string($role) && is_numeric($level) && $login && is_string($login) && is_string($pass = (string) $pass) && $email && is_string($email) && is_email($email) && is_string($fname = (string) $fname) && is_string($lname = (string) $lname) && is_string($ip = (string) $ip) && is_bool($opt_out = (bool) $opt_out) && $opt_out && $user_id && is_numeric($user_id) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) { $ccaps = implode(",", c_ws_plugin__s2member_user_access::user_access_ccaps($user)); /* Get Custom Capabilities. */ /**/ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); /* s2Member Filters enabled? */ c_ws_plugin__s2member_email_configs::email_config_release(); /* Release s2Member Filters before we begin this routine. */ /**/ if (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"])) { if (!class_exists("NC_MCAPI")) { /* Include the MailChimp® API Class here. */ include_once dirname(dirname(__FILE__)) . "/_xtnls/mailchimp/nc-mcapi.inc.php"; } /* MailChimp® API ( no-conflict version ). */ /**/ $mcapi = new NC_MCAPI($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true); /* MailChimp® API ( no-conflict ). */ /**/ foreach (preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list) { $mailchimp = array("function" => __FUNCTION__, "func_get_args" => $args, "api_removal_method" => "listUnsubscribe"); /**/ if ($mailchimp["list_id"] = trim(preg_replace("/\\:\\:.*\$/", "", $mailchimp_list))) { if ($mailchimp["api_removal_response"] = $mcapi->{$mailchimp["api_removal_method"]}($mailchimp["list_id"], $email, $mailchimp["api_removal_delete_member"] = apply_filters("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars()), $mailchimp["api_removal_send_goodbye"] = apply_filters("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars()), $mailchimp["api_removal_send_notify"] = apply_filters("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars()))) { /* Send notification? */ $mailchimp["api_removal_success"] = $removal_success = true; } /* Flag indicating that we DO have a successful removal; affects the function's overall return value. */ $mailchimp["api_removal_properties"] = $mcapi; /* Include API instance too; as it contains some additional information after each method is processed ( need this in the logs ). */ /**/ $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() ? "mailchimp-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($mailchimp, true) . "\n\n", FILE_APPEND); } } } } } } /**/ if (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"])) { foreach (preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list) { $aweber = array("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_removal_method" => "listUnsubscribe"); /**/ if ($aweber["list_id"] = trim($aweber_list)) { $aweber["removal_bcc"] = apply_filters("ws_plugin__s2member_aweber_removal_bcc", false, get_defined_vars()); /**/ c_ws_plugin__s2member_email_configs::email_config(); /* Email configs MUST be ON for removal requests. The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>. */ /**/ if ($aweber["wp_mail_removal_response"] = wp_mail($aweber["list_id"] . "@aweber.com", $aweber["wp_mail_removal_sbj"] = apply_filters("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member#" . $aweber["list_id"], get_defined_vars()), $aweber["wp_mail_removal_msg"] = "REMOVE", $aweber["wp_mail_removal_headers"] = "From: \"" . preg_replace('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">" . ($aweber["removal_bcc"] ? "\r\nBcc: " . $aweber["removal_bcc"] : "") . "\r\nContent-Type: text/plain; charset=utf-8")) { $aweber["wp_mail_removal_success"] = $removal_success = true; } /* Flag indicating that we DO have a successful removal; affects the function's overall return value. */ /**/ c_ws_plugin__s2member_email_configs::email_config_release(); /* Release. */ /**/ $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() ? "aweber-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($aweber, true) . "\n\n", FILE_APPEND); } } } } } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($email_configs_were_on) { /* Back on? */ c_ws_plugin__s2member_email_configs::email_config(); } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return apply_filters("ws_plugin__s2member_process_list_server_removals", isset($removal_success) && $removal_success, get_defined_vars()); }
/** * Unsubscribe. * * @since 141004 * @package s2Member\List_Servers * * @param array $args Input arguments. * * @return bool True if successful. */ public static function unsubscribe($args) { if (!($args = self::validate_args($args))) { return FALSE; } // Invalid args. if (!$args->opt_out) { // Double check. return FALSE; } // Must say explicitly. if (empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $args->level . '_aweber_list_ids'])) { return FALSE; } // No list configured at this level. $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $args->level . '_aweber_list_ids']; $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); if (!$email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } // MUST be ON for removal requests. // `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>. foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', $aw_level_list_ids, NULL, PREG_SPLIT_NO_EMPTY) as $_aw_list) { $_aw = array('args' => $args, 'function' => __FUNCTION__, 'list' => trim($_aw_list), 'list_id' => trim($_aw_list), 'api_method' => 'listUnsubscribe'); if (!$_aw['list']) { continue; } // List missing. $_aw['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars()); if ($_aw['wp_mail_response'] = wp_mail($_aw['list_id'] . '@aweber.com', $_aw['wp_mail_sbj'] = apply_filters('ws_plugin__s2member_aweber_removal_sbj', 'REMOVE#' . $args->email . '#s2Member#' . $_aw['list_id'], get_defined_vars()), $_aw['wp_mail_msg'] = 'REMOVE', $_aw['wp_mail_headers'] = 'From: "' . preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '" <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>' . ($_aw['removal_bcc'] ? "\r\n" . 'Bcc: ' . $_aw['removal_bcc'] : '') . "\r\n" . 'Content-Type: text/plain; charset=UTF-8')) { $_aw['wp_mail_success'] = $success = TRUE; } // Flag this as `TRUE`; assists with return value below. c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw); } unset($_aw_list, $_aw); // Just a little housekeeping. if (!$email_configs_were_on) { // Turn them off now? c_ws_plugin__s2member_email_configs::email_config_release(); } return !empty($success); // If one suceeds. }
/** * Processed by WP_Cron; this handles Auto-EOTs *( EOT = End Of Term )*. * * If you have a HUGE userbase, increase the max EOTs per process. * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network. * To increase, use: ``add_filter ("ws_plugin__s2member_auto_eot_system_per_process");``. * * This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`. * This Hook is used by some of s2Member Pro's Gateway integrations; allowing CRON processing * to run for important communications; which poll Payment Gateway APIs for possible EOTs. * * @package s2Member\Auto_EOT_System * @since 3.5 * * @param int $per_process Number of database records to process each time. * Can also be Filtered with `ws_plugin__s2member_auto_eot_system_per_process`. * @return null */ public static function auto_eot_system($per_process = 3) { global $wpdb; /* Need global DB obj. */ global $current_site, $current_blog; /* Multisite. */ /**/ include_once ABSPATH . "wp-admin/includes/admin.php"; /**/ @set_time_limit(0); /* Make time for processing a larger userbase. */ @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT)); /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_before_auto_eot_system", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) { $per_process = apply_filters("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars()); /**/ if (is_array($eots = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . $wpdb->escape(strtotime("now")) . "' LIMIT " . $per_process))) { foreach ($eots as $eot) { if (($user_id = $eot->ID) && is_object($user = new WP_User($user_id)) && $user->ID) { delete_user_option($user_id, "s2member_auto_eot_time"); /* Always delete. */ /**/ if (!$user->has_cap("administrator")) { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote") { $eot_del_type = "auto-eot-cancellation-expiration-demotion"; /**/ $custom = get_user_option("s2member_custom", $user_id); $subscr_id = get_user_option("s2member_subscr_id", $user_id); $fields = get_user_option("s2member_custom_fields", $user_id); $user_reg_ip = get_user_option("s2member_registration_ip", $user_id); /**/ $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber"); $existing_role = c_ws_plugin__s2member_user_access::user_access_role($user); /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars()); do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), $eot_del_type, "modification", $demotion_role); do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "modification"); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($existing_role !== $demotion_role) { /* Only if NOT the existing Role. */ $user->set_role($demotion_role); } /* Give User the demotion Role. */ /**/ foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } /**/ delete_user_option($user_id, "s2member_custom"); delete_user_option($user_id, "s2member_subscr_id"); delete_user_option($user_id, "s2member_subscr_gateway"); /**/ delete_user_option($user_id, "s2member_ipn_signup_vars"); if (!apply_filters("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars())) { delete_user_option($user_id, "s2member_paid_registration_times"); } /**/ delete_user_option($user_id, "s2member_last_status_scan"); delete_user_option($user_id, "s2member_first_payment_txn_id"); delete_user_option($user_id, "s2member_last_payment_time"); delete_user_option($user_id, "s2member_auto_eot_time"); /**/ delete_user_option($user_id, "s2member_file_download_access_log"); /**/ c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Demoted by s2Member: " . date("D M j, Y g:i a T")); /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\\|/", $custom))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) { /* Handle EOT Notifications. */ /**/ if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode("auto-eot-cancellation-expiration-demotion")), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($subscr_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) { /* Custom Registration/Profile Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } /**/ if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } /**/ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array($cv = preg_split("/\\|/", $custom))) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); /**/ $msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion"; $msg .= "\n\n"; /* Spacing in the message body. */ /**/ $msg .= "eot_del_type: %%eot_del_type%%\n"; $msg .= "subscr_id: %%subscr_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("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds("auto-eot-cancellation-expiration-demotion"), $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($subscr_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) { /* Custom Registration/Profile Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } } /**/ if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { /* Still have a ``$sbj`` and a ``$msg``? */ /**/ foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=utf-8"); } } } } } } } } } /**/ if ($email_configs_were_on) { /* Back on? */ c_ws_plugin__s2member_email_configs::email_config(); } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete") { $eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion"; /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars()); do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "removal-deletion"); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (is_multisite()) { remove_user_from_blog($user_id, $current_blog->blog_id); /* This will automatically trigger `eot_del_notification_urls` as well. */ c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions($user_id, $current_blog->blog_id, "s2says"); } else { /* Otherwise, we can actually delete them. */ /* This will automatically trigger `eot_del_notification_urls` as well. */ wp_delete_user($user_id); } /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */ /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_auto_eot_system", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } } } } } /**/ c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients(); /* Cleanup. */ /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_after_auto_eot_system", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return; /* Return for uniformity. */ }
/** * Handles PayPal IPN processing. * * These same routines also handle s2Member Pro/PayPal Pro operations; * giving you the ability *(as needed)* to Hook into these routines using * WordPress Hooks/Filters; as seen in the source code below. * * Please do NOT modify the source code directly. * Instead, use WordPress Hooks/Filters. * * For example, if you'd like to add your own custom conditionals, use: * ``add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");`` * * @package s2Member\PayPal * @since 3.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling IPN procesing. */ public static function paypal_notify() { global $current_site, $current_blog; do_action("ws_plugin__s2member_before_paypal_notify", get_defined_vars()); if (!empty($_GET["s2member_paypal_notify"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty($_REQUEST["s2member_paypal_proxy"]))) { @ignore_user_abort(true); // Important. Continue processing even if/when the connection is broken by the sending party. include_once ABSPATH . "wp-admin/includes/admin.php"; // Get administrative functions. Needed for `wp_delete_user()`. $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); // Filters on? c_ws_plugin__s2member_email_configs::email_config_release(); // Release s2Member Filters. $paypal = array(); // Initialize PayPal array; we also reference this with a variable for a possible proxy handler. if (!empty($_REQUEST["s2member_paypal_proxy"]) && in_array($_REQUEST["s2member_paypal_proxy"], array("alipay", "authnet", "clickbank", "ccbill", "google"), TRUE)) { ${esc_html(trim(stripslashes($_REQUEST["s2member_paypal_proxy"])))} =& $paypal; } // Internal alias by reference. if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars()) && ($_paypal = $paypal) && ($_paypal_s = serialize($_paypal))) { $paypal["s2member_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $paypal["s2member_log"][] = "s2Member POST vars verified " . (!empty($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal."); $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)\$/i"; $paypal["subscr_gateway"] = !empty($_REQUEST["s2member_paypal_proxy"]) ? esc_html(trim(stripslashes($_REQUEST["s2member_paypal_proxy"]))) : "paypal"; $coupon = !empty($_REQUEST["s2member_paypal_proxy_coupon"]) && is_array($_REQUEST["s2member_paypal_proxy_coupon"]) ? stripslashes_deep($_REQUEST["s2member_paypal_proxy_coupon"]) : array(); $coupon = isset($coupon["full_coupon_code"], $coupon["coupon_code"], $coupon["affiliate_id"]) && is_string($coupon["full_coupon_code"]) && is_string($coupon["coupon_code"]) && is_string($coupon["affiliate_id"]) ? $coupon : array("full_coupon_code" => "", "coupon_code" => "", "affiliate_id" => ""); if (!empty($paypal["txn_type"]) && $paypal["txn_type"] === "merch_pmt") { // This is mostly irrelevant, but it helps to keep the logs cleaner. sleep(5); } // Wait for Pro Form procesing to complete. if (empty($paypal["custom"]) && !empty($paypal["recurring_payment_id"])) { // Recurring Profile ID. $paypal["custom"] = c_ws_plugin__s2member_utils_users::get_user_custom_with($paypal["recurring_payment_id"]); } else { if (empty($paypal["custom"]) && !empty($paypal["mp_id"])) { // Lookup; based on a Billing Agreement ID. $paypal["custom"] = c_ws_plugin__s2member_utils_users::get_user_custom_with($paypal["mp_id"]); } } if (!empty($paypal["custom"]) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"])) { $paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated."; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } if (!apply_filters("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars())) { unset($__refs, $__v); if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_virtual_terminal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_express_checkout::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_cart::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_send_money::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_web_accept_sp::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_billing_agreement_signup::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_merch_pmt::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { // Ignoring this IPN request. The txn_type/status does NOT require any action. $paypal["s2member_log"][] = "Ignoring this IPN request. The `txn_type/status` does NOT require any action on the part of s2Member."; } } } } } } } } } } } } } } } } } else { // Else a custom conditional has been applied by Filters. unset($__refs, $__v); } } else { if (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_cancel\$/i", $paypal["txn_type"])) { $paypal["s2member_log"][] = "Transaction type ( `recurring_payment_profile_cancel` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible."; $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here."; } else { if (!empty($paypal["txn_type"]) && preg_match("/^recurring_/i", $paypal["txn_type"])) { // Otherwise, is this a ^recurring_ txn_type? $paypal["s2member_log"][] = "Transaction type ( `^recurring_?` ), but there is no match to an existing account; so verification of `\$_SERVER[\"HTTP_HOST\"]` was not possible."; } else { // Else, use the default ``$_SERVER["HTTP_HOST"]`` error. $paypal["s2member_log"][] = "Unable to verify `\$_SERVER[\"HTTP_HOST\"]`. Please check the `custom` value in your Button Code. It MUST start with your domain name."; } } } } else { $paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility."; $paypal["s2member_log"][] = "Please see this KB article: `http://www.s2member.com/kb/server-scanner/`. We suggest that you run the s2Member Server Scanner."; $paypal["s2member_log"][] = var_export($_REQUEST, true); // Recording _POST + _GET vars for analysis and debugging. } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } /* Add IPN proxy (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST["s2member_paypal_proxy"])) { $paypal["s2member_paypal_proxy"] = esc_html(trim(stripslashes((string) $_REQUEST["s2member_paypal_proxy"]))); } /* Add IPN proxy use vars (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST["s2member_paypal_proxy_use"])) { $paypal["s2member_paypal_proxy_use"] = esc_html(trim(stripslashes((string) $_REQUEST["s2member_paypal_proxy_use"]))); } /* Add IPN proxy coupon vars (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST["s2member_paypal_proxy_coupon"])) { $paypal["s2member_paypal_proxy_coupon"] = stripslashes_deep((array) $_REQUEST["s2member_paypal_proxy_coupon"]); } /* Also add IPN proxy self-verification (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST["s2member_paypal_proxy_verification"])) { $paypal["s2member_paypal_proxy_verification"] = esc_html(trim(stripslashes((string) $_REQUEST["s2member_paypal_proxy_verification"]))); } /* If debugging/logging is enabled; we need to append ``$paypal`` to the log file. Logging now supports Multisite Networking as well. */ $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "gateway-core-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "gateway-core-ipn.log"; if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($paypal, true)) . "\n\n", FILE_APPEND); } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify", get_defined_vars()); unset($__refs, $__v); status_header(200); // Send a 200 OK status header. header("Content-Type: text/plain; charset=UTF-8"); // Content-Type text/plain with UTF-8. while (@ob_end_clean()) { } // Clean any existing output buffers. exit(!empty($paypal["s2member_paypal_proxy_return_url"]) ? $paypal["s2member_paypal_proxy_return_url"] : ""); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_after_paypal_notify", get_defined_vars()); unset($__refs, $__v); }
/** * Handles new User/Member notifications. * * @package s2Member\Email_Configs * @since 110707 * * @param str|int $user_id A numeric WordPress® User ID. * @param str $user_pass Optional. A plain text version of the User's password. * If omitted, only the administrative notification will be sent. * @param array $notify An array of directives. Must be non-empty, with at least one of these values `user,admin`. * @return bool True if all required parameters are supplied, else false. */ public static function new_user_notification($user_id = FALSE, $user_pass = FALSE, $notify = array("user", "admin")) { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_before_new_user_notification", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($user_id && ($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && is_array($notify) && !empty($notify)) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); /**/ if (in_array("user", $notify) && $user_pass) { $fields = get_user_option("s2member_custom_fields", $user_id); $cv = preg_split("/\\|/", get_user_option("s2member_custom", $user_id)); $user_full_name = trim($user->first_name . " " . $user->last_name); $user_ip = $_SERVER["REMOTE_ADDR"]; /**/ if ($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_subject"]) { if ($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) { if ($sbj = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(wp_login_url()), $sbj)) { if ($sbj = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_pass), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_ip), $sbj)) { if ($sbj = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { /* Custom Registration/Profile Fields. */ if (!($sbj = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $sbj))) { break; } } } /**/ if ($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_email_message"]) { if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) { if ($msg = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(wp_login_url()), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_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) { /* Custom Registration/Profile Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } } /**/ if (($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { /* Still have a ``$sbj`` and a ``$msg``? */ /**/ c_ws_plugin__s2member_email_configs::email_config() . wp_mail($user->user_email, $sbj, $msg, "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(); } } } } } } } } } } } } } } } } } } } } } } } } /**/ if (in_array("admin", $notify)) { /* Send Admin(s) a notification? */ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]) { $fields = get_user_option("s2member_custom_fields", $user_id); $cv = preg_split("/\\|/", get_user_option("s2member_custom", $user_id)); $user_full_name = trim($user->first_name . " " . $user->last_name); $user_ip = $_SERVER["REMOTE_ADDR"]; /**/ if ($rec = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_recipients"]) { if ($rec = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) { if ($rec = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(wp_login_url()), $rec)) { if ($rec = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name)), $rec)) { if ($rec = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(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_dq(c_ws_plugin__s2member_utils_strings::esc_ds($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_pass), $rec)) { if ($rec = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_ip), $rec)) { if ($rec = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $rec)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { /* Custom Registration/Profile Fields. */ if (!($rec = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $rec))) { break; } } } /**/ if ($sbj = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_subject"]) { if ($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) { if ($sbj = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(wp_login_url()), $sbj)) { if ($sbj = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_pass), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_ip), $sbj)) { if ($sbj = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { /* Custom Registration/Profile Fields. */ if (!($sbj = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $sbj))) { break; } } } /**/ if ($msg = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["new_user_admin_email_message"]) { if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) { if ($msg = preg_replace("/%%wp_login_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(wp_login_url()), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_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) { /* Custom Registration/Profile Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } } /**/ if (($rec = trim(preg_replace("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { /* A possible list of recipients. */ wp_mail($recipient, $sbj, $msg, "Content-Type: text/plain; charset=utf-8"); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } /**/ if ($email_configs_were_on) { /* Back on? */ c_ws_plugin__s2member_email_configs::email_config(); } /**/ return apply_filters("ws_plugin__s2member_new_user_notification", true, get_defined_vars()); } else { return apply_filters("ws_plugin__s2member_new_user_notification", false, get_defined_vars()); } }
/** * Handles new User/Member notifications. * * @package s2Member\Email_Configs * @since 110707 * * @param string|int $user_id A numeric WordPress User ID. * @param string $user_pass Optional. A plain text version of the User's password. * If omitted, only the administrative notification will be sent. * @param array $notify An array of directives. Must be non-empty, with at least one of these values `user,admin`. * @param string $user_email Optional. This defaults to the user's currently configured email address. * @return bool True if all required parameters are supplied, else false. */ public static function new_user_notification($user_id = 0, $user_pass = '', $notify = array('user', 'admin'), $user_email = '') { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_new_user_notification', get_defined_vars()); unset($__refs, $__v); // Housekeeping. $user_id = (int) $user_id; $user_pass = (string) $user_pass; $notify = (array) $notify; $user_email = (string) $user_email; if (!$user_pass && !empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) { $user_pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass']; } if ($user_id && ($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && $notify) { $is_gte_wp43 = version_compare(get_bloginfo('version'), '4.3', '>='); $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); if (in_array('user', $notify, true) && empty($GLOBALS['ws_plugin__s2member_custom_wp_login_bp_password']) && ($user_pass && stripos($GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_message'], '%%user_pass%%') !== false || $is_gte_wp43 && stripos($GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_message'], '%%wp_set_pass_url%%') !== false || $is_gte_wp43 && stripos($GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_message'] = sprintf(_x("Your Username/Password for:\n%s\n\nUsername: %%%%user_login%%%%\nTo set your password, visit: %%%%wp_set_pass_url%%%%\n\n%%%%wp_login_url%%%%", 's2member-front', 's2member'), get_bloginfo('name')), '%%wp_set_pass_url%%') !== false)) { if ($is_gte_wp43 && stripos($GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_message'], '%%wp_set_pass_url%%') !== false) { remove_filter('random_password', 'c_ws_plugin__s2member_registrations::generate_password'); $user_activation_key = wp_generate_password(20, false); // ↑ Make sure it's w/o filter. do_action('retrieve_password_key', $user->user_login, $user_activation_key); if (!class_exists('PasswordHash')) { require_once ABSPATH . WPINC . '/class-phpass.php'; } $wp_hasher = new PasswordHash(8, true); $user_activation_key_hash = time() . ':' . $wp_hasher->HashPassword($user_activation_key); $GLOBALS['wpdb']->update($GLOBALS['wpdb']->users, array('user_activation_key' => $user_activation_key_hash), array('user_login' => $user->user_login)); $wp_set_pass_url_args = array('action' => 'rp', 'key' => $user_activation_key, 'login' => $user->user_login); $wp_set_pass_url = add_query_arg(urlencode_deep($wp_set_pass_url_args), wp_login_url()); } else { $wp_set_pass_url = wp_lostpassword_url(); } // Default behavior; and older versions of WordPress. $fields = get_user_option('s2member_custom_fields', $user_id); $cv = preg_split('/\\|/', get_user_option('s2member_custom', $user_id)); $role = c_ws_plugin__s2member_user_access::user_access_role($user); $label = c_ws_plugin__s2member_user_access::user_access_label($user); $level = c_ws_plugin__s2member_user_access::user_access_level($user); $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $user->user_email = $user_email ? $user_email : $user->user_email; $user_full_name = trim($user->first_name . ' ' . $user->last_name); $user_ip = $_SERVER['REMOTE_ADDR']; if ($sbj = $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_subject']) { if ($sbj = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $sbj)) { if ($sbj = preg_replace('/%%wp_set_pass_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($wp_set_pass_url), $sbj)) { if ($sbj = preg_replace('/%%wp_login_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $sbj)) { if ($sbj = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $sbj)) { if ($sbj = preg_replace('/%%label%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($label), $sbj)) { if ($sbj = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $sbj)) { if ($sbj = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $sbj)) { if ($sbj = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $sbj)) { if ($sbj = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $sbj)) { if ($sbj = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { // Custom Registration/Profile Fields. if (!($sbj = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $sbj))) { break; } } } // Empty; we can stop here. if ($msg = $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_email_message']) { if ($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)) { if ($msg = preg_replace('/%%wp_set_pass_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($wp_set_pass_url), $msg)) { if ($msg = preg_replace('/%%wp_login_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $msg)) { if ($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace('/%%label%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($label), $msg)) { if ($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_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) { // Custom Registration/Profile Fields. if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } } // Empty; we can stop here. if (($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()); } c_ws_plugin__s2member_email_configs::email_config() . wp_mail($user->user_email, apply_filters('ws_plugin__s2member_welcome_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_welcome_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(); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if (in_array('admin', $notify, true) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_admin_email_recipients']) { $fields = get_user_option('s2member_custom_fields', $user_id); $cv = preg_split('/\\|/', get_user_option('s2member_custom', $user_id)); $role = c_ws_plugin__s2member_user_access::user_access_role($user); $label = c_ws_plugin__s2member_user_access::user_access_label($user); $level = c_ws_plugin__s2member_user_access::user_access_level($user); $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $user->user_email = $user_email ? $user_email : $user->user_email; $user_full_name = trim($user->first_name . ' ' . $user->last_name); $user_ip = $_SERVER['REMOTE_ADDR']; if ($rec = $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_admin_email_recipients']) { if ($rec = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $rec)) { if ($rec = preg_replace('/%%wp_login_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $rec)) { if ($rec = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $rec)) { if ($rec = preg_replace('/%%label%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($label), $rec)) { if ($rec = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $rec)) { if ($rec = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $rec)) { if ($rec = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name)), $rec)) { if ($rec = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(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_dq(c_ws_plugin__s2member_utils_strings::esc_refs($user_full_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_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $rec)) { if ($rec = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $rec)) { if ($rec = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $rec)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { // Custom Registration/Profile Fields. if (!($rec = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $rec))) { break; } } } // Empty; we can stop here. if ($sbj = $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_admin_email_subject']) { if ($sbj = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $sbj)) { if ($sbj = preg_replace('/%%wp_login_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $sbj)) { if ($sbj = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $sbj)) { if ($sbj = preg_replace('/%%label%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($label), $sbj)) { if ($sbj = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $sbj)) { if ($sbj = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $sbj)) { if ($sbj = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $sbj)) { if ($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($user_full_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_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $sbj)) { if ($sbj = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_ip), $sbj)) { if ($sbj = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $sbj)) { if (is_array($fields) && !empty($fields)) { foreach ($fields as $var => $val) { // Custom Registration/Profile Fields. if (!($sbj = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $sbj))) { break; } } } // Empty; we can stop here. if ($msg = $GLOBALS['WS_PLUGIN__']['s2member']['o']['new_user_admin_email_message']) { if ($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)) { if ($msg = preg_replace('/%%wp_login_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(wp_login_url()), $msg)) { if ($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace('/%%label%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($label), $msg)) { if ($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $msg)) { if ($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($user_full_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_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_pass), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_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) { // Custom Registration/Profile Fields. if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } } // Empty; we can stop here. 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()) { $rec = c_ws_plugin__s2member_utilities::evl($rec, get_defined_vars()); $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) { // A list of receipients. wp_mail($recipient, apply_filters('ws_plugin__s2member_admin_new_user_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_admin_new_user_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($email_configs_were_on) { // Restore? c_ws_plugin__s2member_email_configs::email_config(); } return apply_filters('ws_plugin__s2member_new_user_notification', true, get_defined_vars()); } return apply_filters('ws_plugin__s2member_new_user_notification', false, get_defined_vars()); }
/** * Processed by WP_Cron; this handles Auto-EOTs *(EOT = End Of Term)*. * * If you have a HUGE userbase, increase the max EOTs per process. * But NOTE, this runs ``$per_process`` *(per Blog)* on a Multisite Network. * To increase, use: ``add_filter ("ws_plugin__s2member_auto_eot_system_per_process");``. * * This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`. * This Hook is used by some of s2Member Pro's Gateway integrations; allowing CRON processing * to run for important communications; which poll Payment Gateway APIs for possible EOTs. * * @package s2Member\Auto_EOT_System * @since 3.5 * * @param int $per_process Number of database records to process each time. * Can also be Filtered with `ws_plugin__s2member_auto_eot_system_per_process`. * @return null */ public static function auto_eot_system($per_process = 3) { global $wpdb; global $current_site, $current_blog; include_once ABSPATH . "wp-admin/includes/admin.php"; @set_time_limit(0); @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT)); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_auto_eot_system", get_defined_vars()); unset($__refs, $__v); if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) { $per_process = apply_filters("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars()); if (is_array($eots = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . esc_sql(strtotime("now")) . "' LIMIT " . $per_process))) { foreach ($eots as $eot) { if (($user_id = $eot->ID) && is_object($user = new WP_User($user_id)) && $user->ID) { delete_user_option($user_id, "s2member_auto_eot_time"); if (!$user->has_cap("administrator")) { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote") { $eot_del_type = "auto-eot-cancellation-expiration-demotion"; $custom = get_user_option("s2member_custom", $user_id); $subscr_gateway = get_user_option("s2member_subscr_gateway", $user_id); $subscr_id = get_user_option("s2member_subscr_id", $user_id); $fields = get_user_option("s2member_custom_fields", $user_id); $user_reg_ip = get_user_option("s2member_registration_ip", $user_id); $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber"); $existing_role = c_ws_plugin__s2member_user_access::user_access_role($user); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars()); do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), $eot_del_type, "modification", $demotion_role); do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "modification"); unset($__refs, $__v); if ($existing_role !== $demotion_role) { $user->set_role($demotion_role); } if (apply_filters("ws_plugin__s2member_remove_ccaps_during_eot_events", (bool) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eots_remove_ccaps"], get_defined_vars())) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } delete_user_option($user_id, "s2member_custom"); delete_user_option($user_id, "s2member_subscr_id"); delete_user_option($user_id, "s2member_subscr_gateway"); delete_user_option($user_id, "s2member_ipn_signup_vars"); if (!apply_filters("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars())) { delete_user_option($user_id, "s2member_paid_registration_times"); } delete_user_option($user_id, "s2member_last_status_scan"); delete_user_option($user_id, "s2member_first_payment_txn_id"); delete_user_option($user_id, "s2member_last_payment_time"); delete_user_option($user_id, "s2member_auto_eot_time"); delete_user_option($user_id, "s2member_file_download_access_log"); c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Demoted by s2Member: " . date("D M j, Y g:i a T")); if ($subscr_gateway && $subscr_id) { // Also note the Paid Subscr. Gateway/ID so there is a reference left behind here. c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Paid Subscr. ID @ time of demotion: " . $subscr_gateway . " -› " . $subscr_id); } if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\\|/", $custom))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) { // Handle EOT Notifications. if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode("auto-eot-cancellation-expiration-demotion")), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($subscr_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); } } } } } } } } } } if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array($cv = preg_split("/\\|/", $custom))) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = "(s2Member / API Notification Email) - EOT/Deletion"; $msg .= "\n\n"; $msg .= "eot_del_type: %%eot_del_type%%\n"; $msg .= "subscr_id: %%subscr_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("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds("auto-eot-cancellation-expiration-demotion"), $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($subscr_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)))) { foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } if ($email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars()); unset($__refs, $__v); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete") { $eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion"; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars()); do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "removal-deletion"); unset($__refs, $__v); if (is_multisite()) { remove_user_from_blog($user_id, $current_blog->blog_id); // This will automatically trigger `eot_del_notification_urls`. c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions($user_id, $current_blog->blog_id, "s2says"); } else { // Otherwise, we can actually delete them. // This will automatically trigger `eot_del_notification_urls` wp_delete_user($user_id); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars()); unset($__refs, $__v); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_auto_eot_system", get_defined_vars()); unset($__refs, $__v); } } } } } c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients(); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_after_auto_eot_system", get_defined_vars()); unset($__refs, $__v); return; }
/** * 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('/^(web_accept|subscr_signup)$/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['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_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_subscr_signup', 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)) { $processing = $modifying = $during = FALSE; // Initialize these flags. $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ).'; @(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['period1'] = isset($paypal['period1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D'; $paypal['mc_amount1'] = isset($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'; $paypal['initial'] = isset($paypal['mc_amount1'][0]) && 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'] = !empty($paypal['recurring']) ? $paypal['mc_amount3'] : '0'; // If non-recurring, this should be zero, otherwise regular. $ipn_signup_vars = $paypal; // Create array of IPN signup vars w/o s2member_log. unset($ipn_signup_vars['s2member_log']); /* New Subscription with advanced update vars (option_name1, option_selection1)? These variables are 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_notify_before_subscr_signup_w_update_vars', get_defined_vars()); unset($__refs, $__v); $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ) 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_notify_during_before_subscr_signup_w_update_vars', 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); $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip']; 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']) { $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']); } 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']) { update_user_option($user_id, 's2member_auto_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 set to: ' . date('D M j, Y g:i:s a T', $eot_time) . '.'; } else { 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.'; $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 = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $rec)) && ($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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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 = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $sbj)) && ($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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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 = 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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['modification_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $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'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { $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 .= '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 .= '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_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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']) && 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_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('/%%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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $code)) && ($code = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $code)) && ($code = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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_signup_w_update_vars', 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. Please check the `on0` and `os0` variables in your Button Code.'; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars', get_defined_vars()); unset($__refs, $__v); } else { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/o update vars.'; if (($registration_url = c_ws_plugin__s2member_register_access::register_link_gen($paypal['subscr_gateway'], $paypal['subscr_id'], $paypal['custom'], $paypal['item_number'])) && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { $processing = $during = TRUE; // Yes, we ARE processing this. $sbj = preg_replace('/%%registration_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($registration_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'signup_email_subject']); $msg = preg_replace('/%%registration_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($registration_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'signup_email_message']); $rec = preg_replace('/%%registration_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($registration_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'signup_email_recipients']); 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_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('/%%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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $rec)) { if (($rec = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_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_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('/%%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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $sbj)) { if (($sbj = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_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_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('/%%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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($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_signup_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_signup_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'][] = 'Signup Confirmation Email sent to: ' . $rec . '.'; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['signup_notification_urls'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['signup_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('/%%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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['ip'])), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $url))) { if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } $paypal['s2member_log'][] = 'Signup Notification URLs have been processed.'; } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['signup_notification_recipients'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { $msg = $sbj = '(s2Member / API Notification Email) - Signup'; $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 .= '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_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('/%%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('/%%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_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($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']['signup_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_signup_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_signup_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } } } $paypal['s2member_log'][] = 'Signup Notification Emails have been processed.'; } if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['signup_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_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('/%%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 = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $code)) && ($code = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $code)) && ($code = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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_notify_during_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); } else { $paypal['s2member_log'][] = 'Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response.'; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars', get_defined_vars()); unset($__refs, $__v); } if ($processing && $_REQUEST['s2member_paypal_proxy'] && ($url = $_REQUEST['s2member_paypal_proxy_return_url']) && is_array($cv = preg_split('/\\|/', $paypal['custom']))) { if (!empty($user_id) && !empty($user) && is_object($user) && $user->ID || ($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) { $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. 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('/%%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('/%%modification%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode((int) $modifying)), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $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($url)) { // Preserve remaining replacements; parent routine may perform replacements too. $paypal['s2member_paypal_proxy_return_url'] = $url; } } } } } } } } } } } } } } } } } } $paypal['s2member_log'][] = 'Subscr. Return ( `modification=' . (int) $modifying . '` ), a Proxy Return URL is ready.'; } if ($processing && (preg_match('/^web_accept$/i', $paypal['txn_type']) || $_REQUEST['s2member_paypal_proxy'] && preg_match('/subscr-signup-as-subscr-payment/', $_REQUEST['s2member_paypal_proxy_use']) && $paypal['txn_id'] && $paypal['mc_gross'] > 0) && (!empty($user_id) && !empty($user) && is_object($user) && $user->ID || ($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)) { $paypal['s2member_log'][] = 'User exists. Handling `payment` for Subscription via ( `' . (preg_match('/^web_accept$/i', $paypal['txn_type']) ? 'web_accept' : 'subscr-signup-as-subscr-payment') . '` ).'; $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); if (!get_user_option('s2member_first_payment_txn_id', $user_id)) { update_user_option($user_id, 's2member_first_payment_txn_id', $paypal['txn_id']); } update_user_option($user_id, 's2member_last_payment_time', time()); // Update the last payment time. $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. if ($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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $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 ($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 .= '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_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('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $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.'; } } else { if ($processing && (preg_match('/^web_accept$/i', $paypal['txn_type']) || $_REQUEST['s2member_paypal_proxy'] && preg_match('/subscr-signup-as-subscr-payment/', $_REQUEST['s2member_paypal_proxy_use']) && $paypal['txn_id'] && $paypal['mc_gross'] > 0)) { $paypal['s2member_log'][] = 'Storing `payment` for Subscription via ( `' . (preg_match('/^web_accept$/i', $paypal['txn_type']) ? 'web_accept' : 'subscr-signup-as-subscr-payment') . '` ).'; $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'][] = 'Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.'; set_transient('s2m_' . md5('s2member_transient_ipn_subscr_payment_' . $paypal['subscr_id']), $ipn, 43200); } } if ($processing && (!empty($user_id) && !empty($user) && is_object($user) && $user->ID || ($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)) { $paypal['s2member_log'][] = 'Storing IPN signup vars now. These are associated with a User\'s account record; for future reference.'; update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars); } else { if ($processing) { $paypal['s2member_log'][] = 'Storing IPN signup vars into a Transient Queue. These will be processed on registration.'; set_transient('s2m_' . md5('s2member_transient_ipn_signup_vars_' . $paypal['subscr_id']), $ipn_signup_vars, 43200); } } } else { $paypal['s2member_log'][] = 'Not processing. Duplicate IPN.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ).'; $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_signup', get_defined_vars()); unset($__refs, $__v); return apply_filters('c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level', $paypal, get_defined_vars()); } return apply_filters('c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level', FALSE, get_defined_vars()); }
/** * Processes List Server removals for s2Member. * * @package s2Member\List_Servers * @since 3.5 * * @param str $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`. * @param int|str $level A numeric s2Member Access Level number. * @param str $login Username for the User. * @param str $pass Plain Text Password for the User. * @param str $email Email address for the User. * @param str $fname First Name for the User. * @param str $lname Last Name for the User. * @param str $ip IP Address for the User. * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out. * @param int|str $user_id A WordPress User ID, numeric string or integer. * @return bool True if at least one List Server is processed successfully, else false. * * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}. * @todo Add a separate option for mail debugging; or consolidate? * @todo Integrate AWeber API (much like the MailChimp API). */ public static function process_list_server_removals($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE) { global $current_site, $current_blog; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); if (c_ws_plugin__s2member_list_servers::list_servers_integrated() && ($args = func_get_args()) && $role && is_string($role) && is_numeric($level) && $login && is_string($login) && is_string($pass = (string) $pass) && $email && is_string($email) && is_email($email) && is_string($fname = (string) $fname) && is_string($lname = (string) $lname) && is_string($ip = (string) $ip) && is_bool($opt_out = (bool) $opt_out) && $opt_out && $user_id && is_numeric($user_id) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) { $ccaps = implode(",", c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); if (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"])) { if (!class_exists("NC_MCAPI")) { include_once dirname(dirname(__FILE__)) . "/externals/mailchimp/nc-mcapi.inc.php"; } $mcapi = new NC_MCAPI($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true); foreach (preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list) { $mailchimp = array("function" => __FUNCTION__, "func_get_args" => $args, "api_removal_method" => "listUnsubscribe"); if ($mailchimp["list_id"] = trim(preg_replace("/\\:\\:.*\$/", "", $mailchimp_list))) { if ($mailchimp["api_removal_response"] = $mcapi->{$mailchimp["api_removal_method"]}($mailchimp["list_id"], $email, $mailchimp["api_removal_delete_member"] = apply_filters("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars()), $mailchimp["api_removal_send_goodbye"] = apply_filters("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars()), $mailchimp["api_removal_send_notify"] = apply_filters("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars()))) { // Send notification? $mailchimp["api_removal_success"] = $removal_success = true; } // Flag indicating that we DO have a successful removal; affects the function's overall return value. $mailchimp["api_removal_properties"] = $mcapi; // Include API instance too; as it contains some additional information after each method is processed (need this in the logs). $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\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() ? "mailchimp-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log"; if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($mailchimp, true)) . "\n\n", FILE_APPEND); } } } } } } if (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["getresponse_api_key"]) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_getresponse_list_ids"])) { foreach (preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_getresponse_list_ids"]) as $getresponse_list) { $getresponse = array("function" => __FUNCTION__, "func_get_args" => $args, "api_method" => "get_contacts"); if ($getresponse["list_id"] = $getresponse["list"] = trim($getresponse_list)) { $getresponse["api_headers"] = array("Content-Type" => "application/json"); $getresponse["api_params"] = array($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["getresponse_api_key"], array("campaigns" => array($getresponse["list_id"]), "email" => array("EQUALS" => $email))); $getresponse["api_request"] = json_encode(array("method" => $getresponse["api_method"], "params" => $getresponse["api_params"], "id" => uniqid("", TRUE))); if (is_object($getresponse["api_response"] = json_decode(c_ws_plugin__s2member_utils_urls::remote("https://api2.getresponse.com", $getresponse["api_request"], array("headers" => $getresponse["api_headers"])))) && empty($getresponse["api_response"]->error) && ($getresponse["api_response_contact_ids"] = array_keys((array) $getresponse["api_response"]->result)) && ($getresponse["api_response_contact_id"] = $getresponse["api_response_contact_ids"][0])) { $getresponse["api_method"] = "delete_contact"; // Update method now. $getresponse["api_headers"] = array("Content-Type" => "application/json"); $getresponse["api_params"] = array($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["getresponse_api_key"], array("contact" => $getresponse["api_response_contact_id"])); $getresponse["api_request"] = json_encode(array("method" => $getresponse["api_method"], "params" => $getresponse["api_params"], "id" => uniqid("", TRUE))); if (is_object($getresponse["api_response"] = json_decode(c_ws_plugin__s2member_utils_urls::remote("https://api2.getresponse.com", $getresponse["api_request"], array("headers" => $getresponse["api_headers"])))) && empty($getresponse["api_response"]->error) && $getresponse["api_response"]->result->deleted) { $getresponse["api_success"] = $success = true; } } $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\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() ? "getresponse-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "getresponse-api.log"; if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($getresponse, true)) . "\n\n", FILE_APPEND); } } } } } } if (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"])) { foreach (preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list) { $aweber = array("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_removal_method" => "listUnsubscribe"); if ($aweber["list_id"] = trim($aweber_list)) { $aweber["removal_bcc"] = apply_filters("ws_plugin__s2member_aweber_removal_bcc", false, get_defined_vars()); c_ws_plugin__s2member_email_configs::email_config(); // Email configs MUST be ON for removal requests. // The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>. if ($aweber["wp_mail_removal_response"] = wp_mail($aweber["list_id"] . "@aweber.com", $aweber["wp_mail_removal_sbj"] = apply_filters("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member#" . $aweber["list_id"], get_defined_vars()), $aweber["wp_mail_removal_msg"] = "REMOVE", $aweber["wp_mail_removal_headers"] = "From: \"" . preg_replace('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">" . ($aweber["removal_bcc"] ? "\r\nBcc: " . $aweber["removal_bcc"] : "") . "\r\nContent-Type: text/plain; charset=UTF-8")) { $aweber["wp_mail_removal_success"] = $removal_success = true; } // Flag indicating that we DO have a successful removal; affects the function's overall return value. c_ws_plugin__s2member_email_configs::email_config_release(); $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\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() ? "aweber-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log"; if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($aweber, true)) . "\n\n", FILE_APPEND); } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); if ($email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars()); unset($__refs, $__v); return apply_filters("ws_plugin__s2member_process_list_server_removals", isset($removal_success) && $removal_success, get_defined_vars()); }
/** * Handles PayPal IPN processing. * * These same routines also handle s2Member Pro/PayPal Pro operations; * giving you the ability *(as needed)* to Hook into these routines using * WordPress Hooks/Filters; as seen in the source code below. * * Please do NOT modify the source code directly. * Instead, use WordPress Hooks/Filters. * * For example, if you'd like to add your own custom conditionals, use: * ``add_filter ('ws_plugin__s2member_during_paypal_notify_conditionals', 'your_function');`` * * @package s2Member\PayPal * @since 3.5 * * @attaches-to ``add_action('init');`` */ public static function paypal_notify() { global $current_site, $current_blog; do_action('ws_plugin__s2member_before_paypal_notify', get_defined_vars()); if (!empty($_GET['s2member_paypal_notify']) && ($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_business'] || !empty($_REQUEST['s2member_paypal_proxy']))) { @ignore_user_abort(TRUE); // Important. Continue processing even if/when the connection is broken by the sending party. include_once ABSPATH . 'wp-admin/includes/admin.php'; // Get administrative functions. Needed for `wp_delete_user()`. $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); // Filters on? c_ws_plugin__s2member_email_configs::email_config_release(); // Release s2Member Filters. $paypal = array(); // Initialize PayPal array; we also reference this with a variable for a possible proxy handler. if (!empty($_REQUEST['s2member_paypal_proxy']) && in_array($_REQUEST['s2member_paypal_proxy'], array('alipay', 'stripe', 'authnet', 'clickbank', 'ccbill', 'google'), TRUE)) { ${esc_html(trim(stripslashes($_REQUEST['s2member_paypal_proxy'])))} =& $paypal; } // Internal alias by reference. if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars()) && ($_paypal = $paypal) && ($_paypal_s = serialize($_paypal))) { $paypal['s2member_log'][] = 'IPN received on: ' . date('D M j, Y g:i:s a T'); $paypal['s2member_log'][] = 's2Member POST vars verified ' . (!empty($paypal['proxy_verified']) ? 'with a Proxy Key' : 'through a POST back to PayPal.'); $payment_status_issues = '/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i'; $paypal['subscr_gateway'] = !empty($_REQUEST['s2member_paypal_proxy']) ? esc_html(trim(stripslashes($_REQUEST['s2member_paypal_proxy']))) : 'paypal'; $coupon = !empty($_REQUEST['s2member_paypal_proxy_coupon']) && is_array($_REQUEST['s2member_paypal_proxy_coupon']) ? stripslashes_deep($_REQUEST['s2member_paypal_proxy_coupon']) : array(); $coupon = isset($coupon['full_coupon_code'], $coupon['coupon_code'], $coupon['affiliate_id']) && is_string($coupon['full_coupon_code']) && is_string($coupon['coupon_code']) && is_string($coupon['affiliate_id']) ? $coupon : array('full_coupon_code' => '', 'coupon_code' => '', 'affiliate_id' => ''); if (!empty($paypal['txn_type']) && $paypal['txn_type'] === 'merch_pmt') { // This is mostly irrelevant, but it helps to keep the logs cleaner. sleep(15); } // Wait for Pro-Form procesing to complete. if (empty($paypal['custom']) && !empty($paypal['recurring_payment_id'])) { // Recurring Profile ID. $paypal['custom'] = c_ws_plugin__s2member_utils_users::get_user_custom_with($paypal['recurring_payment_id']); } else { if (empty($paypal['custom']) && !empty($paypal['mp_id'])) { // Billing Agreement ID. $paypal['custom'] = c_ws_plugin__s2member_utils_users::get_user_custom_with($paypal['mp_id']); } } if (!empty($paypal['custom']) && preg_match('/^' . preg_quote(preg_replace('/\\:([0-9]+)$/', '', $_SERVER['HTTP_HOST']), '/') . '/i', $paypal['custom'])) { $paypal['s2member_log'][] = 's2Member originating domain (`$_SERVER["HTTP_HOST"]`) validated.'; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } if (!apply_filters('ws_plugin__s2member_during_paypal_notify_conditionals', FALSE, get_defined_vars())) { unset($__refs, $__v); // From the filter above. if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_virtual_terminal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_express_checkout::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_cart::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_send_money::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_web_accept_sp::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_wa_ccaps_wo_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_modify_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_cancellation_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_eots_w_level::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_sp_refund_reversal::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { if ($_paypal_cp = c_ws_plugin__s2member_paypal_notify_in_billing_agreement_signup::cp(get_defined_vars())) { $paypal = $_paypal_cp; } else { // Ignoring this IPN request. The txn_type/status does NOT require any action. $paypal['s2member_log'][] = 'Ignoring this IPN request. The `txn_type/status` does NOT require any action on the part of s2Member.'; } } } } } } } } } } } } } } } } else { unset($__refs, $__v); } // Else a custom conditional has been applied by Filters. } else { if (!empty($paypal['txn_type']) && preg_match('/^recurring_payment_profile_cancel$/i', $paypal['txn_type'])) { $paypal['s2member_log'][] = 'Transaction type (`recurring_payment_profile_cancel`), but there is no match to an existing account; so verification of `$_SERVER["HTTP_HOST"]` was not possible.'; $paypal['s2member_log'][] = 'It\'s likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here.'; } else { if (!empty($paypal['txn_type']) && preg_match('/^recurring_/i', $paypal['txn_type'])) { // Otherwise, is this a ^recurring_ txn_type? $paypal['s2member_log'][] = 'Transaction type (`^recurring_?`), but there is no match to an existing account; so verification of `$_SERVER["HTTP_HOST"]` was not possible.'; } else { // Else, use the default ``$_SERVER['HTTP_HOST']`` error. $paypal['s2member_log'][] = 'Unable to verify `$_SERVER["HTTP_HOST"]`. Please check the `custom` value in your Button Code. It MUST start with your domain name.'; } } } } else { $paypal['s2member_log'][] = 'Unable to verify $_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.'; $paypal['s2member_log'][] = 'Please see this KB article: `http://www.s2member.com/kb/server-scanner/`. We suggest that you run the s2Member Server Scanner.'; $paypal['s2member_log'][] = var_export($_REQUEST, TRUE); // Recording _POST + _GET vars for analysis and debugging. } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } /* Add IPN proxy (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST['s2member_paypal_proxy'])) { $paypal['s2member_paypal_proxy'] = esc_html(trim(stripslashes((string) $_REQUEST['s2member_paypal_proxy']))); } /* Add IPN proxy use vars (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST['s2member_paypal_proxy_use'])) { $paypal['s2member_paypal_proxy_use'] = esc_html(trim(stripslashes((string) $_REQUEST['s2member_paypal_proxy_use']))); } /* Add IPN proxy coupon vars (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST['s2member_paypal_proxy_coupon'])) { $paypal['s2member_paypal_proxy_coupon'] = stripslashes_deep((array) $_REQUEST['s2member_paypal_proxy_coupon']); } /* Also add IPN proxy self-verification (when available) to the ``$paypal`` array. */ if (!empty($_REQUEST['s2member_paypal_proxy_verification'])) { $paypal['s2member_paypal_proxy_verification'] = esc_html(trim(stripslashes((string) $_REQUEST['s2member_paypal_proxy_verification']))); } /* If debugging/logging is enabled; we need to append ``$paypal`` to the log file. Logging now supports Multisite Networking as well. */ $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT']; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? 'gateway-core-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'gateway-core-ipn.log'; if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) { if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($paypal, TRUE)) . "\n\n", FILE_APPEND); } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify', get_defined_vars()); unset($__refs, $__v); status_header(200); // Send a 200 OK status header. header('Content-Type: text/plain; charset=UTF-8'); // Content-Type text/plain with UTF-8. while (@ob_end_clean()) { } // Clean any existing output buffers. exit(!empty($paypal['s2member_paypal_proxy_return_url']) ? $paypal['s2member_paypal_proxy_return_url'] : ''); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_after_paypal_notify', get_defined_vars()); unset($__refs, $__v); }
/** * Configures all new Users. * * The Hook `user_register` is also fired by calling: * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``. * * This function also receives hand-offs from s2Member's handlers for these two Hooks: * `wpmu_activate_user` and `wpmu_activate_blog`. * * @package s2Member\Registrations * @since 3.5 * * @attaches-to ``add_action('user_register');`` * * @param int|string $user_id A numeric WordPress User ID. * @param string $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources. * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member. * * @TODO Impossible to delete cookies when fired inside: `/wp-activate.php`? */ public static function configure_user_registration($user_id = '', $password = '', $meta = array()) { global $wpdb; // Global database object reference. global $pagenow; // We need this to detect the current administration page. global $current_site, $current_blog; // Adds support for Multisite Networking. static $email_config, $processed; // Static vars prevent duplicate processing. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_configure_user_registration', get_defined_vars()); unset($__refs, $__v); // Housekeeping. // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`. if (!isset($email_config) && ($email_config = TRUE)) { // Anytime this routine is fired; we configure email. c_ws_plugin__s2member_email_configs::email_config(); } // Configures `From:` email header. $_p = isset($_POST) ? $_POST : NULL; // Grab global ``$_POST`` array here, if it's possible to do so. $rvs = isset($GLOBALS['ws_plugin__s2member_registration_vars']) ? $GLOBALS['ws_plugin__s2member_registration_vars'] : NULL; if (!$processed) { if (is_array($_p) || is_array($meta) || is_array($rvs)) { if (!(is_multisite() && is_blog_admin() && $pagenow === 'user-new.php' && isset($_p['noconfirmation']) && is_super_admin() && !is_array($meta))) { if (!(preg_match('/\\/wp-activate\\.php/', $_SERVER['REQUEST_URI']) && !is_array($meta))) { if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) { if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user') && !is_array($rvs))) { if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = TRUE)) { settype($_p, 'array') . settype($meta, 'array') . settype($rvs, 'array'); // Force arrays here. $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p)); $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta)); $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs); foreach ($_p as $_key => $_value) { // Scan ``$_p`` vars; adding `custom_reg_field` keys. if (preg_match('/^ws_plugin__s2member_user_new_/', $_key)) { // Look for keys. if ($_key = str_replace('_user_new_', '_custom_reg_field_', $_key)) { $_p[$_key] = $_value; } } } // Add each of these key conversions. unset($_key, $_value); if (!is_admin() && (isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_custom']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_ccaps']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_notes']))) { exit(_x('s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!', 's2member-front', 's2member')); } $_pmr = array_merge($_p, $meta, $rvs); // Merge all of these arrays together now, in this specific order. unset($_p, $meta, $rvs); // These variables can all be unset now; we have them all in the ``$_pmr`` array. $custom_reg_display_name = $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_display_name']; // Can be configured by the site owner. if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin—via `/user-new.php`. */ /** * @var $subscr_gateway string Reference for IDEs. * @var $subscr_id string Reference for IDEs. * @var $custom string Reference for IDEs. * @var $item_number string Reference for IDEs. */ $processed = 'yes'; // Mark this as yes. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $item_number, 3)); $role = 's2member_level' . $level; // Membership Level. $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip']; $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip; // Else use environment variable. $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']; $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']; $cv = preg_split('/\\|/', $custom); if (!($auto_eot_time = '') && $eotper) { // If a specific EOT Period is included. $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper); } $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes']; $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE; $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in; if (!($fname = $user->first_name)) { if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) { $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name']; } } if (!$fname) { // Also try BuddyPress. if (!empty($_pmr['field_1'])) { // BuddyPress? $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1'])); } } if (!($lname = $user->last_name)) { if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) { $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name']; } } if (!$lname) { // Also try BuddyPress. if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) { $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1'])); } } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) { $fname = trim($login); $lname = ''; // Username and empty Last Name. } $name = trim($fname . ' ' . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) { $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass']; } } if (!$pass) { // Also try BuddyPress Password. if (!empty($_pmr['signup_password'])) { // BuddyPress? $pass = (string) $_pmr['signup_password']; } } if ($pass) { !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL; update_user_option($user_id, 'default_password_nag', FALSE, TRUE); } update_user_option($user_id, 's2member_registration_ip', $ip); update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time); update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway); update_user_option($user_id, 's2member_subscr_id', $subscr_id); update_user_option($user_id, 's2member_subscr_baid', $subscr_baid); update_user_option($user_id, 's2member_subscr_cid', $subscr_cid); update_user_option($user_id, 's2member_custom', $custom); update_user_option($user_id, 's2member_notes', $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, 'first_name', $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, 'last_name', $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === 'full' && $name) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name))); } else { if ($custom_reg_display_name === 'first' && $fname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname))); } else { if ($custom_reg_display_name === 'last' && $lname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname))); } else { if ($custom_reg_display_name === 'login' && $login) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login))); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) { remove_user_from_blog($user_id, $current_site->blog_id); } // No Main Site Role. if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) { // Recorded yet? update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) { foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) { $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id'])); $field_id_class = preg_replace('/_/', '-', $field_var); if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) { $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, 's2member_custom_fields', $fields); } if ($level > 0) { $pr_times = get_user_option('s2member_paid_registration_times', $user_id); $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level']; $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level]; update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now. } if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) { update_user_option($user_id, 's2member_bp_activation_role', $role); update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user)); } if (($transient = 's2m_' . md5('s2member_transient_ipn_signup_vars_' . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) { update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars); // For future reference. delete_transient($transient); // This can be deleted now. } if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_payment_' . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment['subscr_gateway'])) { $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_payment['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_payment), $proxy), array('timeout' => 20)); delete_transient($transient); // This can be deleted now. } if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_eot_' . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot['subscr_gateway'])) { $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_eot['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_eot), $proxy), array('timeout' => 20)); delete_transient($transient); // This can be deleted now. } if (!headers_sent()) { // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies. @setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_configure_user_registration_front_side_paid', get_defined_vars()); do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars()); unset($__refs, $__v); } else { if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user'))) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */ $processed = 'yes'; // Mark this as yes. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); $role = ''; // Initialize ``$role`` to an empty string here, before processing. $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role; $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role; $role = !$role && $current_role ? $current_role : $role; // Use existing Role? $role = !$role ? get_option('default_role') : $role; // Otherwise default. $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']; $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level; $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level; $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level; $level = !$level ? '0' : $level; $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps']; $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip']; $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip; // Else use environment variable. $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']; $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']; $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']; $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']; $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']; $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']); $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : ''; $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes']; $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE; $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in; if (!($fname = $user->first_name)) { if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) { $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name']; } } if (!$fname) { // Also try BuddyPress. if (!empty($_pmr['field_1'])) { // BuddyPress? $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1'])); } } if (!($lname = $user->last_name)) { if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) { $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name']; } } if (!$lname) { // Also try BuddyPress. if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) { $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1'])); } } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) { $fname = trim($login); $lname = ''; // Username and empty Last Name. } $name = trim($fname . ' ' . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) { $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass']; } } if (!$pass) { // Also try BuddyPress Password. if (!empty($_pmr['signup_password'])) { // BuddyPress? $pass = (string) $_pmr['signup_password']; } } if ($pass) { !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL; update_user_option($user_id, 'default_password_nag', FALSE, TRUE); } update_user_option($user_id, 's2member_registration_ip', $ip); update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time); update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway); update_user_option($user_id, 's2member_subscr_id', $subscr_id); update_user_option($user_id, 's2member_subscr_baid', $subscr_baid); update_user_option($user_id, 's2member_subscr_cid', $subscr_cid); update_user_option($user_id, 's2member_custom', $custom); update_user_option($user_id, 's2member_notes', $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, 'first_name', $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, 'last_name', $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === 'full' && $name) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name))); } else { if ($custom_reg_display_name === 'first' && $fname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname))); } else { if ($custom_reg_display_name === 'last' && $lname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname))); } else { if ($custom_reg_display_name === 'login' && $login) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login))); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) { remove_user_from_blog($user_id, $current_site->blog_id); } // No Main Site Role. if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) { // Recorded yet? update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) { foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) { $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id'])); $field_id_class = preg_replace('/_/', '-', $field_var); if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) { $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, 's2member_custom_fields', $fields); } if ($level > 0) { $pr_times = get_user_option('s2member_paid_registration_times', $user_id); $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level']; $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level]; update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now. } if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) { update_user_option($user_id, 's2member_bp_activation_role', $role); update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user)); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', get_defined_vars()); do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars()); unset($__refs, $__v); } else { if (is_blog_admin() && $pagenow === 'user-new.php' || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) { // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`. $processed = 'yes'; // Mark this as yes, to indicate that a routine was processed. $current_role = c_ws_plugin__s2member_user_access::user_access_role($user); $role = ''; // Initialize $role to an empty string here, before processing. $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role; $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role; $role = !$role && $current_role ? $current_role : $role; // Use existing Role? $role = !$role ? get_option('default_role') : $role; // Otherwise default. $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']; $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level; $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level; $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level; $level = !$level ? '0' : $level; $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps']; $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip']; $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']; $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']; $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']; $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']; $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']; $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']); $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : ''; $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes']; $opt_in = !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : FALSE; if (!($fname = $user->first_name)) { // `Users → Add New`. if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) { $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name']; } } if (!($lname = $user->last_name)) { // `Users → Add New`. if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) { $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name']; } } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) { $fname = trim($login); $lname = ''; // Username and empty Last Name. } $name = trim($fname . ' ' . $lname); // Both names. if (!($pass = $password)) { // Try s2Member's generator. if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) { $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass']; } } if (!$pass) { // Also try the `Users → Add New` form. if (!empty($_pmr['pass1'])) { // Field in `/user-new.php`. $pass = (string) $_pmr['pass1']; } } if ($pass) { !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL; update_user_option($user_id, 'default_password_nag', FALSE, TRUE); } update_user_option($user_id, 's2member_registration_ip', $ip); update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time); update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway); update_user_option($user_id, 's2member_subscr_id', $subscr_id); update_user_option($user_id, 's2member_subscr_baid', $subscr_baid); update_user_option($user_id, 's2member_subscr_cid', $subscr_cid); update_user_option($user_id, 's2member_custom', $custom); update_user_option($user_id, 's2member_notes', $notes); if (!$user->first_name && $fname) { update_user_meta($user_id, 'first_name', $fname); } if (!$user->last_name && $lname) { update_user_meta($user_id, 'last_name', $lname); } if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === 'full' && $name) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name))); } else { if ($custom_reg_display_name === 'first' && $fname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname))); } else { if ($custom_reg_display_name === 'last' && $lname) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname))); } else { if ($custom_reg_display_name === 'login' && $login) { wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login))); } } } } } if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) { remove_user_from_blog($user_id, $current_site->blog_id); } // No Main Site Role. if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) { // Recorded yet? update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id); } } if ($current_role !== $role) { // Only if NOT the current Role. $user->set_role($role); } // s2Member. if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) { $user->add_cap('access_s2member_ccap_' . $ccap); } } } if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) { foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) { $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id'])); $field_id_class = preg_replace('/_/', '-', $field_var); if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) { $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var]; } } } unset($field, $field_var, $field_id_class); // Housekeeping. if (!empty($fields)) { // Only if NOT empty. update_user_option($user_id, 's2member_custom_fields', $fields); } if ($level > 0) { $pr_times = get_user_option('s2member_paid_registration_times', $user_id); $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level']; $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level]; update_user_option($user_id, 's2member_paid_registration_times', $pr_times); // Update now. } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_configure_user_registration_admin_side', get_defined_vars()); unset($__refs, $__v); } } } if ($processed === 'yes') { /** * If processed, all of these will have been defined by now. * * @var $role string Reference for IDEs. * @var $level string Reference for IDEs. * @var $ccaps string Reference for IDEs. * @var $auto_eot_time string|integer Reference for IDEs. * @var $fname string Reference for IDEs. * @var $lname string Reference for IDEs. * @var $name string Reference for IDEs. * @var $email string Reference for IDEs. * @var $login string Reference for IDEs. * @var $pass string Reference for IDEs. * @var $ip string Reference for IDEs. * @var $opt_in boolean Reference for IDEs. * @var $fields array Reference for IDEs. */ if ($urls = $GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_urls']) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $urls) as $url) { // Notify each of the URLs. if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) { if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) { if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) { if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) { if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) { if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) { if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) { if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) { if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) { if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) { if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) { if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } } unset($urls, $url, $var, $val); // Housekeeping. if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = '(s2Member / API Notification Email) - Registration'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'role: %%role%%' . "\n"; $msg .= 'level: %%level%%' . "\n"; $msg .= 'ccaps: %%ccaps%%' . "\n"; $msg .= 'auto_eot_time: %%auto_eot_time%%' . "\n"; $msg .= 'user_first_name: %%user_first_name%%' . "\n"; $msg .= 'user_last_name: %%user_last_name%%' . "\n"; $msg .= 'user_full_name: %%user_full_name%%' . "\n"; $msg .= 'user_email: %%user_email%%' . "\n"; $msg .= 'user_login: %%user_login%%' . "\n"; $msg .= 'user_pass: %%user_pass%%' . "\n"; $msg .= 'user_ip: %%user_ip%%' . "\n"; $msg .= 'user_id: %%user_id%%' . "\n"; foreach ($fields as $var => $val) { $msg .= $var . ': %%' . $var . '%%' . "\n"; } $msg .= 'cv0: %%cv0%%' . "\n"; $msg .= 'cv1: %%cv1%%' . "\n"; $msg .= 'cv2: %%cv2%%' . "\n"; $msg .= 'cv3: %%cv3%%' . "\n"; $msg .= 'cv4: %%cv4%%' . "\n"; $msg .= 'cv5: %%cv5%%' . "\n"; $msg .= 'cv6: %%cv6%%' . "\n"; $msg .= 'cv7: %%cv7%%' . "\n"; $msg .= 'cv8: %%cv8%%' . "\n"; $msg .= 'cv9: %%cv9%%'; if ($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)) { if ($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($auto_eot_time), $msg)) { if ($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($fname), $msg)) { if ($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($lname), $msg)) { if ($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($name), $msg)) { if ($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($email), $msg)) { if ($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($login), $msg)) { if ($msg = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($pass), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ip), $msg)) { if ($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } if ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_registration_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_registration_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } } } } } } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on); // Housekeeping. } if (!empty($GLOBALS['ws_plugin__s2member_registration_return_url']) && ($url = $GLOBALS['ws_plugin__s2member_registration_return_url'])) { if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) { if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) { if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) { if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) { if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) { if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) { if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) { if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) { if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) { if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) { if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) { if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { // Custom Fields. if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } if ($url = trim($url)) { // Preserve remaining Replacements; because the parent routine may perform replacements too. $GLOBALS['ws_plugin__s2member_registration_return_url'] = $url; } } } } } } } } } } } } } } } unset($url, $var, $val); // Housekeeping. c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, TRUE, $user_id); /* Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques. @TODO It may also be impossible to delete cookies when fired inside: `/wp-activate.php`. */ if (!headers_sent()) { @setcookie('s2member_subscr_gateway', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_gateway', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie('s2member_subscr_id', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_id', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie('s2member_custom', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_custom', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie('s2member_item_number', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_item_number', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); } /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file. Logging now supports Multisite Networking as well. */ $reg_vars = get_defined_vars(); // All defined vars. $reg_vars['_COOKIE'] = $_COOKIE; // Record cookies also. // No need to include these in the logs. Unset before log entry. unset($reg_vars['wpdb'], $reg_vars['current_site'], $reg_vars['current_blog']); c_ws_plugin__s2member_utils_logs::log_entry('reg-handler', $reg_vars); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_configure_user_registration', get_defined_vars()); unset($__refs, $__v); } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_after_configure_user_registration', get_defined_vars()); unset($__refs, $__v); // Housekeeping. }
/** * s2Member's PayPal® IPN handler ( inner processing routine ). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars); /* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */ /**/ if (!empty($paypal["txn_type"]) && preg_match("/^(web_accept|subscr_signup)\$/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["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && !empty($paypal["payer_email"])) { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", 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 ( `web_accept|subscr_signup` )."; /**/ 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["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". */ /**/ 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. */ /**/ eval('$ipn_signup_vars = $paypal; unset($ipn_signup_vars["s2member_log"]);'); /* Create array of IPN signup vars w/o s2member_log. */ /* New Subscription with advanced update vars ( option_name1, option_selection1 )? These variables are used in Subscr. Modifications. */ if (preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars."; /**/ /* Check for both the old & new subscr_id's, just in case the Return routine already changed it. */ 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. */ /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", 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); /* Unset defined __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_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"); /**/ if (preg_match("/^web_accept\$/i", $paypal["txn_type"]) && $paypal["eotper"]) { update_user_option($user_id, "s2member_auto_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 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"]; /* 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\\:/"); /**/ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines."; /**/ c_ws_plugin__s2member_email_configs::email_config() . wp_mail($paypal["payer_email"], apply_filters("ws_plugin__s2member_modification_email_sbj", _x("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars()), apply_filters("ws_plugin__s2member_modification_email_msg", _x("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x("Please log back in now.", "s2member-front", "s2member") . "\n" . wp_login_url(), 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"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in."; /**/ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial"])), $url)) && ($url = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular"])), $url)) && ($url = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["recurring"])), $url))) { if (($url = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial_term"])), $url)) && ($url = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular_term"])), $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_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) { /* Custom Registration/Profile Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } /**/ if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } } /**/ $paypal["s2member_log"][] = "Modification Notification URLs have been processed."; } /**/ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "( s2Member / API Notification Email ) - Modification"; $msg .= "\n\n"; /* Spacing in the message body. */ /**/ $msg .= "subscr_id: %%subscr_id%%\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 = 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $msg)) && ($msg = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $msg)) && ($msg = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $msg))) { if (($msg = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $msg)) && ($msg = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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_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) { /* Custom Registration/Profile Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } } /**/ if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { /* Still have a ``$sbj`` and a ``$msg``? */ /**/ foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["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"]) && 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $code)) && ($code = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $code)) && ($code = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $code))) { if (($code = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $code)) && ($code = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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_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) { /* Custom Registration/Profile Fields. */ 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 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); } } } } } } } } } } } } } } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __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. Please check the `on0` and `os0` variables in your Button Code."; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/o update vars."; /**/ if (($registration_url = c_ws_plugin__s2member_register_access::register_link_gen($paypal["subscr_gateway"], $paypal["subscr_id"], $paypal["custom"], $paypal["item_number"])) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $processing = $during = true; /* Yes, we ARE processing this. */ /**/ $sbj = preg_replace("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_GET["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_GET["s2member_paypal_proxy_use"]) ? "pro_" : "") . "signup_email_subject"]); $msg = preg_replace("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_GET["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_GET["s2member_paypal_proxy_use"]) ? "pro_" : "") . "signup_email_message"]); $rec = preg_replace("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_GET["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_GET["s2member_paypal_proxy_use"]) ? "pro_" : "") . "signup_email_recipients"]); /**/ 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $rec)) && ($rec = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $rec))) { if (($rec = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $rec)) && ($rec = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $rec))) { if (($rec = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $rec)) && ($rec = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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 (($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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $sbj)) && ($sbj = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $sbj))) { if (($sbj = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $sbj))) { if (($sbj = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $sbj)) && ($sbj = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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 (($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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $msg)) && ($msg = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $msg))) { if (($msg = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $msg)) && ($msg = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $msg))) { if (($msg = preg_replace("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(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_ds(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_ds($paypal["recurring"]), $msg)) && ($msg = preg_replace("/%%recurring\\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($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_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 (($rec = trim(preg_replace("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { 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_signup_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_signup_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"][] = "Signup Confirmation Email sent to: " . $rec . "."; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } /**/ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial"])), $url)) && ($url = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular"])), $url)) && ($url = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["recurring"])), $url))) { if (($url = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial_term"])), $url)) && ($url = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular_term"])), $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 = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } /**/ $paypal["s2member_log"][] = "Signup Notification URLs have been processed."; } /**/ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "( s2Member / API Notification Email ) - Signup"; $msg .= "\n\n"; /* Spacing in the message body. */ /**/ $msg .= "subscr_id: %%subscr_id%%\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_ip: %%user_ip%%\n"; /**/ $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; /**/ if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["subscr_id"]), $msg))) { if (($msg = preg_replace("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $msg)) && ($msg = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $msg)) && ($msg = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $msg))) { if (($msg = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $msg)) && ($msg = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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 ($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"]["signup_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_signup_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_signup_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=utf-8"); } } } } } } } } } } /**/ $paypal["s2member_log"][] = "Signup Notification Emails have been processed."; } /**/ if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial"]), $code)) && ($code = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular"]), $code)) && ($code = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["recurring"]), $code))) { if (($code = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["initial_term"]), $code)) && ($code = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["regular_term"]), $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 = 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); } } } } } } } } } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { $paypal["s2member_log"][] = "Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response."; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } /**/ if ($processing && $_GET["s2member_paypal_proxy"] && ($url = $_GET["s2member_paypal_proxy_return_url"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if ($user_id && is_object($user) && $user->ID || ($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) { $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. */ /**/ 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("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial"])), $url)) && ($url = preg_replace("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular"])), $url)) && ($url = preg_replace("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["recurring"])), $url))) { if (($url = preg_replace("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["initial_term"])), $url)) && ($url = preg_replace("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["regular_term"])), $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("/%%modification%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode((int) $modifying)), $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) { /* Custom Registration/Profile Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } /**/ if ($url = trim($url)) { /* Preserve remaining replacements. */ /* Because the parent routine may perform replacements too. */ $paypal["s2member_paypal_proxy_return_url"] = $url; } } } } } } } } } } } } } } } } /**/ $paypal["s2member_log"][] = "Subscr. Return ( `modification=" . (int) $modifying . "` ), a Proxy Return URL is ready."; } /**/ if ($processing && (preg_match("/^web_accept\$/i", $paypal["txn_type"]) || $_GET["s2member_paypal_proxy"] && preg_match("/subscr-signup-as-subscr-payment/", $_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0) && ($user_id && is_object($user) && $user->ID || ($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)) { $paypal["s2member_log"][] = "User exists. Handling `payment` for Subscription via ( `" . (preg_match("/^web_accept\$/i", $paypal["txn_type"]) ? "web_accept" : "subscr-signup-as-subscr-payment") . "` )."; /**/ $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()); /* Update the last payment time. */ /**/ $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. */ /**/ if ($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("/%%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) { /* Custom Registration/Profile Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) { break; } } } /**/ if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } } /**/ $paypal["s2member_log"][] = "Payment Notification URLs have been processed."; } /**/ if ($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 .= "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("/%%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) { /* Custom Registration/Profile Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) { break; } } } /**/ if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { /* Still have a ``$sbj`` and a ``$msg``? */ /**/ foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["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."; } } else { if ($processing && (preg_match("/^web_accept\$/i", $paypal["txn_type"]) || $_GET["s2member_paypal_proxy"] && preg_match("/subscr-signup-as-subscr-payment/", $_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0)) { $paypal["s2member_log"][] = "Storing `payment` for Subscription via ( `" . (preg_match("/^web_accept\$/i", $paypal["txn_type"]) ? "web_accept" : "subscr-signup-as-subscr-payment") . "` )."; /**/ $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", "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"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration."; /**/ set_transient("s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200); } } /**/ if ($processing && ($user_id && is_object($user) && $user->ID || ($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)) { $paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference."; /**/ update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars); } else { if ($processing) { $paypal["s2member_log"][] = "Storing IPN signup vars into a Transient Queue. These will be processed on registration."; /**/ set_transient("s2m_" . md5("s2member_transient_ipn_signup_vars_" . $paypal["subscr_id"]), $ipn_signup_vars, 43200); } } } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup` )."; $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_signup", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_wa_w_level", false, get_defined_vars()); } }
/** * Processed by WP_Cron; this handles Auto-EOTs *(EOT = End Of Term)*. * * If you have a HUGE userbase, increase the max EOTs per process. * But NOTE, this runs ``$per_process`` *(per Blog)* on a Multisite Network. * To increase, use: ``add_filter ('ws_plugin__s2member_auto_eot_system_per_process');``. * * This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`. * This Hook is used by some of s2Member Pro's Gateway integrations; allowing CRON processing * to run for important communications; which poll Payment Gateway APIs for possible EOTs. * * @package s2Member\Auto_EOT_System * @since 3.5 * * @param int $per_process Number of database records to process each time. * Can also be Filtered with `ws_plugin__s2member_auto_eot_system_per_process`. * * @return null */ public static function auto_eot_system($per_process = 6) { global $wpdb; /** @var $wpdb \wpdb */ global $current_site, $current_blog; include_once ABSPATH . 'wp-admin/includes/admin.php'; @set_time_limit(0); // Make time for processing a larger userbase. @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_auto_eot_system', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['auto_eot_system_enabled']) { $per_process = apply_filters('ws_plugin__s2member_auto_eot_system_per_process', $per_process, get_defined_vars()); if (is_array($eots = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . esc_sql(strtotime("now")) . "' LIMIT " . $per_process))) { foreach ($eots as $eot) { if (($user_id = $eot->ID) && is_object($user = new WP_User($user_id)) && $user->ID) { $auto_eot_time = get_user_option('s2member_auto_eot_time', $user_id); delete_user_option($user_id, 's2member_last_auto_eot_time'); delete_user_option($user_id, 's2member_auto_eot_time'); if (!$user->has_cap('administrator')) { if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_eot_behavior'] === 'demote') { $eot_del_type = 'auto-eot-cancellation-expiration-demotion'; // Set EOT/Del type. $custom = get_user_option('s2member_custom', $user_id); $subscr_gateway = get_user_option('s2member_subscr_gateway', $user_id); $subscr_id = get_user_option('s2member_subscr_id', $user_id); $subscr_baid = get_user_option('s2member_subscr_baid', $user_id); $subscr_cid = get_user_option('s2member_subscr_cid', $user_id); $fields = get_user_option('s2member_custom_fields', $user_id); $user_reg_ip = get_user_option('s2member_registration_ip', $user_id); $ipn_signup_vars = get_user_option('s2member_ipn_signup_vars', $user_id); $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role('subscriber'); $existing_role = c_ws_plugin__s2member_user_access::user_access_role($user); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_auto_eot_system_during_before_demote', get_defined_vars()); do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), $eot_del_type, 'modification', $demotion_role); do_action('ws_plugin__s2member_during_collective_eots', $user_id, get_defined_vars(), $eot_del_type, 'modification'); unset($__refs, $__v); // Housekeeping. if ($existing_role !== $demotion_role) { $user->set_role($demotion_role); } if (apply_filters('ws_plugin__s2member_remove_ccaps_during_eot_events', (bool) $GLOBALS['WS_PLUGIN__']['s2member']['o']['eots_remove_ccaps'], get_defined_vars())) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match('/^access_s2member_ccap_/', $cap)) { $user->remove_cap($ccap = $cap); } } } delete_user_option($user_id, 's2member_subscr_gateway'); delete_user_option($user_id, 's2member_subscr_id'); delete_user_option($user_id, 's2member_subscr_baid'); delete_user_option($user_id, 's2member_subscr_cid'); delete_user_option($user_id, 's2member_ipn_signup_vars'); if (!apply_filters('ws_plugin__s2member_preserve_paid_registration_times', TRUE)) { delete_user_option($user_id, 's2member_paid_registration_times'); } delete_user_option($user_id, 's2member_last_status_scan'); delete_user_option($user_id, 's2member_first_payment_txn_id'); delete_user_option($user_id, 's2member_last_payment_time'); delete_user_option($user_id, 's2member_last_auto_eot_time'); delete_user_option($user_id, 's2member_auto_eot_time'); delete_user_option($user_id, 's2member_file_download_access_log'); delete_user_option($user_id, 's2member_authnet_payment_failures'); update_user_option($user_id, 's2member_last_auto_eot_time', $auto_eot_time); c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Demoted by s2Member: ' . date('D M j, Y g:i a T')); if ($subscr_gateway && $subscr_id) { // Also note the Paid Subscr. Gateway/ID so there is a reference left behind here. c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Paid Subscr. ID @ time of demotion: ' . $subscr_gateway . ' → ' . $subscr_id); } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls'] && is_array($cv = preg_split('/\\|/', $custom))) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls']) as $url) { // Handle EOT Notifications. if (($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode('auto-eot-cancellation-expiration-demotion')), $url)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_id)), $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); } } } } } } } } } } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_recipients'] && is_array($cv = preg_split('/\\|/', $custom))) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = '(s2Member / API Notification Email) - EOT/Deletion'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'eot_del_type: %%eot_del_type%%' . "\n"; $msg .= 'subscr_id: %%subscr_id%%' . "\n"; $msg .= 'subscr_baid: %%subscr_baid%%' . "\n"; $msg .= 'subscr_cid: %%subscr_cid%%' . "\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('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs('auto-eot-cancellation-expiration-demotion'), $msg)) && ($msg = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_id), $msg))) { if (($msg = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_baid), $msg)) && ($msg = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($subscr_cid), $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)))) { foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_eot_del_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_eot_del_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } if ($email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_auto_eot_system_during_demote', get_defined_vars()); unset($__refs, $__v); // Housekeeping. } else { if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_eot_behavior'] === 'delete') { $eot_del_type = $GLOBALS['ws_plugin__s2member_eot_del_type'] = 'auto-eot-cancellation-expiration-deletion'; foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_auto_eot_system_during_before_delete', get_defined_vars()); do_action('ws_plugin__s2member_during_collective_eots', $user_id, get_defined_vars(), $eot_del_type, 'removal-deletion'); unset($__refs, $__v); // Housekeeping. if (is_multisite()) { remove_user_from_blog($user_id, $current_blog->blog_id); // This will automatically trigger `eot_del_notification_urls`. c_ws_plugin__s2member_user_deletions::handle_ms_user_deletions($user_id, $current_blog->blog_id, 's2says'); } else { // Otherwise, we can actually delete them. // This will automatically trigger `eot_del_notification_urls` wp_delete_user($user_id); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_auto_eot_system_during_delete', get_defined_vars()); unset($__refs, $__v); // Housekeeping. } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_auto_eot_system', get_defined_vars()); unset($__refs, $__v); // Housekeeping. } } } } } c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients(); foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_after_auto_eot_system', get_defined_vars()); unset($__refs, $__v); // Housekeeping. }
/** * Handles User removals/deletions. * * @package s2Member\User_Deletions * @since 3.5 * * @attaches-to ``add_action("delete_user");`` * @attaches-to ``add_action("wpmu_delete_user");`` * * @param int|str $user_id Numeric WordPress User ID. * @return null */ public static function handle_user_deletions($user_id = FALSE) { static $processed = array(); // No duplicate processing. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_handle_user_deletions", get_defined_vars()); unset($__refs, $__v); if (empty($processed[$user_id]) && ($processed[$user_id] = true)) { $eot_del_type = !empty($GLOBALS["ws_plugin__s2member_eot_del_type"]) ? $GLOBALS["ws_plugin__s2member_eot_del_type"] : "user-removal-deletion"; // Else use default. $custom = get_user_option("s2member_custom", $user_id); // An EOT Notification is triggered, EVEN if empty. $subscr_id = get_user_option("s2member_subscr_id", $user_id); // And also, EVEN if this is empty. $fields = get_user_option("s2member_custom_fields", $user_id); // Used in API Notifications. $user_reg_ip = get_user_option("s2member_registration_ip", $user_id); // In API Notifications. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_handle_user_before_deletions", get_defined_vars()); do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "removal-deletion"); unset($__refs, $__v); delete_user_option($user_id, "s2member_custom"); // Remove User options (for this Blog). delete_user_option($user_id, "s2member_subscr_id"); delete_user_option($user_id, "s2member_subscr_gateway"); delete_user_option($user_id, "s2member_custom_fields"); delete_user_option($user_id, "s2member_registration_ip"); delete_user_option($user_id, "s2member_ipn_signup_vars"); delete_user_option($user_id, "s2member_paid_registration_times"); delete_user_option($user_id, "s2member_sp_references"); delete_user_option($user_id, "s2member_last_status_scan"); delete_user_option($user_id, "s2member_first_payment_txn_id"); delete_user_option($user_id, "s2member_last_payment_time"); delete_user_option($user_id, "s2member_auto_eot_time"); delete_user_option($user_id, "s2member_file_download_access_arc"); delete_user_option($user_id, "s2member_file_download_access_log"); delete_user_option($user_id, "s2member_login_counter"); delete_user_option($user_id, "s2member_notes"); if (is_object($user = new WP_User($user_id)) && $user->ID && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\\|/", $custom))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) { // Handle EOT Notifications on user deletion. if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($eot_del_type)), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($subscr_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); } } } } } } } } } } if (is_object($user = new WP_User($user_id)) && $user->ID && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array($cv = preg_split("/\\|/", $custom))) { $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); $msg = $sbj = "(s2Member / API Notification Email) - EOT/Deletion"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "eot_del_type: %%eot_del_type%%\n"; $msg .= "subscr_id: %%subscr_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("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($eot_del_type), $msg)) && ($msg = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($subscr_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"]["eot_del_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } if ($email_configs_were_on) { // Back on? c_ws_plugin__s2member_email_configs::email_config(); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_handle_user_deletions", get_defined_vars()); unset($__refs, $__v); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_after_handle_user_deletions", get_defined_vars()); unset($__refs, $__v); return; }
/** * Processes List Server removals for s2Member. * * @package s2Member\List_Servers * @since 3.5 * * @param string $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`. * @param int|string $level A numeric s2Member Access Level number. * @param string $login Username for the User. * @param string $pass Plain Text Password for the User. * @param string $email Email address for the User. * @param string $fname First Name for the User. * @param string $lname Last Name for the User. * @param string $ip IP Address for the User. * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out. * @param int|string $user_id A WordPress User ID, numeric string or integer. * * @return bool True if at least one List Server is processed successfully, else false. * * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}. * @todo Add a separate option for mail debugging; or consolidate? * @todo Integrate AWeber API (much like the MailChimp API). */ public static function process_list_server_removals($role = '', $level = '', $login = '', $pass = '', $email = '', $fname = '', $lname = '', $ip = '', $opt_out = FALSE, $user_id = 0) { global $current_site, $current_blog; // For Multisite support. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_process_list_server_removals', get_defined_vars()); unset($__refs, $__v); if (c_ws_plugin__s2member_list_servers::list_servers_integrated() && ($args = func_get_args()) && $role && is_string($role) && is_numeric($level) && $login && is_string($login) && is_string($pass = (string) $pass) && $email && is_string($email) && is_email($email) && is_string($fname = (string) $fname) && is_string($lname = (string) $lname) && is_string($ip = (string) $ip) && is_bool($opt_out = (bool) $opt_out) && $opt_out && $user_id && is_numeric($user_id) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) { $ccaps = implode(',', c_ws_plugin__s2member_user_access::user_access_ccaps($user)); $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config_release(); if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_mailchimp_list_ids'])) { if (!class_exists('NC_MCAPI')) { // Include the MailChimp API Class here. include_once dirname(dirname(__FILE__)) . '/externals/mailchimp/nc-mcapi.inc.php'; } $mcapi = new NC_MCAPI($GLOBALS['WS_PLUGIN__']['s2member']['o']['mailchimp_api_key'], TRUE); foreach (preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_mailchimp_list_ids']) as $mailchimp_list) { $mailchimp = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'listUnsubscribe'); if ($mailchimp['list_id'] = trim(preg_replace('/\\:\\:.*$/', '', $mailchimp_list))) { if ($mailchimp['api_removal_response'] = $mcapi->{$mailchimp['api_removal_method']}($mailchimp['list_id'], $email, $mailchimp['api_removal_delete_member'] = apply_filters('ws_plugin__s2member_mailchimp_removal_delete_member', FALSE, get_defined_vars()), $mailchimp['api_removal_send_goodbye'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_goodbye', FALSE, get_defined_vars()), $mailchimp['api_removal_send_notify'] = apply_filters('ws_plugin__s2member_mailchimp_removal_send_notify', FALSE, get_defined_vars()))) { $mailchimp['api_removal_success'] = $removal_success = TRUE; } // Flag indicating that we DO have a successful removal; affects the function's overall return value. $mailchimp['api_removal_properties'] = $mcapi; // Include API instance too; as it contains some additional information after each method is processed (need this in the logs). $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT']; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? 'mailchimp-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'mailchimp-api.log'; if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) { if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($mailchimp, TRUE)) . "\n\n", FILE_APPEND); } } } } } } if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key']) && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_getresponse_list_ids'])) { foreach (preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_getresponse_list_ids']) as $getresponse_list) { $getresponse = array('function' => __FUNCTION__, 'func_get_args' => $args, 'api_removal_method' => 'delete_contact'); if ($getresponse['list_id'] = $getresponse['list'] = trim($getresponse_list)) { $getresponse['api_method'] = 'get_contacts'; $getresponse['api_headers'] = array('Content-Type' => 'application/json'); $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('campaigns' => array($getresponse['list_id']), 'email' => array('EQUALS' => $email))); $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE))); if (is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && ($getresponse['api_response_contact_ids'] = array_keys((array) $getresponse['api_response']->result)) && ($getresponse['api_response_contact_id'] = $getresponse['api_response_contact_ids'][0])) { $getresponse['api_method'] = 'delete_contact'; // Update method now. $getresponse['api_params'] = array($GLOBALS['WS_PLUGIN__']['s2member']['o']['getresponse_api_key'], array('contact' => $getresponse['api_response_contact_id'])); $getresponse['api_request'] = json_encode(array('method' => $getresponse['api_method'], 'params' => $getresponse['api_params'], 'id' => uniqid('', TRUE))); if (is_object($getresponse['api_response'] = json_decode(c_ws_plugin__s2member_utils_urls::remote('https://api2.getresponse.com', $getresponse['api_request'], array('headers' => $getresponse['api_headers'])))) && empty($getresponse['api_response']->error) && $getresponse['api_response']->result->deleted) { $getresponse['api_success'] = $success = TRUE; } } $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT']; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? 'getresponse-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'getresponse-api.log'; if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) { if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($getresponse, TRUE)) . "\n\n", FILE_APPEND); } } } } } } if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_aweber_list_ids'])) { foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $level . '_aweber_list_ids']) as $aweber_list) { $aweber = array('function' => __FUNCTION__, 'func_get_args' => $args, 'wp_mail_removal_method' => 'listUnsubscribe'); if ($aweber['list_id'] = trim($aweber_list)) { $aweber['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars()); c_ws_plugin__s2member_email_configs::email_config(); // Email configs MUST be ON for removal requests. // The `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>. if ($aweber['wp_mail_removal_response'] = wp_mail($aweber['list_id'] . '@aweber.com', $aweber['wp_mail_removal_sbj'] = apply_filters('ws_plugin__s2member_aweber_removal_sbj', 'REMOVE#' . $email . '#s2Member#' . $aweber['list_id'], get_defined_vars()), $aweber['wp_mail_removal_msg'] = 'REMOVE', $aweber['wp_mail_removal_headers'] = 'From: "' . preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '" <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>' . ($aweber['removal_bcc'] ? "\r\n" . 'Bcc: ' . $aweber['removal_bcc'] : '') . "\r\n" . 'Content-Type: text/plain; charset=UTF-8')) { $aweber['wp_mail_removal_success'] = $removal_success = TRUE; } // Flag indicating that we DO have a successful removal; affects the function's overall return value. c_ws_plugin__s2member_email_configs::email_config_release(); $logt = c_ws_plugin__s2member_utilities::time_details(); $logv = c_ws_plugin__s2member_utilities::ver_details(); $logm = c_ws_plugin__s2member_utilities::mem_details(); $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . @$_SERVER['HTTP_USER_AGENT']; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? 'aweber-api-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'aweber-api.log'; if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) { if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) { if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($aweber, TRUE)) . "\n\n", FILE_APPEND); } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_process_list_server_removals', get_defined_vars()); unset($__refs, $__v); if ($email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config(); } if ($user_id) { update_user_option($user_id, 's2member_opt_in', '0'); } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_after_process_list_server_removals', get_defined_vars()); unset($__refs, $__v); return apply_filters('ws_plugin__s2member_process_list_server_removals', isset($removal_success) && $removal_success, get_defined_vars()); }
/** * Remind. * * @since 151202 Reminders. * * @attaches-to ``add_action('ws_plugin__s2member_after_auto_eot_system');`` * * @param array $vars Expects an array of defined variables. */ public static function remind($vars = array()) { global $wpdb; // WP database class. $options =& $GLOBALS['WS_PLUGIN__']['s2member']['o']; if (!$options['pro_eot_reminder_email_enable']) { return; // Nothing to do here. } if (!isset($options['pro_eot_reminder_email_days'][0])) { return; // Nothing to do here. } self::$now = time(); // Current UTC timestamp. self::$recipients = json_decode($options['pro_eot_reminder_email_recipients']); self::$subject = json_decode($options['pro_eot_reminder_email_subject']); self::$message = json_decode($options['pro_eot_reminder_email_message']); if (!is_object(self::$recipients) || !is_object(self::$subject) || !is_object(self::$message)) { return; // Not possible. Possible corruption in the DB. } if (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name'] || !$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email']) { return; // Not possible. Email configuration is incomplete. } $days = preg_split('/[;,\\s]+/', trim($options['pro_eot_reminder_email_days']), -1, PREG_SPLIT_NO_EMPTY); $scan_time = apply_filters('ws_plugin__s2member_pro_eot_reminders_scan_time', strtotime('-1 day', self::$now), get_defined_vars()); $per_process = apply_filters('ws_plugin__s2member_pro_eot_reminders_per_process', $vars['per_process'], get_defined_vars()); $message_bytes_in_log = apply_filters('ws_plugin__s2member_pro_eot_reminder_email_message_bytes_in_log', 100); $mail_from = '"' . str_replace('"', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '"' . ' <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>'; $user_ids_to_exclude = ' SELECT DISTINCT `user_id` AS `ID` FROM `' . $wpdb->usermeta . '` WHERE (`meta_key` = \'' . $wpdb->prefix . 's2member_last_reminder_scan\' AND `meta_value` >= \'' . esc_sql($scan_time) . '\') OR (`meta_key` = \'' . $wpdb->prefix . 's2member_reminders_enable\' AND `meta_value` = \'0\') '; $additional_user_ids_to_exclude = apply_filters('ws_plugin__s2member_pro_eot_reminders_exclude_user_ids', array(), get_defined_vars()); $sql = ' SELECT DISTINCT `user_id` AS `ID` FROM `' . $wpdb->usermeta . '` WHERE `user_id` NOT IN(' . $user_ids_to_exclude . ') ' . ($additional_user_ids_to_exclude ? 'AND `user_id` NOT IN(\'' . implode("','", $additional_user_ids_to_exclude) . '\')' : '') . ' AND ( (`meta_key` = \'' . $wpdb->prefix . 's2member_subscr_gateway\' AND `meta_value` != \'\') OR (`meta_key` = \'' . $wpdb->prefix . 's2member_auto_eot_time\' AND `meta_value` != \'\') OR (`meta_key` = \'' . $wpdb->prefix . 's2member_last_auto_eot_time\' AND `meta_value` != \'\') ) LIMIT ' . esc_sql($per_process) . ' '; if (!($user_ids = $wpdb->get_col($sql))) { return; // Nothing to do here. } $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status(); c_ws_plugin__s2member_email_configs::email_config(); foreach ($user_ids as $_user_id) { $_eot = $_day = $_recipients = $_subject = $_message = null; if (!($_user = new WP_User($_user_id)) || !$_user->ID) { continue; // Possible DB corruption. } update_user_option($_user->ID, 's2member_last_reminder_scan', self::$now); $_eot = c_ws_plugin__s2member_utils_users::get_user_eot($_user->ID); if (!$_eot || !$_eot['type'] || !$_eot['time'] || !$_eot['tense']) { continue; // Nothing to do; i.e., no EOT or NPT time. } elseif ($_eot['type'] === 'next' && !$options['pro_eot_reminder_email_on_npt_also']) { continue; // Nothing to do; i.e., not an EOT time and no NPTs. } elseif (!($_day = self::calculate_day($_eot['time'])) && $_day !== '0') { continue; // Unable to calculate day. } elseif (!in_array($_day, $days, true)) { continue; // Nothing on this day. } elseif (!($_recipients = self::get_recipients_for_day($_day))) { continue; // No recipients. } elseif (!($_subject = self::get_subject_for_day($_day))) { continue; // No subject. } elseif (!($_message = self::get_message_for_day($_day))) { continue; // No message. } // self::fill_replacement_codes($_user, $_eot, $_recipients, $_subject, $_message); $_mail_from = apply_filters('ws_plugin__s2member_pro_eot_reminder_email_from', $mail_from, get_defined_vars()); $_recipients = apply_filters('ws_plugin__s2member_pro_eot_reminder_email_recipients', $_recipients, get_defined_vars()); $_subject = apply_filters('ws_plugin__s2member_pro_eot_reminder_email_subject', $_subject, get_defined_vars()); $_message = apply_filters('ws_plugin__s2member_pro_eot_reminder_email_message', $_message, get_defined_vars()); if (!$_recipients || !$_subject || !$_message || !$_mail_from) { continue; // Final validation must not fail. } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($_recipients) as $_recipient) { wp_mail($_recipient, $_subject, $_message, 'From: ' . $_mail_from . "\r\n" . 'Content-Type: text/plain; charset=utf-8'); $_log_entry = array('eot' => $_eot, 'eot_rfc822' => date(DATE_RFC822, $_eot['time']), 'day' => $_day, 'now' => self::$now, 'user_id' => $_user->ID, 'user_login' => $_user->user_login, 'user_email' => $_user->user_email, 'user_first_name' => $_user->first_name, 'user_last_name' => $_user->last_name, 'mail_from' => $_mail_from, 'recipient' => $_recipient, 'subject' => $_subject); if (strlen($_message) > $message_bytes_in_log) { $_log_entry['message_clip'] = substr($_message, 0, $message_bytes_in_log) . '...'; } else { $_log_entry['message'] = $_message; // Full message. } c_ws_plugin__s2member_utils_logs::log_entry('eot-reminders', $_log_entry); } } unset($_user_id, $_user, $_eot, $_day, $_mail_from, $_recipients, $_recipient, $_subject, $_message, $_log_entry); if (!$email_configs_were_on) { c_ws_plugin__s2member_email_configs::email_config_release(); } }