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/save_album.php
<?php
session_start();
require_once '../config/database.php';

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

// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
    http_response_code(401);
    echo json_encode(['success' => false, 'error' => 'Unauthorized']);
    exit;
}

try {
    $input = json_decode(file_get_contents('php://input'), true);
    
    if (!isset($input['title']) || !isset($input['tracks'])) {
        throw new Exception('Missing required fields');
    }

    $pdo = getDBConnection();
    if (!$pdo) {
        throw new Exception('Database connection failed');
    }

    // Create albums table if it doesn't exist
    $pdo->exec("
        CREATE TABLE IF NOT EXISTS user_albums (
            id INT AUTO_INCREMENT PRIMARY KEY,
            user_id INT NOT NULL,
            title VARCHAR(255) NOT NULL,
            artist VARCHAR(255),
            genre VARCHAR(100),
            price DECIMAL(10,2) DEFAULT 0.00,
            description TEXT,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            FOREIGN KEY (user_id) REFERENCES users(id)
        )
    ");

    // Create album tracks table if it doesn't exist
    $pdo->exec("
        CREATE TABLE IF NOT EXISTS album_tracks (
            id INT AUTO_INCREMENT PRIMARY KEY,
            album_id INT NOT NULL,
            track_id INT NOT NULL,
            track_order INT NOT NULL,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            FOREIGN KEY (album_id) REFERENCES user_albums(id),
            FOREIGN KEY (track_id) REFERENCES music_tracks(id)
        )
    ");

    // Insert album
    $stmt = $pdo->prepare("
        INSERT INTO user_albums (user_id, title, artist, genre, price, description) 
        VALUES (?, ?, ?, ?, ?, ?)
    ");
    $stmt->execute([
        $_SESSION['user_id'],
        $input['title'],
        $input['artist'] ?? '',
        $input['genre'] ?? '',
        $input['price'] ?? 0.00,
        $input['description'] ?? ''
    ]);

    $albumId = $pdo->lastInsertId();

    // Insert album tracks
    $stmt = $pdo->prepare("
        INSERT INTO album_tracks (album_id, track_id, track_order) 
        VALUES (?, ?, ?)
    ");

    foreach ($input['tracks'] as $index => $taskId) {
        // Get track ID from task_id
        $trackStmt = $pdo->prepare("SELECT id FROM music_tracks WHERE task_id = ? AND user_id = ?");
        $trackStmt->execute([$taskId, $_SESSION['user_id']]);
        $track = $trackStmt->fetch();
        
        if ($track) {
            $stmt->execute([$albumId, $track['id'], $index + 1]);
        }
    }

    echo json_encode([
        'success' => true,
        'album_id' => $albumId,
        'message' => 'Album saved successfully'
    ]);

} catch (Exception $e) {
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'error' => $e->getMessage()
    ]);
}
?> 

CasperSecurity Mini