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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/private_html/api/toggle_crate_description_visibility.php
<?php
/**
 * Toggle Crate Description Visibility
 * Allows artist to decide if description is shown publicly
 * POST: { crate_id: int }
 */
// Prevent any output before JSON
error_reporting(E_ALL);
ini_set('display_errors', 0);
ob_start();

session_start();

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

// Clear any output
ob_clean();
header('Content-Type: application/json');

if (!isset($_SESSION['user_id'])) {
    echo json_encode(['success' => false, 'error' => 'Not authenticated']);
    exit;
}

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    echo json_encode(['success' => false, 'error' => 'Invalid request method']);
    exit;
}

$input = json_decode(file_get_contents('php://input'), true);
$crate_id = isset($input['crate_id']) ? (int)$input['crate_id'] : 0;

if (!$crate_id) {
    echo json_encode(['success' => false, 'error' => 'Crate ID is required']);
    exit;
}

try {
    $pdo = getDBConnection();
    
    if (!$pdo) {
        throw new Exception('Database connection failed');
    }
    
    // Verify crate belongs to user
    $stmt = $pdo->prepare("SELECT id, is_description_public FROM artist_playlists WHERE id = ? AND user_id = ?");
    if (!$stmt) {
        throw new Exception('Failed to prepare query: ' . implode(', ', $pdo->errorInfo()));
    }
    
    $stmt->execute([$crate_id, $_SESSION['user_id']]);
    $crate = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if (!$crate) {
        echo json_encode(['success' => false, 'error' => 'Crate not found or access denied']);
        exit;
    }
    
    // Check if is_description_public column exists
    try {
        $checkColumn = $pdo->query("SHOW COLUMNS FROM artist_playlists LIKE 'is_description_public'");
        if ($checkColumn && $checkColumn->rowCount() === 0) {
            // Add the column if it doesn't exist (default to public/1)
            $pdo->exec("ALTER TABLE artist_playlists ADD COLUMN is_description_public TINYINT(1) DEFAULT 1");
            $crate['is_description_public'] = 1;
            error_log("Added is_description_public column to artist_playlists table");
        }
    } catch (Exception $colException) {
        // Column might already exist or table structure issue - continue anyway
        error_log("Column check warning: " . $colException->getMessage());
    }
    
    // Toggle visibility - handle null/undefined as public (default)
    $current_value = $crate['is_description_public'] ?? 1;
    $current = (bool)$current_value;
    $new_visibility = !$current;
    $new_value = $new_visibility ? 1 : 0;
    
    $stmt = $pdo->prepare("UPDATE artist_playlists SET is_description_public = ? WHERE id = ?");
    if (!$stmt) {
        throw new Exception('Failed to prepare update query: ' . implode(', ', $pdo->errorInfo()));
    }
    
    $result = $stmt->execute([$new_value, $crate_id]);
    
    if (!$result) {
        throw new Exception('Update failed: ' . implode(', ', $stmt->errorInfo()));
    }
    
    // Verify the update by reading back the value
    $verifyStmt = $pdo->prepare("SELECT is_description_public FROM artist_playlists WHERE id = ?");
    $verifyStmt->execute([$crate_id]);
    $verified = $verifyStmt->fetch(PDO::FETCH_ASSOC);
    $verified_value = (bool)($verified['is_description_public'] ?? 1);
    
    echo json_encode([
        'success' => true,
        'is_description_public' => $verified_value,
        'message' => $verified_value ? 'Description is now visible to public' : 'Description is now hidden from public'
    ]);
    
} catch (Exception $e) {
    error_log("Error toggling crate description visibility: " . $e->getMessage());
    error_log("Stack trace: " . $e->getTraceAsString());
    http_response_code(500);
    echo json_encode([
        'success' => false, 
        'error' => 'Failed to update description visibility. Please try again.'
    ]);
}
?>


CasperSecurity Mini