403Webshell
Server IP : 43.141.49.92  /  Your IP : 113.219.202.141
Web Server : Apache
System : Linux VM-8-5-opencloudos 6.6.34-9.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 19 19:35:45 CST 2024 x86_64
User : www ( 1000)
PHP Version : 8.1.27
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/wwwroot/www.ucppt.com/wp-content/plugins/wpcom-member-pro/payment/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/www.ucppt.com/wp-content/plugins/wpcom-member-pro/payment/points.php
<?php
namespace WPCOM\Member\Payments;
use WPCOM\Member\Order;

defined('ABSPATH') || exit;

class Points extends Payment{
    public function __construct() {
        $this->id = 'points';
        $this->title = '积分支付';
        $this->modal = true;
        $this->icon = '<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="128" height="128"><path d="M436.636 385.155c107.161 0 218.624-23.568 285.558-68.505v81.809h62.01V219.33c0-107.678-179.02-165.825-347.46-165.825-168.449 0-347.577 58.147-347.577 165.832v488.886c0 107.685 179.028 165.825 347.469 165.825v-61.903c-176.928 0-285.566-60.548-285.566-103.915V561.258c66.949 44.836 178.297 68.512 285.566 68.512v-62.024c-176.928 0-285.566-60.541-285.566-103.908V316.765c66.949 44.822 178.411 68.39 285.566 68.39zm0-269.732c176.935 0 285.558 60.548 285.558 103.915 0 43.366-108.63 103.914-285.558 103.914S151.07 262.704 151.07 219.338c.014-43.367 108.738-103.922 285.566-103.922zm270.642 310.84c-153.883 0-234.336 59.194-234.336 117.642v314.159c0 58.448 80.554 117.634 234.336 117.634 152.736 0 233.075-58.348 234.322-116.38h.114V543.912c-.107-58.455-80.56-117.648-234.436-117.648zm0 61.91c113.756 0 172.426 39.066 172.426 55.732 0 16.658-58.663 55.724-172.426 55.724s-172.426-39.066-172.426-55.724 58.662-55.731 172.426-55.731zm0 425.615c-113.764 0-172.426-39.066-172.426-55.724v-75.006c39.28 21.375 97.004 35.625 172.426 35.625 75.414 0 133.038-14.243 172.426-35.625v75.006c0 16.658-58.663 55.724-172.426 55.724zm0-157.123c-113.764 0-172.426-39.087-172.426-55.73v-75.007c39.28 21.375 97.004 35.61 172.426 35.61 75.414 0 133.038-14.235 172.426-35.61v75.006c0 16.644-58.663 55.724-172.426 55.724z"/></svg>';
        $this->color = 'var(--member-color,var(--theme-color,#206be7))';

        add_action('wp_ajax_wpcom_points_pay', [$this, 'paynow']);
        add_action('wp_ajax_nopriv_wpcom_points_pay', [$this, 'paynow']);
        parent::__construct();
    }

    function add_gateway($methods) {
        $user = wp_get_current_user();
        if($this->id && $user && isset($user->ID) && $user->ID){
            $methods[$this->id] = $this;
        }
        return $methods;
    }

    public function process_payment($order_id) {
        $url = Order::get_checkout_payment_url($order_id);
        return [
            'result' => 'success',
            'redirect' =>  $url,
            'height' => '320px',
            'modal-size' => 'modal-sm'
        ];
    }

    public function receipt_page($order_id) {
        $order = Order::get_order($order_id);
        if (!$order || $order->status === 'paid') return;
        $user = wp_get_current_user();
        if($user && isset($user->ID) && $user->ID){
            $points = (float)get_user_option( '_wpcom_points', $user->ID );
            $points = $this->get_points();

            if(is_numeric($points)){
                $price = $order->price;
                if(is_numeric($price) && $price > 0){
                    if($points >= $price){ ?>
                        <div style="color: #666;font-size: 14px;line-height: 1;">可用积分<span style="display: flex;align-items:center;justify-content: center;margin-top: 6px; gap: 2px;font-size: 24px;font-weight:500;color: #f76142;"><span style="font-size: .9em;"><?php echo $this->icon;?></span><?php echo $points;?></span></div>
                        <button type="button" class="btn btn-view btn-pay">立即支付</button>
                        <script src="<?php echo includes_url('js/jquery/jquery.min.js'); ?>"></script>
                        <script>
                            _ajax_url = "<?php echo admin_url( 'admin-ajax.php');?>";
                            _nonce = "<?php echo wp_create_nonce('wpcom_points_receipt_page');?>";
                            jQuery(function ($) {
                                $(document.body).on('click', '.btn', function(){
                                    var $btn = $(this);
                                    if($btn.hasClass('loading')) return false;
                                    $btn.addClass('loading').html('支付中,请稍候...');
                                    jQuery.ajax({
                                        type: 'POST',
                                        url: _ajax_url,
                                        dataType: 'json',
                                        data: {
                                            order_id: <?php echo $order_id; ?>,
                                            action: 'wpcom_points_pay',
                                            nonce: _nonce
                                        }
                                    }).done(function (data) {
                                        $btn.removeClass('loading').html('立即支付');
                                        if (data && data.redirect) {
                                            location.href = data.redirect;
                                            if(window.parent) window.parent.document.getElementById('wpcom-pay-iframe').style.height = '460px'
                                        } else {
                                            alert('支付异常,请稍候再试或者联系管理员获取帮助');
                                        }
                                    });
                                });
                            })
                        </script>
                    <?php }else{
                        $wallet_url = wpcom_subpage_url('wallet');
                        echo '<div class="text-center" style="color:#f66;"><p style="margin-bottom: .3em;">可用积分不足!</p>请确保账户有足够的积分进行支付。</div><a class="btn btn-view" target="_blank" href="' . esc_url($wallet_url) . '">查看我的积分详情 <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5742" width="128" height="128"><path d="M690.005333 469.333333l-228.864-228.864 60.330667-60.330666L853.333333 512l-331.861333 331.861333-60.330667-60.330666L690.005333 554.666667H170.666667v-85.333334z" p-id="5743"></path></svg></a>';
                    }
                }else{
                    echo '<div class="text-center" style="color:#f66;">订单价格异常</div>';
                }
            }else{
                echo '<div class="text-center" style="color:#f66;">积分获取失败</div>';
            }
        }else{
            echo '<div class="text-center" style="color:#f66;">请登录后再试</div>';
        }
    }

    function paynow(){
        $res = ['result' => -1];
        $order_id = isset($_POST['order_id']) && $_POST['order_id'] ? $_POST['order_id'] : '';
        $nonce = isset($_POST['nonce']) && $_POST['nonce'] ? $_POST['nonce'] : '';
        if($nonce && wp_verify_nonce($nonce, 'wpcom_points_receipt_page')){
            $order = $order_id ? Order::get_order($order_id) : '';
            $user_id = get_current_user_id();
            if ($order && isset($order->ID)) {
                $res['redirect'] = Order::get_checkout_return_url($order->ID, $this->id);
                self::add_log('#'.$order->number.' 提交积分支付请求', $this->id);
            }
            if($user_id && $order && isset($order->ID) && $order->number && (int) $order->user === $user_id){
                $points = $this->get_points();
                if(is_numeric($points)){
                    $price = $order->price;
                    if(is_numeric($price) && $price > 0 && $points >= $price && $order->status === 'unpaid'){
                        $title = $this->get_order_title($order);
                        $use_balance = \WPCOM\Member\Points::use_points(-($price), $user_id, $title);
                        if($use_balance){
                            $res['result'] = 0;
                            Order::payment_complete($order->ID,  $this->id);
                            self::add_log('#'.$order->number.' 订单支付完成!', $this->id);
                        }
                    }
                }
            }
        }
        wp_send_json($res);
    }

    function get_points(){
        $user = wp_get_current_user();
        if($user && isset($user->ID) && $user->ID){
            $points = (float)get_user_option( '_wpcom_points', $user->ID );
            return $points && $points > 0 ? $points : 0;
        }
        return 0;
    }
}

new Points();

Youez - 2016 - github.com/yon3zu
LinuXploit