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_subscription_detection.php
<?php
/**
 * Check why Stephane's subscription isn't being detected
 * This will help us understand why subscription tracks aren't being used first
 */

require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/utils/subscription_helpers.php';

$pdo = getDBConnection();

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

echo "<h1>Stephane's Subscription Detection Check</h1>";
echo "<style>
    body { font-family: Arial, sans-serif; margin: 20px; }
    table { border-collapse: collapse; width: 100%; margin: 20px 0; }
    th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
    th { background-color: #667eea; color: white; }
    .error { background-color: #f8d7da; }
    .success { background-color: #d4edda; }
    .warning { background-color: #fff3cd; }
</style>";

foreach ($users as $user) {
    $user_id = $user['id'];
    echo "<h2>User: {$user['name']} (ID: {$user_id})</h2>";
    
    // 1. Check user_subscriptions table directly
    echo "<h3>1. All Subscription Records in Database</h3>";
    $sub_stmt = $pdo->prepare("
        SELECT * FROM user_subscriptions 
        WHERE user_id = ? 
        ORDER BY created_at DESC
    ");
    $sub_stmt->execute([$user_id]);
    $all_subs = $sub_stmt->fetchAll(PDO::FETCH_ASSOC);
    
    if ($all_subs) {
        echo "<table>";
        echo "<tr><th>ID</th><th>Stripe ID</th><th>Plan</th><th>Status</th><th>Period Start</th><th>Period End</th><th>Period End > NOW()?</th><th>Created</th></tr>";
        foreach ($all_subs as $sub) {
            $period_end = $sub['current_period_end'];
            $is_future = false;
            if ($period_end) {
                if (is_numeric($period_end)) {
                    $is_future = ($period_end > time());
                } else {
                    $is_future = (strtotime($period_end) > time());
                }
            }
            
            $status_class = 'error';
            if (in_array($sub['status'], ['active', 'trialing']) && $is_future) {
                $status_class = 'success';
            } elseif (in_array($sub['status'], ['active', 'trialing']) && !$is_future) {
                $status_class = 'warning';
            }
            
            echo "<tr class='{$status_class}'>";
            echo "<td>{$sub['id']}</td>";
            echo "<td>{$sub['stripe_subscription_id']}</td>";
            echo "<td><strong>{$sub['plan_name']}</strong></td>";
            echo "<td><strong>{$sub['status']}</strong></td>";
            echo "<td>{$sub['current_period_start']}</td>";
            echo "<td>{$sub['current_period_end']}</td>";
            echo "<td>" . ($is_future ? 'YES ✅' : 'NO ❌') . "</td>";
            echo "<td>{$sub['created_at']}</td>";
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "<p class='error'>No subscription records found</p>";
    }
    
    // 2. Test hasActiveSubscription() function
    echo "<h3>2. hasActiveSubscription() Function Result</h3>";
    $subscription = hasActiveSubscription($user_id);
    if ($subscription) {
        echo "<table class='success'>";
        echo "<tr><th>Field</th><th>Value</th></tr>";
        foreach ($subscription as $key => $value) {
            echo "<tr><td>{$key}</td><td>" . (is_array($value) ? json_encode($value) : $value) . "</td></tr>";
        }
        echo "</table>";
    } else {
        echo "<p class='error'>hasActiveSubscription() returned FALSE</p>";
        
        // Check why it failed
        echo "<h4>Why did it fail? Checking query conditions:</h4>";
        $test_stmt = $pdo->prepare("
            SELECT id, plan_name, status, current_period_start, current_period_end,
                   (current_period_end > NOW()) as period_end_future,
                   (status IN ('active', 'trialing')) as status_valid
            FROM user_subscriptions
            WHERE user_id = ?
            ORDER BY created_at DESC
            LIMIT 5
        ");
        $test_stmt->execute([$user_id]);
        $test_results = $test_stmt->fetchAll(PDO::FETCH_ASSOC);
        
        if ($test_results) {
            echo "<table>";
            echo "<tr><th>ID</th><th>Plan</th><th>Status</th><th>Status Valid?</th><th>Period End</th><th>Period End Future?</th><th>Would Match?</th></tr>";
            foreach ($test_results as $test) {
                $would_match = ($test['status_valid'] && $test['period_end_future']);
                $match_class = $would_match ? 'success' : 'error';
                echo "<tr class='{$match_class}'>";
                echo "<td>{$test['id']}</td>";
                echo "<td>{$test['plan_name']}</td>";
                echo "<td>{$test['status']}</td>";
                echo "<td>" . ($test['status_valid'] ? 'YES ✅' : 'NO ❌') . "</td>";
                echo "<td>{$test['current_period_end']}</td>";
                echo "<td>" . ($test['period_end_future'] ? 'YES ✅' : 'NO ❌') . "</td>";
                echo "<td><strong>" . ($would_match ? 'YES ✅' : 'NO ❌') . "</strong></td>";
                echo "</tr>";
            }
            echo "</table>";
        }
    }
    
    // 3. Test canCreateTrack() to see what system it returns
    echo "<h3>3. canCreateTrack() Function Result</h3>";
    $track_check = canCreateTrack($user_id);
    echo "<table>";
    echo "<tr><th>Field</th><th>Value</th></tr>";
    foreach ($track_check as $key => $value) {
        if (is_array($value)) {
            $value = json_encode($value);
        }
        echo "<tr><td><strong>{$key}</strong></td><td>{$value}</td></tr>";
    }
    echo "</table>";
    
    // 4. Check monthly track usage
    echo "<h3>4. Monthly Track Usage Records</h3>";
    $usage_stmt = $pdo->prepare("
        SELECT * FROM monthly_track_usage 
        WHERE user_id = ? 
        ORDER BY subscription_period_start DESC 
        LIMIT 10
    ");
    $usage_stmt->execute([$user_id]);
    $usage_records = $usage_stmt->fetchAll(PDO::FETCH_ASSOC);
    
    if ($usage_records) {
        echo "<table>";
        echo "<tr><th>ID</th><th>Subscription ID</th><th>Period Start</th><th>Tracks Created</th><th>Track Limit</th><th>Reset At</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><strong>{$usage['tracks_created']}</strong></td>";
            echo "<td><strong>{$usage['track_limit']}</strong></td>";
            echo "<td>{$usage['reset_at']}</td>";
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "<p>No usage records found</p>";
    }
    
    // 5. Check recent track creations to see what system was used
    echo "<h3>5. Recent Track Creations (Check Logs for System Used)</h3>";
    echo "<p>Check error logs for 'create_music.php: User on subscription plan' or 'create_music.php: User on credit system'</p>";
    echo "<p>This will show whether subscription tracks or credits were used for each track.</p>";
}

echo "<hr><p><em>Generated: " . date('Y-m-d H:i:s') . "</em></p>";
?>



CasperSecurity Mini