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


PHP SwpmUtils::get_user_ip_address方法代码示例

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


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

示例1: get_incomplete_paid_member_info_by_ip

 public static function get_incomplete_paid_member_info_by_ip()
 {
     global $wpdb;
     $user_ip = SwpmUtils::get_user_ip_address();
     if (!empty($user_ip)) {
         //Lets check if a payment has been confirmed from this user's IP and the profile needs to be completed (where username is empty).
         $username = '';
         $query = "SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl WHERE last_accessed_from_ip=%s AND user_name=%s";
         $query = $wpdb->prepare($query, $user_ip, $username);
         $result = $wpdb->get_row($query);
         return $result;
     }
     return null;
 }
开发者ID:andrewfieldwmg,项目名称:greenschoolsproject,代码行数:14,代码来源:class.swpm-utils.php

示例2: swpm_render_pp_subscription_button_sc_output

function swpm_render_pp_subscription_button_sc_output($button_code, $args)
{
    $button_id = isset($args['id']) ? $args['id'] : '';
    if (empty($button_id)) {
        return '<p style="color: red;">Error! swpm_render_pp_subscription_button_sc_output() function requires the button ID value to be passed to it.</p>';
    }
    //Check new_window parameter
    $window_target = isset($args['new_window']) ? 'target="_blank"' : '';
    $settings = SwpmSettings::get_instance();
    $button_cpt = get_post($button_id);
    //Retrieve the CPT for this button
    $membership_level_id = get_post_meta($button_id, 'membership_level_id', true);
    $paypal_email = get_post_meta($button_id, 'paypal_email', true);
    $payment_currency = get_post_meta($button_id, 'payment_currency', true);
    //Subscription payment details
    $billing_amount = get_post_meta($button_id, 'billing_amount', true);
    if (!is_numeric($billing_amount)) {
        return '<p style="color: red;">Error! The billing amount value of the button must be a numeric number. Example: 49.50 </p>';
    }
    $billing_amount = round($billing_amount, 2);
    //round the amount to 2 decimal place.
    $billing_cycle = get_post_meta($button_id, 'billing_cycle', true);
    $billing_cycle_term = get_post_meta($button_id, 'billing_cycle_term', true);
    $billing_cycle_count = get_post_meta($button_id, 'billing_cycle_count', true);
    $billing_reattempt = get_post_meta($button_id, 'billing_reattempt', true);
    //Trial billing details
    $trial_billing_amount = get_post_meta($button_id, 'trial_billing_amount', true);
    if (!empty($trial_billing_amount)) {
        if (!is_numeric($trial_billing_amount)) {
            return '<p style="color: red;">Error! The trial billing amount value of the button must be a numeric number. Example: 19.50 </p>';
        }
    }
    $trial_billing_cycle = get_post_meta($button_id, 'trial_billing_cycle', true);
    $trial_billing_cycle_term = get_post_meta($button_id, 'trial_billing_cycle_term', true);
    $sandbox_enabled = $settings->get_value('enable-sandbox-testing');
    $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_ipn=1';
    $return_url = get_post_meta($button_id, 'return_url', true);
    if (empty($return_url)) {
        $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
    }
    $cancel_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
    $user_ip = SwpmUtils::get_user_ip_address();
    $_SESSION['swpm_payment_button_interaction'] = $user_ip;
    //Custom field data
    $custom_field_value = 'subsc_ref=' . $membership_level_id;
    $custom_field_value .= '&user_ip=' . $user_ip;
    if (SwpmMemberUtils::is_member_logged_in()) {
        $custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id();
    }
    $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value);
    /* === PayPal Subscription Button Form === */
    $output = '';
    $output .= '<div class="swpm-button-wrapper swpm-pp-subscription-wrapper">';
    if ($sandbox_enabled) {
        $output .= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>';
    } else {
        $output .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>';
    }
    $output .= '<input type="hidden" name="cmd" value="_xclick-subscriptions" />';
    $output .= '<input type="hidden" name="charset" value="utf-8" />';
    $output .= '<input type="hidden" name="bn" value="TipsandTricks_SP" />';
    $output .= '<input type="hidden" name="business" value="' . $paypal_email . '" />';
    $output .= '<input type="hidden" name="currency_code" value="' . $payment_currency . '" />';
    $output .= '<input type="hidden" name="item_number" value="' . $button_id . '" />';
    $output .= '<input type="hidden" name="item_name" value="' . htmlspecialchars($button_cpt->post_title) . '" />';
    //Check trial billing
    if (!empty($trial_billing_cycle)) {
        $output .= '<input type="hidden" name="a1" value="' . $trial_billing_amount . '" /><input type="hidden" name="p1" value="' . $trial_billing_cycle . '" /><input type="hidden" name="t1" value="' . $trial_billing_cycle_term . '" />';
    }
    //Main subscription billing
    if (!empty($billing_cycle)) {
        $output .= '<input type="hidden" name="a3" value="' . $billing_amount . '" /><input type="hidden" name="p3" value="' . $billing_cycle . '" /><input type="hidden" name="t3" value="' . $billing_cycle_term . '" />';
    }
    //Re-attempt on failure
    if ($billing_reattempt != '') {
        $output .= '<input type="hidden" name="sra" value="1" />';
    }
    //Reccurring times
    if ($billing_cycle_count > 1) {
        //do not include srt value if billing cycle count set to 1 or a negetive number.
        $output .= '<input type="hidden" name="src" value="1" /><input type="hidden" name="srt" value="' . $billing_cycle_count . '" />';
    } else {
        if (empty($billing_cycle_count)) {
            $output .= '<input type="hidden" name="src" value="1" />';
        }
    }
    //Other required data
    $output .= '<input type="hidden" name="no_shipping" value="1" />';
    //Do not prompt for an address
    $output .= '<input type="hidden" name="notify_url" value="' . $notify_url . '" />';
    $output .= '<input type="hidden" name="return" value="' . $return_url . '" />';
    $output .= '<input type="hidden" name="cancel_return" value="' . $cancel_url . '" />';
    $output .= '<input type="hidden" name="custom" value="' . $custom_field_value . '" />';
    //Filter to add additional payment input fields to the form (example: langauge code or country code etc).
    $output .= apply_filters('swpm_pp_payment_form_additional_fields', '');
    //Submit button
    $button_image_url = get_post_meta($button_id, 'button_image_url', true);
    if (!empty($button_image_url)) {
        $output .= '<input type="image" src="' . $button_image_url . '" class="swpm-subscription-button-submit" alt="' . SwpmUtils::_('Subscribe Now') . '"/>';
    } else {
//.........这里部分代码省略.........
开发者ID:kevinotsuka,项目名称:coffeecircle,代码行数:101,代码来源:paypal_button_shortcode_view.php

示例3: create_swpm_user

 private function create_swpm_user()
 {
     global $wpdb;
     $member = SwpmTransfer::$default_fields;
     $form = new SwpmFrontForm($member);
     if (!$form->is_valid()) {
         $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following'), 'extra' => $form->get_errors());
         SwpmTransfer::get_instance()->set('status', $message);
         return false;
     }
     $member_info = $form->get_sanitized();
     $free_level = SwpmUtils::get_free_level();
     $account_status = SwpmSettings::get_instance()->get_value('default-account-status', 'active');
     $member_info['last_accessed_from_ip'] = SwpmUtils::get_user_ip_address();
     $member_info['member_since'] = date("Y-m-d");
     $member_info['subscription_starts'] = date("Y-m-d");
     $member_info['account_state'] = $account_status;
     $plain_password = $member_info['plain_password'];
     unset($member_info['plain_password']);
     if (SwpmUtils::is_paid_registration()) {
         $member_info['reg_code'] = '';
         $member_id = filter_input(INPUT_GET, 'member_id', FILTER_SANITIZE_NUMBER_INT);
         $code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
         $wpdb->update($wpdb->prefix . "swpm_members_tbl", $member_info, array('member_id' => $member_id, 'reg_code' => $code));
         $query = $wpdb->prepare('SELECT membership_level FROM ' . $wpdb->prefix . 'swpm_members_tbl WHERE member_id=%d', $member_id);
         $member_info['membership_level'] = $wpdb->get_var($query);
         $last_insert_id = $member_id;
     } else {
         if (!empty($free_level)) {
             $member_info['membership_level'] = $free_level;
             $wpdb->insert($wpdb->prefix . "swpm_members_tbl", $member_info);
             $last_insert_id = $wpdb->insert_id;
         } else {
             $message = array('succeeded' => false, 'message' => SwpmUtils::_('Membership Level Couldn\'t be found.'));
             SwpmTransfer::get_instance()->set('status', $message);
             return false;
         }
     }
     $member_info['plain_password'] = $plain_password;
     $this->member_info = $member_info;
     return true;
 }
开发者ID:andrewfieldwmg,项目名称:greenschoolsproject,代码行数:42,代码来源:class.swpm-front-registration.php

示例4: swpm_render_stripe_buy_now_button_sc_output

function swpm_render_stripe_buy_now_button_sc_output($button_code, $args)
{
    $button_id = isset($args['id']) ? $args['id'] : '';
    if (empty($button_id)) {
        return '<p class="swpm-red-box">Error! swpm_render_stripe_buy_now_button_sc_output() function requires the button ID value to be passed to it.</p>';
    }
    //Check new_window parameter
    $window_target = isset($args['new_window']) ? 'target="_blank"' : '';
    $button_text = isset($args['button_text']) ? $args['button_text'] : SwpmUtils::_('Buy Now');
    $billing_address = isset($args['billing_address']) ? '1' : '';
    //By default don't show the billing address in the checkout form.
    $item_logo = '';
    //Can be used to show an item logo or thumbnail in the checkout form.
    $settings = SwpmSettings::get_instance();
    $button_cpt = get_post($button_id);
    //Retrieve the CPT for this button
    $item_name = htmlspecialchars($button_cpt->post_title);
    $membership_level_id = get_post_meta($button_id, 'membership_level_id', true);
    //Verify that this membership level exists (to prevent user paying for a level that has been deleted)
    if (!SwpmUtils::membership_level_id_exists($membership_level_id)) {
        return '<p class="swpm-red-box">Error! The membership level specified in this button does not exist. You may have deleted this membership level. Edit the button and use the correct membership level.</p>';
    }
    //Payment amount and currency
    $payment_amount = get_post_meta($button_id, 'payment_amount', true);
    if (!is_numeric($payment_amount)) {
        return '<p class="swpm-red-box">Error! The payment amount value of the button must be a numeric number. Example: 49.50 </p>';
    }
    $payment_amount = round($payment_amount, 2);
    //round the amount to 2 decimal place.
    $price_in_cents = $payment_amount * 100;
    //The amount (in cents). This value is passed to Stripe API.
    $payment_currency = get_post_meta($button_id, 'payment_currency', true);
    //Return, cancel, notifiy URLs
    $return_url = get_post_meta($button_id, 'return_url', true);
    if (empty($return_url)) {
        $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
    }
    $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_stripe_buy_now=1';
    //We are going to use it to do post payment processing.
    //$button_image_url = get_post_meta($button_id, 'button_image_url', true);//Stripe doesn't currenty support button image for their standard checkout.
    //User's IP address
    $user_ip = SwpmUtils::get_user_ip_address();
    $_SESSION['swpm_payment_button_interaction'] = $user_ip;
    //Custom field data
    $custom_field_value = 'subsc_ref=' . $membership_level_id;
    $custom_field_value .= '&user_ip=' . $user_ip;
    if (SwpmMemberUtils::is_member_logged_in()) {
        $custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id();
    }
    $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value);
    //Sandbox settings
    $sandbox_enabled = $settings->get_value('enable-sandbox-testing');
    //API keys
    $stripe_test_secret_key = get_post_meta($button_id, 'stripe_test_secret_key', true);
    $stripe_test_publishable_key = get_post_meta($button_id, 'stripe_test_publishable_key', true);
    $stripe_live_secret_key = get_post_meta($button_id, 'stripe_live_secret_key', true);
    $stripe_live_publishable_key = get_post_meta($button_id, 'stripe_live_publishable_key', true);
    if ($sandbox_enabled) {
        $publishable_key = $stripe_test_publishable_key;
        //Use sandbox API key
    } else {
        $publishable_key = $stripe_live_publishable_key;
        //Use live API key
    }
    /* === Stripe Buy Now Button Form === */
    $output = '';
    $output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
    $output .= "<form action='" . $notify_url . "' METHOD='POST'> ";
    $output .= "<script src='https://checkout.stripe.com/checkout.js' class='stripe-button'\r\n        data-key='" . $publishable_key . "'\r\n        data-panel-label='Pay'\r\n        data-amount='{$price_in_cents}'\r\n        data-name='{$item_name}'";
    $output .= "data-description='{$payment_amount} {$payment_currency}'";
    $output .= "data-label='{$button_text}'";
    //Stripe doesn't currenty support button image for their standard checkout.
    $output .= "data-currency='{$payment_currency}'";
    if (!empty($item_logo)) {
        //Show item logo/thumbnail in the stripe payment window
        $output .= "data-image='{$item_logo}'";
    }
    if (!empty($billing_address)) {
        //Show billing address in the stipe payment window
        $output .= "data-billingAddress='true'";
    }
    $output .= apply_filters('swpm_stripe_additional_checkout_data_parameters', '');
    //Filter to allow the addition of extra data parameters for stripe checkout.
    $output .= "></script>";
    $output .= wp_nonce_field('stripe_payments', '_wpnonce', true, false);
    $output .= '<input type="hidden" name="item_number" value="' . $button_id . '" />';
    $output .= "<input type='hidden' value='{$item_name}' name='item_name' />";
    $output .= "<input type='hidden' value='{$payment_amount}' name='item_price' />";
    $output .= "<input type='hidden' value='{$payment_currency}' name='currency_code' />";
    $output .= "<input type='hidden' value='{$custom_field_value}' name='custom' />";
    //Filter to add additional payment input fields to the form.
    $output .= apply_filters('swpm_stripe_payment_form_additional_fields', '');
    $output .= "</form>";
    $output .= '</div>';
    //End .swpm_button_wrapper
    return $output;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:97,代码来源:stripe_button_shortcode_view.php

示例5: get_real_ip_addr

 public static function get_real_ip_addr()
 {
     return SwpmUtils::get_user_ip_address();
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:4,代码来源:class.swpm-transfer.php

示例6: check_constraints

 private function check_constraints()
 {
     if (empty($this->userData)) {
         return false;
     }
     global $wpdb;
     $enable_expired_login = SwpmSettings::get_instance()->get_value('enable-expired-account-login', '');
     //Update the last accessed date and IP address for this login attempt. $wpdb->update(table, data, where, format, where format)
     $last_accessed_date = current_time('mysql');
     $last_accessed_ip = SwpmUtils::get_user_ip_address();
     $wpdb->update($wpdb->prefix . 'swpm_members_tbl', array('last_accessed' => $last_accessed_date, 'last_accessed_from_ip' => $last_accessed_ip), array('member_id' => $this->userData->member_id), array('%s', '%s'), array('%d'));
     //Check the member's account status.
     $can_login = true;
     if ($this->userData->account_state == 'inactive' && empty($enable_expired_login)) {
         $this->lastStatusMsg = SwpmUtils::_('Account is inactive.');
         $can_login = false;
     } else {
         if ($this->userData->account_state == 'expired' && empty($enable_expired_login)) {
             $this->lastStatusMsg = SwpmUtils::_('Account has expired.');
             $can_login = false;
         } else {
             if ($this->userData->account_state == 'pending') {
                 $this->lastStatusMsg = SwpmUtils::_('Account is pending.');
                 $can_login = false;
             }
         }
     }
     if (!$can_login) {
         $this->isLoggedIn = false;
         $this->userData = null;
         return false;
     }
     if (SwpmUtils::is_subscription_expired($this->userData)) {
         if ($this->userData->account_state == 'active') {
             $wpdb->update($wpdb->prefix . 'swpm_members_tbl', array('account_state' => 'expired'), array('member_id' => $this->userData->member_id), array('%s'), array('%d'));
         }
         if (empty($enable_expired_login)) {
             $this->lastStatusMsg = SwpmUtils::_('Account has expired.');
             $this->isLoggedIn = false;
             $this->userData = null;
             return false;
         }
     }
     $this->permitted = SwpmPermission::get_instance($this->userData->membership_level);
     $this->lastStatusMsg = SwpmUtils::_("You are logged in as:") . $this->userData->user_name;
     $this->isLoggedIn = true;
     return true;
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:48,代码来源:class.swpm-auth.php


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