当前位置: 首页>>代码示例>>PHP>>正文


PHP c_ws_plugin__s2member_utils_users::get_user_id_with方法代码示例

本文整理汇总了PHP中c_ws_plugin__s2member_utils_users::get_user_id_with方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_users::get_user_id_with方法的具体用法?PHP c_ws_plugin__s2member_utils_users::get_user_id_with怎么用?PHP c_ws_plugin__s2member_utils_users::get_user_id_with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c_ws_plugin__s2member_utils_users的用法示例。


在下文中一共展示了c_ws_plugin__s2member_utils_users::get_user_id_with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cp

 /**
  * s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  *
  * @todo Optimize with ``empty()`` and ``isset()``.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     if (!empty($paypal["txn_type"]) && preg_match("/^(web_accept|subscr_signup|subscr_payment)\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || !empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"]))) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_rtn = "s2m_rtn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
             list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\\:/", $paypal["item_number"], 3);
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             $paypal["ip"] = !$paypal["ip"] && $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
             if (preg_match("/^subscr_payment\$/i", $paypal["txn_type"]) && !empty($_GET["s2member_paypal_return_tra"]) && (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET["s2member_paypal_return_tra"])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra["ta"], $tra["tp"], $tra["tt"], $tra["ra"], $tra["rp"], $tra["rt"], $tra["rr"], $tra["rrt"], $tra["rra"], $tra["invoice"], $tra["checksum"])) && $tra["invoice"] === $paypal["invoice"] && $tra["checksum"] === md5($paypal["invoice"] . $paypal["ip"] . $paypal["item_number"])) {
                 $tracking_properties = true;
                 $paypal["period1"] = $tra["rr"] !== "BN" && $tra["tp"] ? $tra["tp"] . " " . $tra["tt"] : "0 D";
                 $paypal["mc_amount1"] = $tra["rr"] !== "BN" && $tra["tp"] ? number_format($tra["ta"], 2, ".", "") : "0.00";
                 $paypal["period3"] = $tra["rp"] . " " . $tra["rt"];
                 $paypal["mc_amount3"] = $tra["ra"];
                 $paypal["recurring"] = $tra["rr"] === "1" ? "1" : "0";
                 $paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                 $paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
                 $paypal["regular"] = $paypal["mc_amount3"];
                 $paypal["regular_term"] = $paypal["period3"];
                 $paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
                 $ipn_signup_vars = $paypal;
                 /* Create array of wouldbe IPN signup vars w/o s2member_log. */
                 unset($ipn_signup_vars["s2member_log"]);
             } else {
                 if (preg_match("/^(web_accept|subscr_signup)\$/i", $paypal["txn_type"])) {
                     $tracking_properties = true;
                     $paypal["period1"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                     $paypal["mc_amount1"] = strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0 ? $paypal["mc_amount1"] : "0.00";
                     if (preg_match("/^web_accept\$/i", $paypal["txn_type"])) {
                         $paypal["period3"] = $paypal["eotper"] ? $paypal["eotper"] : "1 L";
                         $paypal["mc_amount3"] = $paypal["mc_gross"];
                     }
                     $paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                     $paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
                     $paypal["regular"] = $paypal["mc_amount3"];
                     $paypal["regular_term"] = $paypal["period3"];
                     $paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
                     $ipn_signup_vars = $paypal;
                     /* Create array of wouldbe IPN signup vars w/o s2member_log. */
                     unset($ipn_signup_vars["s2member_log"]);
                 }
             }
             /*
             New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications.
             */
             if (preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) {
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
                 if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                     if (!$user->has_cap("administrator")) {
                         $processing = $modifying = $during = true;
                         foreach (array_keys(get_defined_vars()) as $__v) {
                             $__refs[$__v] =& ${$__v};
                         }
                         do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_signup_w_update_vars", get_defined_vars());
                         do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
                         unset($__refs, $__v);
                         $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))))) {
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-return-in-subscr-or-wa-w-level.inc.php

示例2: get_user_ipn_signup_vars

 /**
  * Retrieves IPN Signup Vars & validates their Subscription ID.
  *
  * The ``$user_id`` can be passed in directly; or a lookup can be performed with ``$subscr_id``.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param int|str $user_id Optional. A numeric WordPress User ID.
  * @param str $subscr_id Optional. Can be used instead of passing in a ``$user_id``.
  * 	If ``$subscr_id`` is passed in, it has to match the one found inside the resulting IPN Signup Vars collected by this routine.
  * 	If neither of these parameters are passed in, the current User is assumed instead, obtained through ``wp_get_current_user()``.
  * @return array|bool A User's IPN Signup Vars on success, else false on failure.
  */
 public static function get_user_ipn_signup_vars($user_id = FALSE, $subscr_id = FALSE)
 {
     if ($user_id || $subscr_id && ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($subscr_id)) || !$user_id && !$subscr_id && is_object($user = wp_get_current_user()) && !empty($user->ID) && ($user_id = $user->ID)) {
         $_subscr_id = get_user_option("s2member_subscr_id", $user_id);
         $_subscr_baid = get_user_option("s2member_subscr_baid", $user_id);
         if ($_subscr_id && (!$subscr_id || $subscr_id === $_subscr_id || $subscr_id === $_subscr_baid) && ($subscr_id = $_subscr_id)) {
             if (is_array($ipn_signup_vars = get_user_option("s2member_ipn_signup_vars", $user_id))) {
                 if ($ipn_signup_vars["subscr_id"] === $subscr_id) {
                     return $ipn_signup_vars;
                 }
             }
         }
     }
     return false;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:29,代码来源:utils-users.inc.php

示例3: cp

 /**
  * 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))) {
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:paypal-notify-in-wa-ccaps-wo-level.inc.php

示例4: cp

 /**
  * s2Member's PayPal IPN handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  *
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if (!empty($paypal['txn_type']) && preg_match('/^(subscr_payment|recurring_payment|merch_pmt)$/i', $paypal['txn_type']) && ((!empty($paypal['item_number']) || ($paypal['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['subscr_id']) || ($paypal['subscr_id'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && (!empty($paypal['item_name']) || ($paypal['item_name'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal['payer_email']) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal['subscr_id']))) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id'])) && !empty($paypal['txn_id']) && !empty($paypal['mc_gross'])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_payment', get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal['s2member_log'][] = 's2Member `txn_type` identified as ' . ($identified_as = '( `subscr_payment|recurring_payment` )') . '.';
             if (empty($_REQUEST['s2member_paypal_proxy'])) {
                 $paypal['s2member_log'][] = 'Sleeping for 15 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).';
                 sleep(15);
                 // Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
                 $paypal['s2member_log'][] = 'Awake. It\'s ' . date('D M j, Y g:i:s a T') . '. s2Member `txn_type` identified as ' . $identified_as . '.';
             }
             list($paypal['level'], $paypal['ccaps']) = preg_split('/\\:/', $paypal['item_number'], 3);
             $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
             $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
             $paypal['currency'] = strtoupper($paypal['mc_currency']);
             // Normalize input currency.
             $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
             if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                 $processing = $during = TRUE;
                 // Yes, we ARE processing this.
                 $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                 $pr_times['level'] = !$pr_times['level'] ? time() : $pr_times['level'];
                 // Preserves existing.
                 $pr_times['level' . $paypal['level']] = !$pr_times['level' . $paypal['level']] ? time() : $pr_times['level' . $paypal['level']];
                 update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                 // Update now.
                 if (!get_user_option('s2member_first_payment_txn_id', $user_id)) {
                     // 1st payment?
                     update_user_option($user_id, 's2member_first_payment_txn_id', $paypal['txn_id']);
                 }
                 update_user_option($user_id, 's2member_last_payment_time', time());
                 // Also update last payment time.
                 $paypal['s2member_log'][] = 'Updated Payment Times for this Member.';
                 // Flag this action in the log.
                 $fields = get_user_option('s2member_custom_fields', $user_id);
                 // These will be needed in the routines below.
                 $user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
                 // Original IP during Registration.
                 $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
                 // Now merge conditionally.
                 if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['payment_notification_urls']) {
                     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_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('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['mc_gross'])), $url)) && ($url = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_id'])), $url))) {
                                         if (($url = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_number'])), $url)) && ($url = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_name'])), $url))) {
                                             if (($url = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['first_name'])), $url)) && ($url = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['last_name'])), $url))) {
                                                 if ($url = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $url)) {
                                                     if ($url = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['payer_email'])), $url)) {
                                                         if (($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
                                                             if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . ' ' . $user->last_name))), $url)) {
                                                                 if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
                                                                     if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
                                                                         if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
                                                                             if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                                 if (is_array($fields) && !empty($fields)) {
                                                                                     foreach ($fields as $var => $val) {
                                                                                         if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                             break;
                                                                                         }
                                                                                     }
                                                                                 }
                                                                                 if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) {
                                                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $paypal['s2member_log'][] = 'Payment Notification URLs have been processed.';
                 }
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-payment-w-level.inc.php

示例5: cp

 /**
  * s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  *
  * @todo Optimize with ``empty()`` and ``isset()``.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     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"])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_rtn = "s2m_rtn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ), a Subscription Modification.";
             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["ip"] = !$paypal["ip"] && $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
             $paypal["period1"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
             $paypal["mc_amount1"] = strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0 ? $paypal["mc_amount1"] : "0.00";
             if (preg_match("/^web_accept\$/i", $paypal["txn_type"])) {
                 $paypal["period3"] = $paypal["eotper"] ? $paypal["eotper"] : "1 L";
                 $paypal["mc_amount3"] = $paypal["mc_gross"];
             }
             $paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
             $paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
             $paypal["regular"] = $paypal["mc_amount3"];
             $paypal["regular_term"] = $paypal["period3"];
             $paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
             $ipn_signup_vars = $paypal;
             /* Create array of wouldbe IPN signup vars w/o s2member_log. */
             unset($ipn_signup_vars["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;
                     foreach (array_keys(get_defined_vars()) as $__v) {
                         $__refs[$__v] =& ${$__v};
                     }
                     do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_modify", get_defined_vars());
                     do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
                     unset($__refs, $__v);
                     $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_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"];
                     $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 on ( `subscr_modify` ), a Subscription Modification.";
                     setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["subscr_id"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
                     $paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `subscr_modify` ), a Subscription Modification.";
                     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)) {
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-return-in-subscr-modify-w-level.inc.php

示例6: cp

 /**
  * s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
  *
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if (!empty($paypal['txn_type']) && preg_match('/^(web_accept|subscr_signup|subscr_payment)$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['subscr_id']) || !empty($paypal['txn_id']) && ($paypal['subscr_id'] = $paypal['txn_id'])) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status']))) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup', get_defined_vars());
         unset($__refs, $__v);
         // Housekeeping.
         if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
             $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).';
             @(list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3));
             $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
             $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
             $paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip'];
             if (preg_match('/^subscr_payment$/i', $paypal['txn_type']) && !empty($_GET['s2member_paypal_return_tra']) && (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET['s2member_paypal_return_tra'])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra['ta'], $tra['tp'], $tra['tt'], $tra['ra'], $tra['rp'], $tra['rt'], $tra['rr'], $tra['rrt'], $tra['rra'], $tra['invoice'], $tra['checksum'])) && $tra['invoice'] === $paypal['invoice'] && $tra['checksum'] === md5($paypal['invoice'] . $paypal['ip'] . $paypal['item_number'])) {
                 $tracking_properties = TRUE;
                 // Yes, these tracking properties ARE being set here.
                 $paypal['period1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? $tra['tp'] . ' ' . $tra['tt'] : '0 D';
                 $paypal['mc_amount1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? number_format($tra['ta'], 2, '.', '') : '0.00';
                 $paypal['period3'] = $tra['rp'] . ' ' . $tra['rt'];
                 $paypal['mc_amount3'] = $tra['ra'];
                 $paypal['recurring'] = $tra['rr'] === '1' ? '1' : '0';
                 $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
                 // Defaults to '0 D' (zero days).
                 $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
                 $paypal['regular'] = $paypal['mc_amount3'];
                 // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
                 $paypal['regular_term'] = $paypal['period3'];
                 // This is just set to keep a standard; this way both initial_term & regular_term are available.
                 $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
                 // If non-recurring, this should be zero, otherwise Regular.
                 $paypal['currency'] = strtoupper($paypal['mc_currency']);
                 // Normalize input currency.
                 $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
                 $ipn_signup_vars = $paypal;
                 // Copy of PayPal vars; used as IPN signup vars.
                 unset($ipn_signup_vars['s2member_log']);
                 // Create array of wouldbe IPN signup vars w/o s2member_log.
             } else {
                 if (preg_match('/^(web_accept|subscr_signup)$/i', $paypal['txn_type'])) {
                     $tracking_properties = TRUE;
                     // Yes, these tracking properties ARE being set here.
                     $paypal['period1'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
                     // Defaults to '0 D' (zero days).
                     $paypal['mc_amount1'] = strlen($paypal['mc_amount1']) && $paypal['mc_amount1'] > 0 ? $paypal['mc_amount1'] : '0.00';
                     if (preg_match('/^web_accept$/i', $paypal['txn_type'])) {
                         $paypal['period3'] = $paypal['eotper'] ? $paypal['eotper'] : '1 L';
                         // 1 Lifetime.
                         $paypal['mc_amount3'] = $paypal['mc_gross'];
                         // The 'Buy Now' amount is the full gross.
                     }
                     $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
                     // Defaults to '0 D' (zero days).
                     $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
                     $paypal['regular'] = $paypal['mc_amount3'];
                     // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
                     $paypal['regular_term'] = $paypal['period3'];
                     // This is just set to keep a standard; this way both initial_term & regular_term are available.
                     $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
                     // If non-recurring, this should be zero, otherwise Regular.
                     $paypal['currency'] = strtoupper($paypal['mc_currency']);
                     // Normalize input currency.
                     $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
                     $ipn_signup_vars = $paypal;
                     // Copy of PayPal vars; used as IPN signup vars.
                     unset($ipn_signup_vars['s2member_log']);
                     // Create array of wouldbe IPN signup vars w/o s2member_log.
                 } else {
                     $tracking_properties = FALSE;
                 }
             }
             // Not possible.
             /*
             New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications.
             */
             if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) {
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars', get_defined_vars());
                 unset($__refs, $__v);
                 // Housekeeping.
                 $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.';
                 if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                     if (!$user->has_cap('administrator')) {
                         $processing = $modifying = $during = TRUE;
                         // Yes, we ARE processing this.
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:paypal-return-in-subscr-or-wa-w-level.inc.php

示例7: cp

 /**
  * s2Member's PayPal IPN handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_payment|recurring_payment)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!empty($paypal["subscr_baid"]) || ($paypal["subscr_baid"] = $paypal["subscr_id"])) && (!empty($paypal["subscr_cid"]) || ($paypal["subscr_cid"] = $paypal["subscr_id"])) && !empty($paypal["txn_id"]) && !empty($paypal["mc_gross"])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_payment|recurring_payment` )") . ".";
             if (empty($_REQUEST["s2member_paypal_proxy"])) {
                 $paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
                 sleep(5);
                 // Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
                 $paypal["s2member_log"][] = "Awake. It's " . date("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
             }
             list($paypal["level"], $paypal["ccaps"]) = preg_split("/\\:/", $paypal["item_number"], 3);
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                 $processing = $during = true;
                 // Yes, we ARE processing this.
                 $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                 $pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"];
                 // Preserves existing.
                 $pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]];
                 update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                 // Update now.
                 if (!get_user_option("s2member_first_payment_txn_id", $user_id)) {
                     // 1st payment?
                     update_user_option($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
                 }
                 update_user_option($user_id, "s2member_last_payment_time", time());
                 // Also update last payment time.
                 $paypal["s2member_log"][] = "Updated Payment Times for this Member.";
                 // Flag this action in the log.
                 $fields = get_user_option("s2member_custom_fields", $user_id);
                 // These will be needed in the routines below.
                 $user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
                 // Original IP during Registration.
                 $user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
                 // Now merge conditionally.
                 if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                     foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url) {
                         if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_id"])), $url))) {
                             if (($url = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_baid"])), $url)) && ($url = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_cid"])), $url))) {
                                 if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["txn_id"])), $url))) {
                                     if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["item_name"])), $url))) {
                                         if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["last_name"])), $url))) {
                                             if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) {
                                                 if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["payer_email"])), $url)) {
                                                     if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
                                                         if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) {
                                                             if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
                                                                 if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
                                                                     if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
                                                                         if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                             if (is_array($fields) && !empty($fields)) {
                                                                                 foreach ($fields as $var => $val) {
                                                                                     if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                         break;
                                                                                     }
                                                                                 }
                                                                             }
                                                                             if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
                                                                                 c_ws_plugin__s2member_utils_urls::remote($url);
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
                 }
                 if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                     $msg = $sbj = "(s2Member / API Notification Email) - Payment";
                     $msg .= "\n\n";
                     // Spacing in the message body.
                     $msg .= "subscr_id: %%subscr_id%%\n";
                     $msg .= "subscr_baid: %%subscr_baid%%\n";
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-payment-w-level.inc.php

示例8: authnet_notify

 /**
  * Handles Authorize.Net IPN URL processing.
  *
  * @package s2Member\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action('init');``
  */
 public static function authnet_notify()
 {
     global $current_site, $current_blog;
     // For Multisite support.
     if (!empty($_GET['s2member_pro_authnet_notify']) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_api_login_id']) {
         @ignore_user_abort(TRUE);
         // Continue processing even if/when connection is broken by the sender.
         if (is_array($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_postvars()) && ($_authnet = $authnet)) {
             $processing = $processed = FALSE;
             // Initialize these flags.
             $authnet['s2member_log'][] = 'IPN received on: ' . date('D M j, Y g:i:s a T');
             $authnet['s2member_log'][] = 's2Member POST vars verified with Authorize.Net.';
             if ($authnet['x_subscription_id'] && $authnet['x_subscription_paynum'] && $authnet['x_response_code'] === '1') {
                 if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                     $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / PAYMENT #' . $authnet['x_subscription_paynum'] . '`).';
                     if ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($authnet['x_subscription_id'])) {
                         delete_user_option($user_id, 's2member_authnet_payment_failures');
                         $authnet['s2member_log'][] = 'Successful payment. Resetting payment failures to `0` for this subscription.';
                     }
                     $authnet['s2member_log'][] = 'IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` (`subscr_payment`).';
                     $authnet['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                     $processing = $processed = TRUE;
                     $ipn = array();
                     // Reset.
                     $ipn['txn_type'] = 'subscr_payment';
                     $ipn['subscr_id'] = $authnet['x_subscription_id'];
                     $ipn['txn_id'] = $authnet['x_trans_id'];
                     $ipn['custom'] = $authnet['s2_custom'];
                     $ipn['mc_gross'] = number_format($authnet['x_amount'], 2, '.', '');
                     $ipn['mc_currency'] = strtoupper(!empty($authnet['s2_currency']) ? $authnet['s2_currency'] : 'USD');
                     $ipn['tax'] = number_format($authnet['x_tax'], 2, '.', '');
                     $ipn['payer_email'] = $authnet['x_email'];
                     $ipn['first_name'] = $authnet['x_first_name'];
                     $ipn['last_name'] = $authnet['x_last_name'];
                     $ipn['option_name1'] = 'Referencing Customer ID';
                     $ipn['option_selection1'] = $authnet['x_subscription_id'];
                     $ipn['option_name2'] = 'Customer IP Address';
                     $ipn['option_selection2'] = NULL;
                     $ipn['item_number'] = $authnet['s2_invoice'];
                     $ipn['item_name'] = $authnet['x_description'];
                     $ipn['s2member_paypal_proxy'] = 'authnet';
                     $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                     $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                     c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                 } else {
                     $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / PAYMENT #' . $authnet['x_subscription_paynum'] . '`).';
                     $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.';
                 }
             } else {
                 if ($authnet['x_subscription_id'] && $authnet['x_subscription_paynum'] && preg_match('/^(2|3)$/', $authnet['x_response_code'])) {
                     if (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) {
                         if ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($authnet['x_subscription_id'])) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures'] && ($current_payment_failures = get_user_option('s2member_authnet_payment_failures', $user_id)) + 1 >= $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures']) {
                                 $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                                 $authnet['s2member_log'][] = 'This subscription has `' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_max_payment_failures'] . '` or more failed payments.';
                                 $authnet['s2member_log'][] = 'Max failed payments. IPN reformulated. Piping through s2Member\'s core/standard PayPal processor as `txn_type` (`subscr_eot`).';
                                 $authnet['s2member_log'][] = 'Please check PayPal IPN logs for further processing details.';
                                 $processing = $processed = TRUE;
                                 $ipn = array();
                                 // Reset.
                                 $ipn['txn_type'] = 'subscr_eot';
                                 $ipn['subscr_id'] = $authnet['x_subscription_id'];
                                 $ipn['custom'] = $authnet['s2_custom'];
                                 $ipn['period1'] = $authnet['s2_p1'];
                                 $ipn['period3'] = $authnet['s2_p3'];
                                 $ipn['payer_email'] = $authnet['x_email'];
                                 $ipn['first_name'] = $authnet['x_first_name'];
                                 $ipn['last_name'] = $authnet['x_last_name'];
                                 $ipn['option_name1'] = 'Referencing Customer ID';
                                 $ipn['option_selection1'] = $authnet['x_subscription_id'];
                                 $ipn['option_name2'] = 'Customer IP Address';
                                 $ipn['option_selection2'] = NULL;
                                 $ipn['item_number'] = $authnet['s2_invoice'];
                                 $ipn['item_name'] = $authnet['x_description'];
                                 $ipn['s2member_paypal_proxy'] = 'authnet';
                                 $ipn['s2member_paypal_proxy_use'] = 'pro-emails';
                                 $ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
                                 c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
                                 c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response(array('x_method' => 'cancel', 'x_subscription_id' => $authnet['x_subscription_id']));
                             } else {
                                 $current_payment_failures = get_user_option('s2member_authnet_payment_failures', $user_id);
                                 update_user_option($user_id, 's2member_authnet_payment_failures', $current_payment_failures + 1);
                                 $authnet['s2member_log'][] = 'Bumping payment failures for subscription: `' . $authnet['x_subscription_id'] . '`, to: `' . ($current_payment_failures + 1) . '`';
                                 $authnet['s2member_log'][] = 'Recording number of payment failures only. This does not require any action (at the moment) on the part of s2Member.';
                             }
                         } else {
                             $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                             $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference to an existing user/member.';
                         }
                     } else {
                         $authnet['s2member_log'][] = 'Authorize.Net transaction identified as (`ARB / FAILED PAYMENT`).';
                         $authnet['s2member_log'][] = 'Ignoring this IPN. The transaction does NOT contain a valid reference value/desc.';
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member-pro,代码行数:101,代码来源:authnet-notify-in.inc.php

示例9: cp

 /**
  * 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);
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-notify-in-subscr-or-wa-w-level.inc.php

示例10: cp

 /**
  * 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_cancel|recurring_payment_profile_cancel|mp_cancel)\$/i", $paypal["txn_type"]) && !(preg_match("/^recurring_payment_profile_cancel\$/i", $paypal["txn_type"]) && !empty($paypal["initial_payment_status"]) && preg_match("/^failed\$/i", $paypal["initial_payment_status"])) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal)) || ($paypal["period1"] = "0 D")) && (!empty($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal))) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!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_cancel", 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_cancel|recurring_payment_profile_cancel|mp_cancel` ).";
             list($paypal["level"], $paypal["ccaps"]) = preg_split("/\\:/", $paypal["item_number"], 3);
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                 if (!$user->has_cap("administrator")) {
                     $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 (!get_user_option("s2member_auto_eot_time", $user_id)) {
                         $processing = $during = true;
                         // Yes, we ARE processing this.
                         $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time($user_id, $paypal["period1"], $paypal["period3"]);
                         update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                         // s2Member follows-up later.
                         $paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date("D M j, Y g:i a T", $auto_eot_time);
                         foreach (array_keys(get_defined_vars()) as $__v) {
                             $__refs[$__v] =& ${$__v};
                         }
                         do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars());
                         unset($__refs, $__v);
                     } else {
                         $paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
                     }
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                         foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) {
                             // Handle Cancellation Notifications.
                             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("/%%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("/%%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"][] = "Cancellation Notification URLs have been processed.";
                     }
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                         $msg = $sbj = "(s2Member / API Notification Email) - Cancellation";
                         $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 .= "item_number: %%item_number%%\n";
                         $msg .= "item_name: %%item_name%%\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";
//.........这里部分代码省略.........
开发者ID:adnandot,项目名称:intenseburn,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-cancellation-w-level.inc.php

示例11: cp

 /**
  * 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.";
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-notify-in-subscr-modify-w-level.inc.php

示例12: cp

 /**
  * 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_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i', $paypal['txn_type']) && ($recurring = TRUE) || !empty($paypal['txn_type']) && preg_match('/^recurring_payment_profile_cancel$/i', $paypal['txn_type']) && !empty($paypal['initial_payment_status']) && preg_match('/^failed$/i', $paypal['initial_payment_status']) && ($recurring = TRUE) || !empty($paypal['txn_type']) && preg_match('/^new_case$/i', $paypal['txn_type']) && !empty($paypal['case_type']) && preg_match('/^chargeback$/i', $paypal['case_type']) && !($recurring = FALSE) || !empty($paypal['payment_status']) && preg_match('/^(refunded|reversed|reversal)$/i', $paypal['payment_status']) && !($recurring = FALSE)) && (!empty($paypal['subscr_id']) || ($paypal['subscr_id'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal)) || !empty($paypal['parent_txn_id']) && ($paypal['subscr_id'] = $paypal['parent_txn_id'])) && (!empty($paypal['period1']) || ($paypal['period1'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal, FALSE)) || empty($recurring) || ($paypal['period1'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('period1', FALSE, $paypal['subscr_id'])) || ($paypal['period1'] = '0 D')) && (!empty($paypal['period3']) || ($paypal['period3'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal, FALSE)) || empty($recurring) || ($paypal['period3'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('period3', FALSE, $paypal['subscr_id'])) || ($paypal['period3'] = '1 D')) && ((!empty($paypal['item_number']) || ($paypal['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal)) || ($paypal['item_number'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('item_number', FALSE, $paypal['subscr_id'])) || ($paypal['item_number'] = '1')) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['item_name']) || ($paypal['item_name'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal['item_name'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('item_name', FALSE, $paypal['subscr_id'])) || ($paypal['item_name'] = $_SERVER['HTTP_HOST'])) && (!empty($paypal['payer_email']) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('payer_email', FALSE, $paypal['subscr_id'])) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal['subscr_id']))) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id']))) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_eot', get_defined_vars());
         unset($__refs, $__v);
         // Housekeeping.
         if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $is_refund = preg_match('/^refunded$/i', $paypal['payment_status']) && !empty($paypal['parent_txn_id']);
             $is_reversal = preg_match('/^(reversed|reversal)$/i', $paypal['payment_status']) && !empty($paypal['parent_txn_id']);
             $is_reversal = !$is_reversal ? preg_match('/^new_case$/i', $paypal['txn_type']) && preg_match('/^chargeback$/i', $paypal['case_type']) : $is_reversal;
             $is_refund_or_reversal = $is_refund || $is_reversal;
             // If either of the previous tests above evaluated to true; then it's obviously a Refund and/or a Reversal.
             $is_partial_refund = !$is_refund || !empty($paypal['mc_gross']) && ($original_txn_type = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('txn_type', FALSE, $paypal['subscr_id'])) === 'web_accept' && ($original_mc_gross = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('mc_gross', FALSE, $paypal['subscr_id'])) <= abs($paypal['mc_gross']) ? FALSE : TRUE;
             $is_delayed_eot = !$is_refund_or_reversal && preg_match('/^(subscr_eot|recurring_payment_expired)$/i', $paypal['txn_type']) && preg_match('/^I-/i', $paypal['subscr_id']);
             if ($is_refund_or_reversal) {
                 $paypal['s2member_log'][] = 's2Member `txn_type` identified as ' . ($identified_as = '( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` )') . '.';
             } else {
                 $paypal['s2member_log'][] = 's2Member `txn_type` identified as ' . ($identified_as = '( `subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment` ) - or - `recurring_payment_profile_cancel` w/ `initial_payment_status` ( `failed` )') . '.';
             }
             if (empty($_REQUEST['s2member_paypal_proxy'])) {
                 $paypal['s2member_log'][] = 'Sleeping for 15 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).';
                 sleep(15);
                 // Sleep here for a moment. PayPal sometimes sends a subscr_eot before the subscr_signup, subscr_modify.
                 $paypal['s2member_log'][] = 'Awake. It\'s ' . date('D M j, Y g:i:s a T') . '. s2Member `txn_type` identified as ' . $identified_as . '.';
             }
             $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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) {
                 $fields = get_user_option('s2member_custom_fields', $user_id);
                 // These will be needed below.
                 $user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
                 // Needed below.
                 $user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
                 if (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option('s2member_auto_eot_time', $user_id) || $is_refund_or_reversal && $is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,partial_refunds,reversals' || $is_refund_or_reversal && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,partial_refunds,reversals' || $is_refund_or_reversal && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,reversals' || $is_refund && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds' || $is_reversal && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'reversals') {
                     if (!$user->has_cap('administrator')) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['auto_eot_system_enabled']) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_eot_behavior'] === 'demote') {
                                 $processing = $during = TRUE;
                                 // Yes, we ARE processing this.
                                 $eot_del_type = $is_refund_or_reversal ? 'ipn-refund-reversal-demotion' : 'ipn-cancellation-expiration-demotion';
                                 $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_paypal_notify_during_subscr_eot_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) {
                                     // Only if NOT the existing Role.
                                     $user->set_role($demotion_role);
                                 }
                                 // Give User the demotion Role.
                                 if (apply_filters('ws_plugin__s2member_remove_ccaps_during_eot_events', (bool) $GLOBALS['WS_PLUGIN__']['s2member']['o']['eots_remove_ccaps'] || $is_refund_or_reversal, 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', time());
                                 c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Demoted by s2Member: ' . date('D M j, Y g:i a T'));
                                 c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Paid Subscr. ID @ time of demotion: ' . $paypal['subscr_gateway'] . ' → ' . $paypal['subscr_id']);
                                 $paypal['s2member_log'][] = 'Member Level/Capabilities demoted to: ' . ucwords(preg_replace('/_/', ' ', $demotion_role)) . '.';
                                 if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) {
//.........这里部分代码省略.........
开发者ID:adnandot,项目名称:intenseburn,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-eots-w-level.inc.php

示例13: cp

 /**
  * s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
  *
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     if (!empty($paypal['txn_type']) && preg_match('/^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['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_return_before_subscr_modify', get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
             $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `subscr_modify` ), a Subscription Modification.';
             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['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $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';
             if (preg_match('/^web_accept$/i', $paypal['txn_type'])) {
                 $paypal['period3'] = !empty($paypal['eotper']) ? $paypal['eotper'] : '1 L';
                 // 1 Lifetime.
                 $paypal['mc_amount3'] = $paypal['mc_gross'];
                 // The 'Buy Now' amount is the full gross.
             }
             $paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
             // Defaults to '0 D' (zero days).
             $paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
             $paypal['regular'] = $paypal['mc_amount3'];
             // This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
             $paypal['regular_term'] = $paypal['period3'];
             // This is just set to keep a standard; this way both initial_term & regular_term are available.
             $paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
             // If non-recurring, this should be zero, otherwise Regular.
             $paypal['currency'] = strtoupper($paypal['mc_currency']);
             // Normalize input currency.
             $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
             $ipn_signup_vars = $paypal;
             // Copy of PayPal vars; used as IPN signup vars.
             unset($ipn_signup_vars['s2member_log']);
             // Create array of wouldbe IPN signup vars w/o s2member_log.
             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_return_during_before_subscr_modify', get_defined_vars());
                     do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), 'rtn-upgrade-downgrade', 'modification', 's2member_level' . $paypal['level']);
                     unset($__refs, $__v);
                     $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);
                         // Now update the $user object we're using.
                     }
                     $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']);
                     }
                     // 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');
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:paypal-return-in-subscr-modify-w-level.inc.php

示例14: get_user_ipn_signup_vars

 /**
  * Retrieves IPN Signup Vars & validates their Subscription ID.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param integer|string $user_id Optional. A numeric WordPress User ID.
  *
  * @param string         $subscr_txn_baid_cid_id Optional. Can be used instead of passing in a ``$user_id``.
  *   If ``$subscr_baid_cid_id`` is passed in, it has to match the one found inside the resulting IPN Signup Vars collected by this routine.
  *   If neither of these parameters are passed in, the current User is assumed instead, obtained through ``wp_get_current_user()``.
  *
  * @return array|bool A User's IPN Signup Vars on success, else false on failure.
  */
 public static function get_user_ipn_signup_vars($user_id = 0, $subscr_txn_baid_cid_id = '')
 {
     if ($user_id || $subscr_txn_baid_cid_id && ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($subscr_txn_baid_cid_id)) || !$user_id && !$subscr_txn_baid_cid_id && is_object($user = wp_get_current_user()) && !empty($user->ID) && ($user_id = $user->ID)) {
         $_subscr_baid = get_user_option('s2member_subscr_baid', $user_id);
         $_subscr_cid = get_user_option('s2member_subscr_cid', $user_id);
         $_subscr_id = get_user_option('s2member_subscr_id', $user_id);
         if ($_subscr_id && (!$subscr_txn_baid_cid_id || $subscr_txn_baid_cid_id === $_subscr_id || $subscr_txn_baid_cid_id === $_subscr_baid || $subscr_txn_baid_cid_id === $_subscr_cid)) {
             if (is_array($ipn_signup_vars = get_user_option('s2member_ipn_signup_vars', $user_id))) {
                 if ($ipn_signup_vars['subscr_id'] === $_subscr_id) {
                     return $ipn_signup_vars;
                 }
             }
         }
     }
     return FALSE;
     // Otherwise, return false.
 }
开发者ID:codeforest,项目名称:s2member,代码行数:31,代码来源:utils-users.inc.php

示例15: cp

 /**
  * 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);
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:paypal-notify-in-subscr-modify-w-level.inc.php


注:本文中的c_ws_plugin__s2member_utils_users::get_user_id_with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。