T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/soundstudiopro.com/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/public_html/subscribe_essential.php
<?php
/**
 * Essential Plan Subscription Signup
 * $5/month - 5 tracks per month
 */

session_start();
require_once 'config/database.php';

// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
    header('Location: /auth/login.php?redirect=' . urlencode('/subscribe_essential.php'));
    exit;
}

$pdo = getDBConnection();

// Get user info
$stmt = $pdo->prepare("SELECT id, name, email, plan FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);

// Check if already subscribed
require_once __DIR__ . '/utils/subscription_helpers.php';
$existing_subscription = hasActiveSubscription($_SESSION['user_id']);

$stripe_secret = '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';
$stripe_publishable = 'pk_live_51Rn8TtD0zXLMB4gHMCZ5OMunyo0YtN6hBR30BoXFEiQxPG9I6U2tko6Axxwl0yJS21DCCykhC9PxAMdZoEfwJI0p00KlrZUR3w';

// TODO: Replace with actual Stripe Price ID after creating product in Stripe Dashboard
$stripe_price_id = $_GET['price_id'] ?? 'price_YOUR_PRICE_ID_HERE'; // Get this from Stripe Dashboard

// Handle subscription creation
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_subscription'])) {
    try {
        // Create or get Stripe customer
        $customer_id = null;
        
        // Check if user already has a Stripe customer ID
        if (!empty($user['stripe_customer_id'])) {
            $customer_id = $user['stripe_customer_id'];
        } else {
            // Create new Stripe customer
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'https://api.stripe.com/v1/customers');
            curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $stripe_secret]);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
                'email' => $user['email'],
                'name' => $user['name'],
                'metadata' => json_encode(['user_id' => $user['id']])
            ]));
            
            $response = curl_exec($ch);
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);
            
            if ($http_code === 200) {
                $customer = json_decode($response, true);
                $customer_id = $customer['id'];
                
                // Save customer ID to user
                $stmt = $pdo->prepare("UPDATE users SET stripe_customer_id = ? WHERE id = ?");
                $stmt->execute([$customer_id, $user['id']]);
            } else {
                throw new Exception("Failed to create Stripe customer");
            }
        }
        
        // Create Stripe Checkout Session for subscription
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://api.stripe.com/v1/checkout/sessions');
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $stripe_secret]);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
            'customer' => $customer_id,
            'mode' => 'subscription',
            'line_items' => json_encode([[
                'price' => $stripe_price_id,
                'quantity' => 1
            ]]),
            'success_url' => 'https://soundstudiopro.com/subscription_success.php?session_id={CHECKOUT_SESSION_ID}',
            'cancel_url' => 'https://soundstudiopro.com/subscribe_essential.php?canceled=1',
            'metadata' => json_encode([
                'user_id' => $user['id'],
                'plan' => 'essential'
            ])
        ]));
        
        $response = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        
        if ($http_code === 200) {
            $session = json_decode($response, true);
            header('Location: ' . $session['url']);
            exit;
        } else {
            $error_data = json_decode($response, true);
            $error_message = $error_data['error']['message'] ?? 'Failed to create subscription';
            throw new Exception($error_message);
        }
        
    } catch (Exception $e) {
        $error_message = $e->getMessage();
    }
}

$page_title = 'Subscribe to Essential Plan';
include 'includes/header.php';
?>

<main style="max-width: 800px; margin: 40px auto; padding: 20px;">
    <div style="background: #2a2a2a; border-radius: 12px; padding: 40px; text-align: center;">
        <h1 style="color: white; margin-bottom: 10px;">🎵 Essential Plan</h1>
        <p style="color: #a0aec0; font-size: 1.2rem; margin-bottom: 30px;">Perfect for creators who need a few tracks each month</p>
        
        <?php if ($existing_subscription): ?>
            <div style="background: #2d5016; padding: 20px; border-radius: 8px; margin-bottom: 30px;">
                <p style="color: #48bb78; font-size: 1.1rem;">✅ You already have an active subscription!</p>
                <p style="color: white; margin-top: 10px;">Current plan: <strong><?= ucfirst($existing_subscription['plan_name']) ?></strong></p>
                <p style="color: white;">Status: <strong><?= ucfirst($existing_subscription['status']) ?></strong></p>
                <p style="color: white;">Renews: <strong><?= date('M j, Y', strtotime($existing_subscription['current_period_end'])) ?></strong></p>
                <a href="/manage_subscription.php" style="display: inline-block; margin-top: 15px; padding: 10px 20px; background: #667eea; color: white; text-decoration: none; border-radius: 5px;">Manage Subscription</a>
            </div>
        <?php else: ?>
            <?php if (isset($error_message)): ?>
                <div style="background: #5a1a1a; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
                    <p style="color: #e53e3e;">❌ Error: <?= htmlspecialchars($error_message) ?></p>
                </div>
            <?php endif; ?>
            
            <div style="background: #1a1a1a; padding: 30px; border-radius: 8px; margin-bottom: 30px;">
                <div style="font-size: 3rem; color: #667eea; font-weight: bold; margin-bottom: 10px;">$5<span style="font-size: 1.5rem; color: #a0aec0;">/month</span></div>
                <div style="font-size: 1.5rem; color: white; margin-bottom: 30px;">5 Tracks Per Month</div>
                
                <ul style="text-align: left; color: white; list-style: none; padding: 0; margin: 20px 0;">
                    <li style="padding: 10px 0; border-bottom: 1px solid #333;">✅ 5 tracks per month</li>
                    <li style="padding: 10px 0; border-bottom: 1px solid #333;">✅ Monthly reset</li>
                    <li style="padding: 10px 0; border-bottom: 1px solid #333;">✅ Basic AI models</li>
                    <li style="padding: 10px 0; border-bottom: 1px solid #333;">✅ Standard generation speed</li>
                    <li style="padding: 10px 0; border-bottom: 1px solid #333;">✅ Personal use license</li>
                    <li style="padding: 10px 0;">✅ Cancel anytime</li>
                </ul>
                
                <form method="POST" style="margin-top: 30px;">
                    <button type="submit" name="create_subscription" value="1" style="padding: 15px 40px; background: #667eea; color: white; border: none; border-radius: 8px; font-size: 1.2rem; cursor: pointer; width: 100%;">
                        Subscribe Now - $5/month
                    </button>
                </form>
                
                <p style="color: #a0aec0; font-size: 0.9rem; margin-top: 15px;">
                    You'll be redirected to Stripe to complete your subscription. Cancel anytime.
                </p>
            </div>
        <?php endif; ?>
        
        <div style="margin-top: 30px; padding-top: 30px; border-top: 1px solid #333;">
            <a href="/account_settings.php" style="color: #667eea; text-decoration: none;">← Back to Account Settings</a>
        </div>
    </div>
</main>

<?php include 'includes/footer.php'; ?>


CasperSecurity Mini