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/api_claim_holiday_gift.php
<?php
/**
 * API Endpoint: Claim Holiday Gift
 * Grants 5 free credits to users during the holiday season
 */

session_start();
header('Content-Type: application/json');

// Include translation system
require_once __DIR__ . '/includes/translations.php';

// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
    http_response_code(401);
    echo json_encode([
        'success' => false,
        'message' => t('holiday.api.login_required')
    ]);
    exit;
}

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

try {
    $pdo = getDBConnection();
    $user_id = $_SESSION['user_id'];
    
    // Check if user has already claimed the holiday gift
    // We'll use a simple check: if they received 5 credits today from a "bonus" type with holiday gift description
    try {
        $stmt = $pdo->prepare("
            SELECT COUNT(*) as count 
            FROM credit_transactions 
            WHERE user_id = ? 
            AND type = 'bonus' 
            AND description LIKE '%Holiday Gift%'
            AND DATE(created_at) = CURDATE()
        ");
        $stmt->execute([$user_id]);
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        
        if ($result && $result['count'] > 0) {
            echo json_encode([
                'success' => false,
                'message' => t('holiday.api.already_claimed')
            ]);
            exit;
        }
    } catch (PDOException $e) {
        // Table might not exist, continue anyway
        error_log("Could not check previous claims: " . $e->getMessage());
    }
    
    // Start transaction
    $pdo->beginTransaction();
    
    // Add 5 credits to user account
    $stmt = $pdo->prepare("
        UPDATE users 
        SET credits = credits + 5 
        WHERE id = ?
    ");
    $stmt->execute([$user_id]);
    
    // Get updated credit count
    $stmt = $pdo->prepare("SELECT credits FROM users WHERE id = ?");
    $stmt->execute([$user_id]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);
    $new_credits = $user['credits'];
    
    // Record transaction in credit_transactions table (if it exists)
    try {
        $stmt = $pdo->prepare("
            INSERT INTO credit_transactions 
            (user_id, amount, type, description, created_at) 
            VALUES (?, 5, 'bonus', 'Holiday Gift - 5 Free Songs', NOW())
        ");
        $stmt->execute([$user_id]);
    } catch (PDOException $e) {
        // Table might not exist, that's okay - we'll just log it
        error_log("Credit transactions table might not exist: " . $e->getMessage());
    }
    
    // Also record in credit_purchases as a free gift (optional, for tracking)
    // Note: Free holiday gifts don't expire, so we set a far future date
    try {
        $far_future_date = date('Y-m-d H:i:s', strtotime('+100 years'));
        $stmt = $pdo->prepare("
            INSERT INTO credit_purchases 
            (user_id, package, credits, amount, payment_intent_id, expires_at, created_at) 
            VALUES (?, 'holiday_gift', 5, 0, 'holiday_gift_2024', ?, NOW())
        ");
        $stmt->execute([$user_id, $far_future_date]);
    } catch (PDOException $e) {
        // Table might not exist or have different structure, that's okay
        error_log("Could not record in credit_purchases: " . $e->getMessage());
    }
    
    // Commit transaction
    $pdo->commit();
    
    // Update session credits
    $_SESSION['credits'] = $new_credits;
    
    // Log the gift claim
    error_log("Holiday gift claimed by user_id: $user_id");
    
    echo json_encode([
        'success' => true,
        'message' => t('holiday.api.claim_success'),
        'credits_added' => 5,
        'new_credits' => $new_credits
    ]);
    
} catch (PDOException $e) {
    // Rollback on error
    if ($pdo->inTransaction()) {
        $pdo->rollBack();
    }
    
    error_log("Error claiming holiday gift: " . $e->getMessage());
    
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => t('holiday.api.error')
    ]);
} catch (Exception $e) {
    error_log("Unexpected error claiming holiday gift: " . $e->getMessage());
    
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => t('holiday.api.unexpected_error')
    ]);
}
?>


CasperSecurity Mini